Skip to content

Latest commit

 

History

History
172 lines (100 loc) · 4.6 KB

README.md

File metadata and controls

172 lines (100 loc) · 4.6 KB

Challenge 3

Deploy the given architecture to vote namespace. Find the lab here

As ever, the order you create the resources is significant, and largely governed by the direction of the arrows in the diagram. There are a lot of inter-dependencies in this one, and things will break if deployed in the wrong order. Since all the applications are going to depend on their data sources, we do those first, followed by the services that front the data sources, then the rest.

Note that some of the deployments may take up to a minute to start fully and reach running state.

You should study the manifests provided in the repo carefully and understand how they provide what the question asks.

  1. vote (namespace)


    Create a new namespace: name = 'vote'

    kubectl create namespace vote
  2. db-deployment


    Create new deployment. name: 'db-deployment'

    Apply the manifest

  3. db-service


    Create new service: 'db'

    Apply the manifest

  4. redis-deployment


    Create new deployment, name: 'redis-deployment'

    Apply the manifest

  5. redis-service


    New Service, name = 'redis'

    Apply the manifest

  6. worker


    Create new deployment. name: 'worker'

    Apply the manifest

  7. vote-deployment


    Create a deployment: name = 'vote-deployment'

    Apply the manifest

  8. vote-service


    Create a new service: name = vote-service

    Apply the manifest

  9. result-deployment


    Create a new service: name = result-deployment

    Apply the manifest

  10. result-service


    Create a new service: name = result-service

    Apply the manifest

Automate the lab in a single script!

As DevOps engineers, we love everything to be automated!

What we can do here is to clone this repo down to the lab to get all the YAML manifest solutions, then apply them in the correct order. When the script completes, you can press the Check button and the lab will be complete!

Since there is a strong dependency between all the deployments, i.e. worker will fail if its data sources aren't ready, we use a shell function to wait for a pod to be running given the name of its deployment.

You should study the manifests provided in the repo carefully and understand how they provide what the question asks.

Automation Script

Paste this entire script to the lab terminal, sit back and enjoy!

{
wait_deployment() {
    deployment=$1

    echo "Waiting up to 120s for $deployment deployment to be available..."
    kubectl wait -n vote deployment $deployment --for condition=Available=True --timeout=120s

    if [ $? -ne 0 ]
    then
        echo "The deployment did not rollout correctly. Please reload the lab and try again."
        echo "If the issue persists, please report it in Slack in kubernetes-challenges channel"
        echo "https://kodekloud.slack.com/archives/C02LS58EGQ4"
        echo "Press CTRL-C to exit"
        read x
    fi
}

git clone https://github.com/kodekloudhub/kubernetes-challenges.git

kubectl create namespace vote

kubectl apply -f kubernetes-challenges/challenge-3/db-deployment.yml

wait_deployment db-deployment

kubectl apply -f kubernetes-challenges/challenge-3/db-service.yml

kubectl apply -f kubernetes-challenges/challenge-3/redis-deployment.yml

wait_deployment redis-deployment

kubectl apply -f kubernetes-challenges/challenge-3/redis-service.yml

kubectl apply -f kubernetes-challenges/challenge-3/worker.yml

wait_deployment worker

kubectl apply -f kubernetes-challenges/challenge-3/result-deployment.yml

wait_deployment result-deployment

kubectl apply -f kubernetes-challenges/challenge-3/result-service.yml

kubectl apply -f kubernetes-challenges/challenge-3/vote-deployment.yml

wait_deployment vote-deployment

kubectl apply -f kubernetes-challenges/challenge-3/vote-service.yml

echo -e "\nAutomation complete. Press the Check button.\n"
}