我正在运行一个部署:
# 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
标记。
有没有办法可以更新副本或任何其他属性,如果部署但只是发出命令(不涉及任何编辑器)?