当我使用Kubernetes restful api进行滚动升级时,升级后,会创建New ReplicaSet,New pods正在运行并获得所需的副本 . 但与此同时,Old ReplicaSet和Old pods仍在运行 . 部署的副本是3,当我检查 etcd 中的数据时,新副本集_1720859的副本是2,我在控制器管理器日志中找不到任何错误信息 .

另一个问题:为什么kubectl不使用restful api来进行滚动更新? kubectl做滚动升级in this way

我的代码:

cli := rdc.k8sClients
dp, err := cli.Extensions().Deployments(namespace).Get(deployment)
if err != nil {
    return
}

curImage := dp.Spec.Template.Spec.Containers[0].Image

ds := new(extensions.DeploymentStrategy)
ds.Type = extensions.RollingUpdateDeploymentStrategyType
ds.RollingUpdate = new(extensions.RollingUpdateDeployment)
ds.RollingUpdate.MaxUnavailable = intstr.FromInt(int(ROLLING_MAXUNAVAILABLE))
ds.RollingUpdate.MaxSurge = intstr.FromInt(int(ROLLING_MAXSURGE))

_, err = cli.Extensions().Deployments(namespace).Update(dp)