Quickstart Google Kubernetes Engine
Set a default compute zone
- To set your default compute zone to us-central1-a, start a new session in Cloud Shell, and run the following command:
gcloud config set compute/zone us-central1-a
Create a GKE cluster
- To create a cluster, run the following command, replacing [CLUSTER-NAME] with the name you choose for the cluster (for example:my-cluster).
gcloud container clusters create [CLUSTER-NAME]
Get authentication credentials for the cluster
- To authenticate the cluster, run the following command, replacing [CLUSTER-NAME] with the name of your cluster:
gcloud container clusters get-credentials [CLUSTER-NAME]
Deploy an application to the cluster
- To create a new Deployment hello-server from the hello-app container image, run the following kubectl create command:
kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:1.0
- To create a Kubernetes Service, which is a Kubernetes resource that lets you expose your application to external traffic, run the following kubectl expose command:
kubectl expose deployment hello-server --type=LoadBalancer --port 8080
- To inspect the hello-server Service, run kubectl get:
kubectl get service
- To view the application from your web browser, open a new tab and enter the following address, replacing [EXTERNAL IP] with the EXTERNAL-IP for hello-server.
http://[EXTERNAL-IP]:8080
Deleting the cluster
- To delete the cluster, run the following command:
gcloud container clusters delete [CLUSTER-NAME]
- When prompted, type Y to confirm.
Comments are closed, but trackbacks and pingbacks are open.