First Create the namespace:
kubectl create ns prod -o yaml --dry-run=client > prod-namespace.yamlFirst Create the Code Kitty API Deployment:
kubectl create deployment code-kitty-api --image=ghcr.io/codekittyshow/code-kitty-api:latest -n prod --port 8080 -o yaml --dry-run=client > api/code-kitty-api-deploy.yamlRun below command to get logs
kubectl logs --selector=app=code-kitty-api -n prod --tail -1Pod logs are like below
> @codekitty/[email protected] start /app
> tsc && node dist/index.js
Server running on port 4000
Connected to MongoDB!
DB is not connected since we have not provide env variable for it.
env:
- name: PORT
value: "8080"
- name: DB_USERNAME
value: "chamod"
- name: DB_HOST
value: "codekitty.sacfe.mongodb.net"
- name: DB_NAME
value: "CodeKitty"Create Secret
kubectl create secret generic mongodb-secret -n prod -o yaml --dry-run=client > mongodb/mongodb-secret.yamlBase 64 encode the DB_PASSWORD
echo -n "12345" | base64Add that encoded password to our secret
type: Opaque
data:
db-password: MTIzNDU=Ref secret to the env variable
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: mongodb-secret
key: db-passwordApply yaml we created so far
kubectl apply -f prod-namespace.yaml
kubectl apply -f mongodb
kubectl apply -f apiCreate service for Code Kitty API Deployment
kubectl expose deployment/code-kitty-api -n prod --type=LoadBalancerMake sure you have a public IP address for the service
curl <EXTERNAL_IP>:8080/api/v1Create the Code Kitty Frontend Deployment:
kubectl create deployment code-kitty --image=ghcr.io/codekittyshow/code-kitty:latest -n prod --port 80 -o yaml --dry-run=client > frontend/code-kitty-deploy.yamlLet's create frontend deployment
kubectl apply -f frontendCreate service for Code Kitty Frontend Deployment
kubectl expose deployment/code-kitty -n prod --port 80 --type=LoadBalancerkubectl get svc -n prod