Last active
January 14, 2016 08:45
-
-
Save itsprdp/0161aa129db50323630c to your computer and use it in GitHub Desktop.
GCE-container engine commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Init project settings | |
$ gcloud config set project PROJECT_ID | |
$ gcloud config set compute/zone us-east1-b | |
$ export PROJECT_ID=your-project-id-here | |
# Build docker image and push it to gcr.io | |
$ docker build -t gcr.io/${PROJECT_ID}/<project-name> . | |
Then push this image to the Google Container Registry: | |
$ gcloud docker push gcr.io/${PROJECT_ID}/<project-name> | |
# Create container clusters | |
$ gcloud container clusters create <project-name> \ | |
--num-nodes 1 \ | |
--machine-type g1-small | |
# List cloud instances | |
$ gcloud compute instances list | |
# Create pods | |
$ kubectl run <project-name> --image=gcr.io/${PROJECT_ID}/<project-name> --port=80 | |
# Create replication controllers | |
$ kubectl expose rc <project-name> --type="LoadBalancer" | |
# List the services (Use external IP to access the application) | |
$ kubectl get services <project-name> | |
# Scale the container instances | |
$ kubectl scale rc <project-name> --replicas=3 | |
## Cleanup ## | |
# First, delete the Service, which also deletes your external load balancer: | |
$ kubectl delete services <project-name> | |
# Delete the running pods with: | |
$ kubectl delete rc <project-name> | |
# Delete your cluster: | |
$ gcloud container clusters delete <project-name> | |
// Update the pods of frontend, keeping the replication controller name | |
$ kubectl rolling-update frontend --image=image:v2 | |
# Resizing the container cluster | |
$ gcloud container clusters describe CLUSTER_NAME --format yaml | grep -A 1 instanceGroupUrls | |
$ gcloud compute instance-groups managed resize gke-example-b937f2ba-group --zone us-central1-f --size 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment