126 words
1 minute
Google Kubernetes Engine quick start
Prerequisites
Steps
- Set a default compute zone
- Set the default compute region
Terminal window gcloud config set compute/region "REGION" - Set the default compute zone
Terminal window gcloud config set compute/zone "ZONE"NOTE
REGION
: available region. Ex:us-central1
.ZONE
: available zone. Ex:us-central1-a
is a zone in theus-central1
region.
- Set the default compute region
- Create a GKE cluster
- Create a cluster
Terminal window gcloud container clusters create --machine-type=machine-type --zone=ZONE cluster-nameNOTE
machine-type
: available machine type. Ex:e2-medium
.cluster-name
: cluster name.
- Create a cluster
- Get authentication credentials for the cluster
- Authenticate with the cluster
Terminal window gcloud container clusters get-credentials cluster-name
- Authenticate with the cluster
- Deploy an application to the cluster
- Create new deployment from a image
Terminal window kubectl create deployment deployment-name --image=image-name:image-tagNOTE
deployment-name
: deployment name.image-name
: image name. Ex:gcr.io/google-samples/hello-app
.image-tag
: image tag. Ex:1.0
.
- Expose application
Terminal window kubectl expose deployment deployment-name --type=LoadBalancer --port your-portNOTE
your-port
: exposed port. Ex:8080
- Inspect service
Terminal window kubectl get service
- Create new deployment from a image
- Delete the cluster
- Run following command
Terminal window gcloud container clusters delete cluster-name- Type
Y
and Enter to confirm
References
Google Kubernetes Engine quick start
https://slimaeus.github.io/posts/google-kubernetes-engine-quick-start/