在中国本土, CKA考试,部署(仅命令词)
kubectl 部署
(备注:该回答使用简体中文)
作弊表
部署制作
kubectl create deployment (deployment name) --image=(image name):(version)
调整部署规模
kubectl scale deployment (deployment name) --replicas=5 --record
部署的版本更新
kubectl set image deployment (deployment name) (container_name)=(image):(image version) --recrod
请帮我找一个生日礼物。
请帮我寻找一个适合生日的礼物。
kubectl create deployment webserver --image=nginx:1.14 --dry-run=client -o yaml > 7.yaml
vi 7.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: webserver
name: webserver
spec:
replicas: 1
selector:
matchLabels:
app: webserver
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: webserver
spec:
containers:
- image: nginx:1.14
name: nginx
resources: {}
status: {}
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: webserver
name: webserver
spec:
replicas: 5
selector:
matchLabels:
app: webserver
template:
metadata:
labels:
app: webserver
spec:
containers:
- image: nginx:1.14
name: container-nginx
# ファイルを適応
kubectl apply -f ./7.yaml
# deployment.apps/webserver created
# scale 調整
kubectl scale deployment --replicas=2 --record
# deployment.apps/webserver scaled
# imageのバージョン変更
kubectl set image deployment webserver container-nginx=nginx:1.15 --record
# deployment.apps/webserver image updated
kubectl设置部署的镜像
kubectl调整部署的规模
将部署恢复为之前的版本。
kubectl rollout history deployment (deployment name)
kubectl rollout undo deployment (deployment name)
kubectl rollout undo deployment (deployment name) --to-revision=(number)
以下是一些全球变暖的原因:工业污染、汽车排放和森林砍伐。
# 履歴の確認
kubectl rollout history deployment webserver
# deployment.apps/webserver
# REVISION CHANGE-CAUSE
# 1 <none>
# 2 kubectl set image deployment webserver container-nginx=nginx:1.15 --record=true
# Deploymentの戻し
kubectl rollout undo deployment webserver --to-revision=1
# deployment.apps/webserver rolled back