0
我有一個部署運行:Kubernetes - 更新部署配置文件使用命令行
# kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
kubernetes-dashboard 4 4 4 4 131d
我可以使用查看當前部署的配置:
# kubectl get deployments kubernetes-dashboard -o yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2"
creationTimestamp: 2017-02-03T16:04:04Z
generation: 5
labels:
app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: default
resourceVersion: "33197158"
selfLink: /apis/extensions/v1beta1/namespaces/default/deployments/kubernetes-dashboard
uid: 627d92b2-ea2a-11e6-a152-0050569b714e
spec:
replicas: 4
selector:
matchLabels:
app: kubernetes-dashboard
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
annotations:
scheduler.alpha.kubernetes.io/tolerations: |
[
{
"key": "dedicated",
"operator": "Equal",
"value": "master",
"effect": "NoSchedule"
}
]
creationTimestamp: null
labels:
app: kubernetes-dashboard
spec:
containers:
- args:
- --apiserver-host=http://172.29.219.6:8080
image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.0
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
httpGet:
path:/
port: 9090
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 30
name: kubernetes-dashboard
ports:
- containerPort: 9090
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
dnsPolicy: ClusterFirst
restartPolicy: Always
securityContext: {}
terminationGracePeriodSeconds: 30
status:
availableReplicas: 4
observedGeneration: 5
replicas: 4
updatedReplicas: 4
現在我想在飛行中編輯replicas: 4
。我知道一種方法是:
kubectl edit deployment kubernetes-dashboard
但上述方法打開一個文件,然後我需要手動更新。這對我來說成了一個問題,因爲我想用諸如腳本或Ansible之類的外部工具自動編輯這些部署。
我希望用這樣的:
kubectl set replicas deployment/kubernetes-dashboard replicas=2
但是好像不支持這樣的命令。 看起來像這樣的命令僅支持image
標記。
有什麼辦法可以更新副本或任何其他屬性,如果部署,但只是發出命令(不涉及任何編輯器)?