Kodekloud Kubernetes Challenge 3 solution | Vote App | Redis | Postgresql DB | Deployment | service

Ticker

6/recent/ticker-posts

Kodekloud Kubernetes Challenge 3 solution | Vote App | Redis | Postgresql DB | Deployment | service

 Question : Deploy the given architecture to vote namespace

1. Create a  service: name = vote-service

     port = '5000'

     targetPort = '80'

     nodePort= '31000'

     service endpoint exposes deployment 'vote-deployment'

2. Create a deployment: name = 'vote-deployment'

     image = 'kodekloud/examplevotingapp_vote:before'

     status: 'Running'

3. New Service, name = 'redis'

     port: '6379'

     targetPort: '6379'

     type: 'ClusterIP'

     service endpoint exposes deployment 'redis-deployment'

4. Create new deployment, name: 'redis-deployment'

     image: 'redis:alpine'

     Volume Type: 'EmptyDir'

     Volume Name: 'redis-data'

     mountPath: '/data'

     status: 'Running'

5. Create new deployment. name: 'worker'

     image: 'kodekloud/examplevotingapp_worker'

     status: 'Running'

6. Create new service: 'db'

     port: '5432'

     targetPort: '5432'

     type: 'ClusterIP'

7. Create new deployment. name: 'db-deployment'

     image: 'postgres:9.4' and add the env: 'POSTGRES_HOST_AUTH_METHOD=trust'

     Volume Type: 'EmptyDir'

     Volume Name: 'db-data'

     mountPath: '/var/lib/postgresql/data'

     status: 'Running'

8. Create new deployment, name: 'result-deployment'

     image: 'kodekloud/examplevotingapp_result:before'

     status: 'Running'

9. Create new service, name: 'result-service'
    
    port: '5001'

    targetPort: '80'

    NodePort: '31001'



Solution: 

1. Create new Namespace vote & validate the status

root@controlplane ~   kubectl create namespace vote

namespace/vote created

root@controlplane ~  

root@controlplane ~   kubectl get namespace

NAME              STATUS   AGE

default           Active   36m

kube-node-lease   Active   36m

kube-public       Active   36m

kube-system       Active   36m

vote              Active   2s

root@controlplane ~


2.  Created  YAML  manifest files with all the parameters, Kindly clone repo or you can copy from GitLab 

git clone https://gitlab.com/nb-tech-support/devops.git

 Refer Below Video for more clarity )

3.  Create new db-deployment & validate the status

root@controlplane ~   kubectl apply -f devops/kubernetes-challenges/challenge-3/db-deployment.yml

deployment.apps/db-deployment created

root@controlplane ~  

root@controlplane ~   kubectl get deployment -n vote

NAME            READY   UP-TO-DATE   AVAILABLE   AGE

db-deployment   1/1     1            1           27s

root@controlplane ~  


4.  Create new db-service & validate the status

root@controlplane ~   kubectl apply -f devops/kubernetes-challenges/challenge-3/db-service.yml

service/db created

root@controlplane ~   kubectl get svc -n vote

NAME   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE

db     ClusterIP   10.108.140.177   <none>        5432/TCP   11s

root@controlplane ~  


5.  Create new redis-deployment &  services 

root@controlplane ~   kubectl apply -f devops/kubernetes-challenges/challenge-3/redis-deployment.yml

deployment.apps/redis-deployment created

root@controlplane ~  

root@controlplane ~   kubectl apply -f devops/kubernetes-challenges/challenge-3/redis-service.yml

service/redis created

root@controlplane ~  


6.  Create worker deployment

root@controlplane ~   kubectl apply -f devops/kubernetes-challenges/challenge-3/worker.yml

deployment.apps/worker created

root@controlplane ~  


7.  Create result deployment & service

root@controlplane ~   kubectl apply -f devops/kubernetes-challenges/challenge-3/result-deployment.yml

deployment.apps/result-deployment created

root@controlplane ~  

root@controlplane ~   kubectl apply -f devops/kubernetes-challenges/challenge-3/result-service.yml

service/result-service created

root@controlplane ~  


8.  Create vote deployment & service

root@controlplane ~   kubectl apply -f devops/kubernetes-challenges/challenge-3/vote-deployment.yml

deployment.apps/vote-deployment created

root@controlplane ~  

root@controlplane ~   kubectl apply -f devops/kubernetes-challenges/challenge-3/vote-service.yml

service/vote-service created

root@controlplane ~  


9.  Validate the complete deployment

root@controlplane ~   kubectl get all -n vote

NAME                                     READY   STATUS    RESTARTS   AGE

pod/db-deployment-7f94c7d956-9nh69       1/1     Running   0          12m

pod/redis-deployment-69957f749-5fcs6     1/1     Running   0          3m3s

pod/result-deployment-6b49cd76bc-6fjgz   1/1     Running   0          2m39s

pod/vote-deployment-8d7f7bcdc-p8w7z      1/1     Running   0          2m22s

pod/worker-64d7c4db94-f842s              1/1     Running   0          2m46s

 

NAME                     TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE

service/db               ClusterIP   10.108.140.177   <none>        5432/TCP         10m

service/redis            ClusterIP   10.110.206.89    <none>        6379/TCP         2m57s

service/result-service   NodePort    10.106.219.112   <none>        5001:31001/TCP   2m30s

service/vote-service     NodePort    10.111.78.1      <none>        5000:31000/TCP   2m11s

 

NAME                                READY   UP-TO-DATE   AVAILABLE   AGE

deployment.apps/db-deployment       1/1     1            1           12m

deployment.apps/redis-deployment    1/1     1            1           3m4s

deployment.apps/result-deployment   1/1     1            1           2m40s

deployment.apps/vote-deployment     1/1     1            1           2m22s

deployment.apps/worker              1/1     1            1           2m46s

 

NAME                                           DESIRED   CURRENT   READY   AGE

replicaset.apps/db-deployment-7f94c7d956       1         1         1       12m

replicaset.apps/redis-deployment-69957f749     1         1         1       3m3s

replicaset.apps/result-deployment-6b49cd76bc   1         1         1       2m40s

replicaset.apps/vote-deployment-8d7f7bcdc      1         1         1       2m22s

replicaset.apps/worker-64d7c4db94              1         1         1       2m46s

 root@controlplane ~  


10. Click on Check & Confirm to complete the task successfully


Happy Learning!!!!


Apart from this if you need more clarity,  I have made a  tutorial video on this , please go through and share your comments. Like and share the knowledge



Post a Comment

0 Comments

Latest Posts

Kodekloud Kubernetes Challenge 4 solution | Build a highly available Redis Cluster | redis-cluster-config | PersistentVolume