輕鬆建置一套Container Cluster
建立GKE Cluster
透過clusters create可已建立自己的GKE cluster...
$ gcloud container clusters create mygke
Creating cluster mygke...done.
Created [https://container.googleapis.com/v1/projects/easelifes-gcp-project/zones/asia-east1-a/clusters/mygke].
kubeconfig entry generated for mygke.
NAME ZONE MASTER_VERSION MASTER_IP MACHINE_TYPE NUM_NODES STATUS
mygke asia-east1-a 1.1.2 104.199.140.230 n1-standard-1 3 RUNNING
然後執行在環境中設定預設的cluster為所建立的名稱
$ gcloud config set container/cluster mygke
設定環境使用
$ gcloud container clusters get-credentials mygke \
--zone asia-east1-a \
--project your-project-id
Fetching cluster endpoint and auth data.
kubeconfig entry generated for mygke.
如果想要了解一些細部的資訊,可以開啟Debug mode來看看指令做了些什麼...
$ gcloud container clusters get-credentials mygke --verbosity debug
DEBUG: Running gcloud.container.clusters.get-credentials with Namespace(__calliope_internal_deepest_parser=ArgumentParser(prog='gcloud.container.clusters.get-credentials', usage=None, description='See https://cloud.google.com/container-engine/docs/kubectl for\nkubectl documentation.', version=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False), account=None, api_version=None, authority_selector=None, authorization_token_file=None, cmd_func=<bound method Command.Run of <googlecloudsdk.calliope.backend.Command object at 0x1054c1590>>, command_path=['gcloud', 'container', 'clusters', 'get-credentials'], configuration=None, document=None, format=None, h=None, help=None, http_timeout=None, log_http=None, name='mygke', project=None, quiet=None, trace_email=None, trace_log=False, trace_token=None, user_output_enabled=None, verbosity='debug', version=None, zone=None).
Fetching cluster endpoint and auth data.
DEBUG: Saved kubeconfig to /Users/peihsinsu/.kube/config
kubeconfig entry generated for mygke.
INFO: Display format "default".
Resize GKE group
Checking GKE instance group name
$ gcloud compute instance-groups list
NAME ZONE NETWORK MANAGED INSTANCES
gke-mygke-b0b86220-group asia-east1-a default Yes 3
Do resize
$ gcloud compute instance-groups managed resize gke-mygke-b0b86220-group --zone asia-east1-a --size 1
Updated [https://www.googleapis.com/compute/v1/projects/easelifes-gcp-project/zones/asia-east1-a/instanceGroupManagers/gke-mygke-b0b86220-group].
---
baseInstanceName: gke-mygke-b0b86220-node
creationTimestamp: '2015-11-23T18:47:48.119-08:00'
currentActions:
abandoning: 0
creating: 0
deleting: 2
none: 1
recreating: 0
refreshing: 0
restarting: 0
fingerprint: 42WmSpB8rSM=
id: '8414696411043361083'
instanceGroup: gke-mygke-b0b86220-group
instanceTemplate: gke-mygke-b0b86220-1-1-2
kind: compute#instanceGroupManager
name: gke-mygke-b0b86220-group
selfLink: https://www.googleapis.com/compute/v1/projects/easelifes-gcp-project/zones/asia-east1-a/instanceGroupManagers/gke-mygke-b0b86220-group
targetSize: 1
zone: asia-east1-a