GCP-Kubernetes-Manually

In this article, we will show you how to deploy a web application by kubernetes on gcp.

  1. run nginx on daemon
    1
    docker run -d -p 8080:80 nginx:latest
  2. change index.html in nginx container
    1
    docker cp index.html 607de9f58775:/usr/share/nginx/html/
  3. create docker image from the new container version
    1
    docker commit 607de9f58775 daccfrance:version1
  4. create tag of docker image with project id
    1
    docker tag daccfrance:version1 eu.gcr.io/kube-test-286917/daccfrance:version1
  5. push docker image to gcp container registry
    1
    docker push eu.gcr.io/kube-test-286917/daccfrance:version1
  6. kill docker container
    1
    docker container kill #container_id
  7. set compute zone by default
    1
    gcloud config set compute/zone europe-west1-b
  8. create a kubernetes cluster
    1
    gcloud container clusters create gk-cluster --num-nodes=1
  9. get authentication credentials for the cluster
    1
    gcloud container clusters get-credentials gk-cluster
  10. create kubernetes deployment
    1
    kubectl create deployment web-server --image=eu.gcr.io/kube-test-286917/daccfrance:version1
  11. create kubernetes service
    1
    kubectl expose deployment web-server --type LoadBalancer --port 80 --target-port 80
  12. get kubernetes pods
    1
    kubectl get pods
  13. get kubernetes service
    1
    kubectl get service web-server