Day 12 LAB | Deploy App use EKS Volume-based DB

Day 12 LAB | Deploy App use EKS Volume-based DB

Yesterday We have created PostgreSQL DB backed by EKS CSI Based EBS volume. Today We are going to use that DB with the newly deployed application.

For this LAB Demo, I am using below application:

(1) Create a Deployment.

apiVersion: apps/v1
kind: Deployment 
metadata:
  name: rails-crud-microservice
  labels:
    app: rails-crud
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rails-crud
  template:  
    metadata:
      labels: 
        app: rails-crud
    spec:
      containers:
        - name: rails-crud
          image: 943874580445.dkr.ecr.us-east-1.amazonaws.com/crud:v2 # replace this image with your uploaded Image
          ports: 
            - containerPort: 3000           
          env:
            - name: POSTGRES_HOST   # this type of env declaration is not recommanded for production usecase
              value: "postgres"                       
            - name: POSTGRES_USER
              value: "postgres"            
            - name: POSTGRES_PASSWORD
              value: "postgres123"

(2) Create NodePort Application Service.

To access the application from the browser, we use the NodePort service here.

apiVersion: v1
kind: Service
metadata:
  name: rails-crud-service
  labels: 
    app: rails-crud
spec:
  type: NodePort
  selector:
    app: rails-crud
  ports: 
    - port: 3000
      targetPort: 3000
      nodePort: 31231

(3) Apply the Kubernetes manifest.

Now Open the browser, with worker-node-ip and nodeport port. like
http://<WorkerNode-Public-IP>:31231

You can see the application is live... you can delete the pod and see the magic.