Kuberenetes basics class

Hello,

I am trying to do this where I create the cluster and use the deployment file. For some reason the worker-deployment fails and the event states the following Container image “kodekloud/examplevotingapp_worker:v1” already present on machine. Can someone help ?

Any help or assistance would be greatly appreciated.

Sumeet

Please follow these full steps to know what you have missed and try again :

Note: We will create deployments again so please before following the steps, Run kubectl delete deployment --all to delete old deployments and avoid any conflicts.

  1. Run git clone GitHub - mmumshad/example-voting-app-kubernetes-v2

  2. Run cd example-voting-app-kubernetes-v2/

  3. Run vim postgres-deployment.ymland modify it’s content as below then save and exit.

Note: It’s a new update from Postgres.

 apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: postgres-deployment
   labels:
     app: demo-voting-app
 spec:
   replicas: 1
   selector:
     matchLabels:
       name: postgres-pod
       app: demo-voting-app
   template:
     metadata:
       name: postgres-pod
       labels:
         name: postgres-pod
         app: demo-voting-app
     spec:
       containers:
       - name: postgres
         image: postgres:9.4
         env:
         - name: POSTGRES_USER
           value: postgres
         - name: POSTGRES_PASSWORD
           value: postgres
         - name: POSTGRES_HOST_AUTH_METHOD
           value: trust
         ports:
         - containerPort: 5432
  1. Run kubectl create -f . if you create deployments for the first time, if you created the same deployments before Run kubectl apply -f . .

  2. Run kubectl get service to get the exposed ports.

For example if the output of the command as above you can accces the voting app by hitting One_of_the_worker_nodes_IP:32733 on your browser and the same for the resulting app >> One_of_the_worker_nodes_IP:30013.

Note: The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.

Hope this helps!

Thanks bro. I will try it this afternoon. Cheers from Chicago. Wish you all well.

Sumeet

Hello Ayman,

So i deleted all deployment as suggested. Made the necessary changes on the postgres deployment file. When I do a deployment get all command they show up but its not on a ready states. Please see below.

oot@Datix2021:/home/example-voting-app-kubernetes-v2# kubectl get deployments,svc
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/postgres-deployment 0/1 1 0 23s
deployment.apps/redis-deployment 0/1 1 0 71s
deployment.apps/voting-app-deployment 2/3 3 2 2m10s
deployment.apps/worker-app-deployment 0/3 3 0 12s

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/db ClusterIP 10.100.111.33 5432/TCP 18s
service/kubernetes ClusterIP 10.100.0.1 443/TCP 3m52s
service/redis ClusterIP 10.100.97.198 6379/TCP 60s
service/voting-service LoadBalancer 10.100.85.255 a2e864e2c695841da8737fb05ee64a92-1670468843.us-east-2.elb.amazonaws.com 80:32097/TCP 116s
root@Datix2021:/home/example-voting-app-kubernetes-v2#

Looks like I did not deploy result app and svc. I have deployed it now. Please look at output now.

oot@Datix2021:/home/example-voting-app-kubernetes-v2# kubectl get deployments,svc
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/postgres-deployment 0/1 1 0 9m28s
deployment.apps/redis-deployment 0/1 1 0 10m
deployment.apps/result-app-deployment 0/1 1 0 65s
deployment.apps/voting-app-deployment 2/3 3 2 11m
deployment.apps/worker-app-deployment 0/3 3 0 9m17s

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/db ClusterIP 10.100.111.33 5432/TCP 9m23s
service/kubernetes ClusterIP 10.100.0.1 443/TCP 12m
service/redis ClusterIP 10.100.97.198 6379/TCP 10m
service/result-service LoadBalancer 10.100.229.24 a943f01e30c2241a280fda84222b3897-1056733411.us-east-2.elb.amazonaws.com 80:31984/TCP 58s
service/voting-service LoadBalancer 10.100.85.255 a2e864e2c695841da8737fb05ee64a92-1670468843.us-east-2.elb.amazonaws.com 80:32097/TCP 11m

Hello @sumeetahluwalia,
Can you please provide us with a screenshot of kubectl get and kubectl describe commands for your deployments.

Thanks,
Kodekloud Support