docker
push / pull image
1 | gcloud docker -- push [HOSTNAME]/[PROJECT-ID]/[IMAGE] |
如果出现错误https://gcr.io/v2/: net/http: request canceled while waiting for connection,docker设置proxy
Config
gcloud config set project [PROJECT_ID]
gcloud config set compute/zone [COMPUTE_ZONE], such as us-west1-a
Kubernetes
Pod
Bash Shell 进入Pod
1 | kubectl get pod pod-name |
update Pod Image
Deployment模式
1 | kubectl apply -f file |
注意,Image必须不同,比如原来是redis:v1,新的不能再是v1,可以设置为v2
Cluster
创建cluster
命令:gcloud container clusters create [CLUSTER_NAME]
获取授权
命令:gcloud container clusters get-credentials [CLUSTER_NAME]
例如,gcloud container clusters get-credentials cluster-name –zone us-central1-a –project project_id
gcloud container clusters get-credentials fintend-cloud –zone asia-southeast1-a –project fintend-cloud
删除 cluster
命令格式:gcloud container clusters delete [CLUSTER_NAME]
upgrading clusters
查看当前Node版本配置信息,以及可选的升级版本
1 | gcloud container get-server-config --zone us-central1-a |
输出1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27defaultClusterVersion: 1.7.12-gke.0
defaultImageType: COS
validImageTypes:
- COS
- UBUNTU
validMasterVersions:
- 1.8.7-gke.0
- 1.8.6-gke.0
- 1.8.5-gke.0
- 1.7.12-gke.0
- 1.7.11-gke.1
validNodeVersions:
- 1.8.7-gke.0
- 1.8.6-gke.0
- 1.8.5-gke.0
- 1.8.4-gke.1
- 1.8.3-gke.0
- 1.8.2-gke.0
- 1.8.1-gke.1
- 1.7.12-gke.0
- 1.7.12
- 1.7.11-gke.1
- 1.7.10-gke.0
- 1.7.8-gke.0
- 1.6.13-gke.1
- 1.6.11-gke.0
- 1.5.7
Node
查看Node数量
1 | kubectl get nodes |
输出结果1
2
3
4NAME STATUS ROLES AGE VERSION
gke-cluster-test-default-pool-07160edc-0b2w Ready <none> 3h v1.7.12-gke.0
gke-cluster-test-default-pool-07160edc-mtl7 Ready <none> 3h v1.7.12-gke.0
gke-cluster-test-default-pool-07160edc-rr9z Ready <none> 3h v1.7.12-gke.0
查看Node信息
1 | kubectl describe node node-name |
App
- deploy app
命令:kubectl run app-name –image gcr.io/PROJECT_ID/image-name –port server-port
例如,kubectl run hello-server –image gcr.io/google-samples/hello-app:1.0 –port 8080
- exposing app
命令:kubctl expose deployment app-name –type
–type:ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is ‘ClusterIP’.
例如,kubectl expose deployment hello-server –type “LoadBalancer”
- 删除LoadBalancer
例如,kubectl delete service hello-server
- inspect app
命令格式:kubectl get service app-name
- destroy app
命令格式:kubectl delete service app-name
Builder
local
container-builder-local
./container-builder-local_{linux,darwin}_{386,amd64}-v<latest_tag> –dryrun=false –config=path/to/cloudbuild.yaml path/to/code
remote
gcloud container builds submit –config cloudbuild.yaml .