-
Notifications
You must be signed in to change notification settings - Fork 0
Kubernetes Installation on Google Container Engine
GunSik Choi edited this page Feb 29, 2016
·
1 revision
Installing in AWS
$ gcloud container clusters create hello-world --num-nodes 1 --machine-type g1-small
$ gcloud compute instances list
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
gke-hello-world-90332445-node-t1gw asia-east1-a g1-small 10.140.0.2 107.167.177.222 RUNNING
$ gcloud container clusters resize hello-world --size 2
$ gcloud compute instances list
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
gke-hello-world-90332445-node-kc06 asia-east1-a g1-small 10.140.0.3 104.155.214.94 RUNNING
gke-hello-world-90332445-node-t1gw asia-east1-a g1-small 10.140.0.2 107.167.177.222 RUNNING
$ kubectl get nodes
NAME LABELS STATUS AGE
gke-hello-world-90332445-node-kc06 kubernetes.io/hostname=gke-hello-world-90332445-node-kc06 Ready 15m
gke-hello-world-90332445-node-t1gw kubernetes.io/hostname=gke-hello-world-90332445-node-t1gw Ready 42m
$ kubectl run hello-node --image=gcr.io/${PROJECT_ID}/hello-node:v1 --port=8080
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-node-vxhm2 1/1 Running 0 20m
$ kubectl scale rc hello-node --replicas=3
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-node-4km5x 1/1 Running 0 19m
hello-node-vxhm2 1/1 Running 0 20m
hello-node-y46bo 1/1 Running 0 15m
$ kubectl expose rc hello-node --type="LoadBalancer"
$ kubectl get services
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
hello-node 10.3.249.45 104.155.206.98 8080/TCP run=hello-node 20m
kubernetes 10.3.240.1 <none> 443/TCP <none> 43m
$ kubectl get replicationcontrollers
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS AGE
hello-node hello-node gcr.io/cgshome/hello-node:v1 run=hello-node 3 20m
// nginx container 실행
$ kubectl run my-nginx --image=nginx --replicas=3 --port=80
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-node-4km5x 1/1 Running 0 20m
hello-node-vxhm2 1/1 Running 0 21m
hello-node-y46bo 1/1 Running 0 16m
my-nginx-mh0za 0/1 Pending 0 36s
my-nginx-n0a92 0/1 Pending 0 36s
my-nginx-wtkl1 0/1 Pending 0 36s
$ kubectl scale rc my-nginx --replicas=2
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-node-4km5x 1/1 Running 0 21m
hello-node-vxhm2 1/1 Running 0 22m
hello-node-y46bo 1/1 Running 0 17m
my-nginx-mh0za 1/1 Running 0 1m
my-nginx-wtkl1 1/1 Running 0 1m
$ kubectl expose rc my-nginx --type="LoadBalancer"
$ kubectl get services
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
hello-node 10.3.249.45 104.155.206.98 8080/TCP run=hello-node 24m
kubernetes 10.3.240.1 <none> 443/TCP <none> 47m
my-nginx 10.3.242.135 80/TCP run=my-nginx 49s
$ kubectl get services
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
hello-node 10.3.249.45 104.155.206.98 8080/TCP run=hello-node 25m
kubernetes 10.3.240.1 <none> 443/TCP <none> 48m
my-nginx 10.3.242.135 104.155.220.14 80/TCP run=my-nginx 1m
$ kubectl delete services my-nginx
$ kubectl delete rc my-nginx
$ kubectl delete services hello-node
$ kubectl delete rc hello-node
$ gcloud container clusters delete hello-worldReference