Check KodeKloud’s Kubernetes Challenge #3!

Note - if you really must see the solutions directly, find them on my GitHub page; okbobm!

What’s the scenario? Deploy the given architecture to vote namespace.

Challenge3

What are the general requirements for this challenge?

  1. Create service (i.e. vote-service)
  2. Create deployment (i.e vote-deployment)
  3. Create service (i.e. redis-service)
  4. Create deployment (i.e redis-deployment)
  5. Create deployment (i.e. worker-deployment)
  6. Create service (i.e. db-service)
  7. Create deployment (i.e. db-deployment)
  8. Create deployment (i.e. result-deployment)
  9. Create service (i.e. result-service)

Step 1: Create service (i.e. vote-service)

Requirements:

  • Create a new service: name = vote-service
  • port = ‘5000’
  • targetPort = ‘80’
  • nodePort= ‘31000’
  • service endpoint exposes deployment ‘vote-deployment’

Solution:

  • Create namespace
    • k create ns vote
  • Create a yaml file for the vote-service
    • Apply from yaml
      • k apply -f vote-service.yaml
  • Note - Won’t satisfy deployment exposed until deployment (below) is created

Step 2: Create deployment (i.e vote-deployment)

Requirements:

  • Create a deployment: name = ‘vote-deployment’
  • image = ‘kodekloud/examplevotingapp_vote:before’
  • status: ‘Running’

Solution:

  • Create a yaml file for the vote-deployment
    • Apply from yaml
      • k apply -f vote-deployment.yaml

Step 3: Create service (i.e. redis-service)

Requirements:

  • New Service, name = ‘redis’
  • port: ‘6379’
  • targetPort: ‘6379’
  • type: ‘ClusterIP’
  • service endpoint exposes deployment ‘redis-deployment’

    Solution:

  • Create a yaml file for the redis-service
    • Apply from yaml
      • k apply -f redis-service.yaml
  • Note - Won’t satisfy deployment exposed until deployment (below) is created

Step 4: Create deployment (i.e redis-deployment)

Requirements:

  • Create new deployment, name: ‘redis-deployment’
  • image: ‘redis:alpine’
  • Volume Type: ‘EmptyDir’
  • Volume Name: ‘redis-data’
  • mountPath: ‘/data’
  • status: ‘Running’

Solution:

  • Create a yaml file for the redis-deployment
  • Apply from yaml
    • k apply -f redis-deployment.yaml

Step 5: Create deployment (i.e. worker-deployment)

Requirements:

  • Create new deployment. name: ‘worker’
  • image: ‘kodekloud/examplevotingapp_worker’
  • status: ‘Running’

Solution:

  • Create a yaml file for the worker-deployment
  • Apply from yaml
    • k apply -f worker-deployment.yaml

Step 6: Create service (i.e. db-service)

Requirements:

  • Create new service: ‘db’
  • port: ‘5432’
  • targetPort: ‘5432’
  • type: ‘ClusterIP’

Solution:

  • Create a yaml file for the db-service
  • Apply from yaml
    • k apply -f db-service.yaml

Step 7: Create deployment (i.e. db-deployment)

Requirements:

  • 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’

Solution:

  • Create a yaml file for the db-deployment
  • Apply from yaml
    • k apply -f db-deployment.yaml

Step 8: Create deployment (i.e. result-deployment)

Requirements:

  • Create new deployment, name: ‘result-deployment’
  • image: ‘kodekloud/examplevotingapp_result:before’
  • status: ‘Running’

Solution:

  • Create a yaml file for the result-deployment
  • Apply from yaml
    • k apply -f result-deployment.yaml

Step 9: Create service (i.e. result-service)

Requirements:

  • port: ‘5001’
  • targetPort: ‘80’
  • NodePort: ‘31001’

Solution:

  • Create a yaml file for the result-service
  • Apply from yaml
    • k apply -f result-service.yaml

Finally - completed!

You should see everything in green as in the diagram below:

Challenge3_completed

Future bonus points: write a script to complete all the scripts at once!

(Find something in error or that could be done better? Contact me! I would love to hear from you.)