In this article, we will show you how to deploy a web application by kubernetes on gcp.
- run nginx on daemon
1
docker run -d -p 8080:80 nginx:latest
- change index.html in nginx container
1
docker cp index.html 607de9f58775:/usr/share/nginx/html/
- create docker image from the new container version
1
docker commit 607de9f58775 daccfrance:version1
- create tag of docker image with project id
1
docker tag daccfrance:version1 eu.gcr.io/kube-test-286917/daccfrance:version1
- push docker image to gcp container registry
1
docker push eu.gcr.io/kube-test-286917/daccfrance:version1
- kill docker container
1
docker container kill #container_id
- set compute zone by default
1
gcloud config set compute/zone europe-west1-b
- create a kubernetes cluster
1
gcloud container clusters create gk-cluster --num-nodes=1
- get authentication credentials for the cluster
1
gcloud container clusters get-credentials gk-cluster
- create kubernetes deployment
1
kubectl create deployment web-server --image=eu.gcr.io/kube-test-286917/daccfrance:version1
- create kubernetes service
1
kubectl expose deployment web-server --type LoadBalancer --port 80 --target-port 80
- get kubernetes pods
1
kubectl get pods
- get kubernetes service
1
kubectl get service web-server