Skip to content

codekittyshow/k8s-manifests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K8s Manifests

First Create the namespace:

kubectl create ns prod -o yaml --dry-run=client > prod-namespace.yaml

First 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.yaml

Run below command to get logs

kubectl logs --selector=app=code-kitty-api -n prod --tail -1

Pod 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.yaml

Base 64 encode the DB_PASSWORD

echo -n "12345" | base64

Add 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-password

Apply yaml we created so far

kubectl apply -f prod-namespace.yaml
kubectl apply -f mongodb
kubectl apply -f api

Create service for Code Kitty API Deployment

kubectl expose deployment/code-kitty-api -n prod --type=LoadBalancer

Make sure you have a public IP address for the service

curl <EXTERNAL_IP>:8080/api/v1

Create 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.yaml

Let's create frontend deployment

kubectl apply -f frontend

Create service for Code Kitty Frontend Deployment

kubectl expose deployment/code-kitty -n prod --port 80 --type=LoadBalancer
kubectl get svc -n prod

Releases

No releases published

Packages

No packages published