<p>头盔升级失败,并带有spec.clusterIP:无效值:“”:该字段是不可变的</p>

创建于 2020-04-20  ·  64评论  ·  资料来源: helm/helm

颁发头盔升级时,它显示类似以下错误((“ my-service”从“ clusterIP:无”更改为“类型:LoadBalancer”,没有字段clusterIP)

Error: UPGRADE FAILED: Service "my-service" is invalid: spec.clusterIP: Invalid value: "": field is immutable 

但是,所有其他具有新版本的Pod仍将重新启动,但“ my-service”类型不会更改为新类型“ LoadBalancer”

我知道为什么升级失败是因为掌舵不支持在某些特定字段上进行更改。 但是为什么头盔仍通过重新启动来升级其他服务/吊舱。 如果升级过程中出现任何错误,头盔应该什么都不做? 我不愿将头盔视为将整个服务套件升级为全部升级或全部升级的软件包,但似乎我的期望可能是错误的。

如果我们最终遇到这种情况,那么我们应该如何摆脱这种情况呢? 像如何将“我的服务”升级为新类型?

而且,如果我使用--dry-run选项,则helm不会显示任何错误。

这是考虑到错误还是预期的错误,即升级会引发一些错误,但某些服务仍会升级。

helm version

Client: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}

kubectl version

Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:36:53Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14+", GitVersion:"v1.14.10-gke.27", GitCommit:"145f9e21a4515947d6fb10819e5a336aff1b6959", GitTreeState:"clean", BuildDate:"2020-02-21T18:01:40Z", GoVersion:"go1.12.12b4", Compiler:"gc", Platform:"linux/amd64"}

云提供商/平台(AKS,GKE,Minikube等):
GKE和Minkube

最有用的评论

仅供参考,OP提出的问题以及此处提出的有关--force是单独的,独立的问题。 让我们尝试在这里重点讨论OP的问题。

为了澄清,OP描述的问题是在https://github.com/helm/helm/issues/7956#issuecomment -620749552中确定的@ n1koo潜在回归。 那似乎是一个合法的错误。

从Kubernetes的角度来看,其他评论提到删除为他们工作的--force是故意的和预期的行为。 使用--force ,您正在请求Helm对Kubernetes发出PUT请求。 实际上,您是在要求Kubernetes将目标清单(从helm upgrade绘制到图表中的模板)作为真相的来源,并用呈现的清单覆盖集群中的资源。 这与kubectl apply --overwrite

在大多数情况下,您的模板没有指定群集IP,这意味着helm upgrade --force要求删除(或更改)服务的群集IP。 从Kubernetes的角度来看,这是非法操作。

这也记录在#7082中。

这也是为什么删除--force起作用的原因:Helm进行PATCH操作,与实时状态不同,将群集IP合并到修补的清单中,并在升级时保留群集IP。

如果要像在Helm 2中一样强行删除并重新创建对象,请查看#7431。

希望这能使事情澄清。

展望未来,让我们尝试在此处重点关注OP的问题。

所有64条评论

没有提供足够的信息来进行复制。 请告诉我们如何创建可复制的图表,以及您使用了哪些Helm命令。

嗨,这是复制步骤
具有两个服务yaml文件,如下所示。

nginx.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

普罗米修斯

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: prometheus
spec:
  template:
    metadata:
      labels:
        app: prometheus
    spec:
      containers:
      - image: prom/prometheus
        name: prometheus
        ports:
        - containerPort: 9090
        imagePullPolicy: Always
      hostname: prometheus
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: prometheus
spec:
  selector:
    app: prometheus
  clusterIP: None
  ports:
  - name: headless
    port: 9090
    targetPort: 0

然后在helm1 / templates /中放置两个文件,然后安装。 它显示了普罗米修斯服务使用clusterIP且nginx版本为1.14.2

# helm upgrade --install test helm1
Release "test" does not exist. Installing it now.
NAME: test
LAST DEPLOYED: Tue Apr 21 20:42:55 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

# kubectl get svc
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP    35d
prometheus   ClusterIP   None         <none>        9090/TCP   7s

# kubectl describe deployment nginx |grep Image
    Image:        nginx:1.14.2

现在将nginx.yaml的部分更新为新版本1.16

        image: nginx:1.16

并将prometheus.yaml更改为LoadBalancer。

spec:
  selector:
    app: prometheus
  ports:
  - name: "9090"
    port: 9090
    protocol: TCP
    targetPort: 9090
  type: LoadBalancer

现在将它们设置为helm2并进行升级。 然后,您可以看到升级引发了一些错误,但是通过升级到新版本,nginx服务得以通过,但是由于仍在使用群集IP,因此未升级prometheus。

# helm upgrade --install test helm2
Error: UPGRADE FAILED: cannot patch "prometheus" with kind Service: Service "prometheus" is invalid: spec.clusterIP: Invalid value: "": field is immutable

# kubectl get svc
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP    35d
prometheus   ClusterIP   None         <none>        9090/TCP   5m34s

# kubectl describe deployment nginx |grep Image
    Image:        nginx:1.16

掌舵清单显示

# helm list
NAME    NAMESPACE   REVISION    UPDATED                                 STATUS  CHART                                       APP VERSION
test    default     2           2020-04-21 20:48:20.133644429 -0700 PDT failed  

掌舵历史

# helm history test
REVISION    UPDATED                     STATUS      CHART       APP VERSION DESCRIPTION                                                                                                                                               
1           Tue Apr 21 20:42:55 2020    deployed    helm-helm   1.0.0.6     Install complete                                                                                                                                          
2           Tue Apr 21 20:48:20 2020    failed      helm-helm   1.0.0.6     Upgrade "test" failed: cannot patch "prometheus" with kind Service: Service "prometheus" is invalid: spec.clusterIP: Invalid value: "": field is immutable

我们在v3.2.0中具有相同的行为,降级为v3.1.3是我们的临时解决方案

我的Helm 2-> 3迁移中有很多这样的功能。 当第一次尝试升级转换后的发行版时,我得到了很多。 到目前为止,这是针对Nginx Ingress,Prometheus Operator,Graylog和Jaeger图表的。 他们大多数人对删除服务并让Helm重新创建服务感到满意,但是对于Nginx Ingress来说,这不是一个选择...

刚刚找到了这个https://github.com/helm/helm/issues/6378#issuecomment -557746499,这说明了我的问题。

以#6378的副本形式关闭。 @cablespaghetti找到了对此行为的更深层解释,对此进行了详细描述。

让我们知道这是否不适合您。

@GaramNick为什么会降级为您解决此问题? 您能否详细说明降级所解决的“问题”?

@bacongobbler在这里时。 有什么方法可以解决此问题,而无需删除发行版并重新部署? 在helm 2或3下,我似乎无法做到这一点。我想破解现有的发布数据,因此Helm认为clusterIP始终被省略,因此不需要补丁。

您尝试过kubectl edit吗?

我们也遇到了同样的问题,并降级为3.1.3也为我们解决了该问题。 我的猜测是,它与https://github.com/helm/helm/pull/7649/commits/d829343c1514db17bee7a90624d06cdfbffde963中的新逻辑有关,考虑到这是Create而不是更新,因此试图将其设置为空IP,不要重复使用填充的IP

有趣的发现。 感谢您的调查。

@jlegrone是否有机会您可能有时间对此进行调查?

@bacongobbler我们的CI / CD管道使用Helm更新我们的应用程序,其中包括类型为ClusterIP的服务。 命令:

helm upgrade --install --force \
        --wait \
        --set image.repository="$CI_REGISTRY_IMAGE" \
        --set image.tag="$CI_COMMIT_REF_NAME-$CI_COMMIT_SHA" \
        --set image.pullPolicy=IfNotPresent \
        --namespace="$KUBE_NAMESPACE" \
        "$APP_NAME" \
        ./path/to/charts/

在v3.2.0上,此命令失败,并显示Service "service-name" is invalid: spec.clusterIP: Invalid value: "": field is immutable

在v3.1.3上可以正常工作。

如果您想了解更多信息,请告诉我。

同样在这里。 我们有以下service.yaml与helm2正常工作了许多个月。
迁移后,Helm 3.2 helm upgrade命令失败,出现上述保存错误。 降级到3.1.3可以解决该问题。

apiVersion: v1
kind: Service
metadata:
  name: {{ .Values.global.name }}
  namespace: {{ index .Values.global.namespace .Values.global.env }}
  labels:
     microservice: {{ .Values.global.name }}
spec:
   type: ClusterIP
   ports:
   - port: 8080
   selector:
      microservice: {{ .Values.global.name }}

我们也有同样的问题,降级到3.1.3也为我们解决了。 我的猜测是,它与d829343中的新逻辑有关,考虑到这是创建而非更新,因此尝试设置空IP而不重用填充的IP

@ n1koo您能解释一下为什么您认为这是导致此问题的代码吗? 因为这是安装而非升级代码,所以3.1中create并且可以正常工作。

我正在审核@adamreese的问题,我们_think_这是@ n1koo确定的补丁。 Create方法将绕过服务上的常规三向差异,这将导致服务的clusterIP设置为“”,而不是Kubernetes填充的值。 结果,清单文件发送到API服务器_appears_以重置群集IP,这在服务上是非法的(并且绝对不是用户的意图)。

我们仍在调查中,如果我们了解更多,我会进行更新。

所以https://github.com/helm/helm/issues/6378#issuecomment -557746499是正确的。 在继续解决此问题之前,请先阅读该内容。 如果设置了clusterIP: "" ,Kubernetes将分配一个IP。 在下一次Helm升级时,如果再次clusterIP:"" ,它将给出上面的错误,因为在Kubernetes_看来您正在尝试重置IP。 (是的,Kubernetes修改了服务的spec:部分!)

Create方法绕过三向差异时,它将设置clusterIP: ""而不是将其设置为Kubernetes分配的IP地址。

复制:

$ helm create issue7956
$ # edit issue7956/templates/service.yaml and add `clusterIP: ""` under `spec:`
$ helm upgrade --install issue7956 issue7956
...
$ helm upgrade issue7956 issue7956
Error: UPGRADE FAILED: cannot patch "issue-issue7956" with kind Service: Service "issue-issue7956" is invalid: spec.clusterIP: Invalid value: "": field is immutable

第二次运行升级,它将失败。

我无法在master上复制@IdanAdar的情况。

@GaramNick没有足够的关于您正在使用的服务的信息,以便我们重现您的错误。

我的情况:
version.BuildInfo{Version:"v3.2.0", GitCommit:"e11b7ce3b12db2941e90399e874513fbd24bcb71", GitTreeState:"clean", GoVersion:"go1.13.10"}
还测试了瓦特/
version.BuildInfo{Version:"v3.2.1", GitCommit:"fe51cd1e31e6a202cba7dead9552a6d418ded79a", GitTreeState:"clean", GoVersion:"go1.13.10"}

给定以下服务模板:

apiVersion: v1
kind: Service
metadata:
  name: {{ include "app.fullname" . }}
  labels:
    {{- include "app.labels" . | nindent 4 }}
  annotations:
    getambassador.io/config: |
      ---
      apiVersion: ambassador/v1
      kind: Mapping
      name: {{ include "app.fullname" . }}_mapping
      prefix: /{{ include "app.fullname" . }}
      host: "^{{ include "app.fullname" . }}.*"
      host_regex: true
      service: {{ include "app.fullname" . }}.{{ .Release.Namespace }}
      rewrite: ""
      timeout_ms: 60000
      bypass_auth: true
      cors:
        origins: "*"
        methods: POST, GET, OPTIONS
        headers:
        - Content-Type
        - Authorization
        - x-client-id
        - x-client-secret
        - x-client-trace-id
        - x-flow-proto
      ---
      apiVersion: ambassador/v1
      kind: Mapping
      name: {{ include "app.fullname" . }}_swagger_mapping
      ambassador_id: corp
      prefix: /swagger
      host: "^{{ include "app.fullname" . }}.corp.*"
      host_regex: true
      service: {{ include "app.fullname" . }}.{{ .Release.Namespace }}
      rewrite: ""
      bypass_auth: true
      cors:
        origins: "*"
        methods: POST, GET, OPTIONS
        headers:
        - Content-Type
        - x-client-id
        - x-client-secret
        - Authorization
        - x-flow-proto
  namespace: {{ .Release.Namespace }}
spec:
  type: {{ .Values.service.type }}
  selector:
    {{- include "app.selectorLabels" . | nindent 4 }}
  ports:
  - port: {{ .Values.service.port }}
    name: http-rest-hub
    targetPort: http-rest
  - port: {{ .Values.service.healthPort }}
    name: http-health
    targetPort : http-health

结果在upgrade --install

apiVersion: v1
kind: Service
metadata:
  annotations:
    getambassador.io/config: |
      ---
      apiVersion: ambassador/v1
      kind: Mapping
      name: hub-alt-bor_mapping
      prefix: /hub-alt-bor
      host: "^hub-alt-bor.*"
      host_regex: true
      service: hub-alt-bor.brett
      rewrite: ""
      timeout_ms: 60000
      bypass_auth: true
      cors:
        origins: "*"
        methods: POST, GET, OPTIONS
        headers:
        - Content-Type
        - Authorization
        - x-client-id
        - x-client-secret
        - x-client-trace-id
        - x-flow-proto
      ---
      apiVersion: ambassador/v1
      kind: Mapping
      name: hub-alt-bor_swagger_mapping
      ambassador_id: corp
      prefix: /swagger
      host: "^hub-alt-bor.corp.*"
      host_regex: true
      service: hub-alt-bor.brett
      rewrite: ""
      bypass_auth: true
      cors:
        origins: "*"
        methods: POST, GET, OPTIONS
        headers:
        - Content-Type
        - x-client-id
        - x-client-secret
        - Authorization
        - x-flow-proto
    meta.helm.sh/release-name: alt-bor
    meta.helm.sh/release-namespace: brett
  creationTimestamp: ...
  labels:
    app: hub
    app.kubernetes.io/instance: alt-bor
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: hub
    app.kubernetes.io/version: v1.6.0-rc.26
    deploy.xevo.com/stackname: bor-v0.1-test
    helm.sh/chart: hub-0.0.4
    owner: gateway
    ownerSlack: TODOunknown
  name: hub-alt-bor
  namespace: brett
  resourceVersion: ...
  selfLink: ...
  uid: ...
spec:
  clusterIP: 172.20.147.13
  ports:
  - name: http-rest-hub
    port: 80
    protocol: TCP
    targetPort: http-rest
  - name: http-health
    port: 90
    protocol: TCP
    targetPort: http-health
  selector:
    app.kubernetes.io/instance: alt-bor
    app.kubernetes.io/name: hub
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}

如果我然后再次上传与版本0.0.5和upgrade --install完全相同的图表,则会得到以下信息:
Error: UPGRADE FAILED: failed to replace object: Service "hub-alt-bor" is invalid: spec.clusterIP: Invalid value: "": field is immutable

唯一的区别是helm.sh/chart标签的值现在具有hub-0.0.5

这是一个巨大的障碍。

@GaramNick没有足够的关于您正在使用的服务的信息,以便我们重现您的错误。

@technosophos您需要什么? 乐意提供更多细节!

更新! 仅当使用helm upgrade --install w / --force时更新失败。 现在减少了阻塞。

哦! 这太有趣了。 这应该使错误更易于查找。

您好@technosophos @bacongobbler我们有2个相同的问题:

version.BuildInfo{Version:"v3.2.1", GitCommit:"fe51cd1e31e6a202cba7dead9552a6d418ded79a", GitTreeState:"clean", GoVersion:"go1.13.10"}

  1. 问题
    我们有Service模板,没有clusterIP但是kubernetes会自动分配clusterIP
apiVersion: v1
kind: Service
metadata:
  name: {{ .Release.Name }}
  labels:
    app: {{ .Values.image.name }}
    release: {{ .Release.Name }}
spec:
  type: ClusterIP
  ports:
    - port: {{ .Values.service.port }}
      targetPort: {{ .Values.service.port }}
      protocol: TCP
      name: http
  selector:
    app: {{ .Values.image.name }}
    release: {{ .Release.Name }}

在使用helm 2to3 convert迁移到头盔3之后,尝试升级相同的发行版helm3 upgrade --install --force

failed to replace object: Service "dummy-stage" is invalid: spec.clusterIP: Invalid value: "": field is immutable

如果我没有--force -> helm3 upgrade --install正常工作而没有错误。

  1. 问题
    如果我想在部署中更改spec.selector.matchLabels ,而没有--force则是不可变字段,则会收到错误消息:
cannot patch "dummy-stage" with kind Deployment: Deployment.apps "dummy-stage" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/name":"web-nerf-dummy-app"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable

如果我将对--force做同样的操作,则会收到错误消息:

failed to replace object: Deployment.apps "dummy-stage" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/name":"web-nerf-dummy-app"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable

是否有可能对--forcehelm 2相同的行为,因为我们可以毫无错误地升级不可变字段?

apiVersion: v1
kind: Service
metadata:
  name: zipkin-proxy
  namespace: monitoring
spec:
  ports:
  - port: 9411
    targetPort: 9411
  selector:
    app: zipkin-proxy
  type: ClusterIP

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: zipkin-proxy
  namespace: monitoring
spec:
  replicas: {{ .Values.zipkinProxy.replicaCount }}
  template:
    metadata:
      labels:
        app: zipkin-proxy
      annotations:
        prometheus.io/scrape: 'true'
    spec:
      containers:
      - image: {{ .Values.image.repository }}/zipkin-proxy
        name: zipkin-proxy
        env:
        - name: STORAGE_TYPE
          value: stackdriver

helm upgrade -i --debug --force --namespace monitoring zipkin-proxy --values ./values.yaml.tmp .

我尝试删除了force选项。 我尝试使用v3.1.3,v3.2.0和v3.2.1仍然是同一问题。

堆栈跟踪

history.go:52: [debug] getting history for release zipkin-proxy
upgrade.go:84: [debug] preparing upgrade for zipkin-proxy
upgrade.go:92: [debug] performing update for zipkin-proxy
upgrade.go:234: [debug] creating upgraded release for zipkin-proxy
client.go:163: [debug] checking 2 resources for changes
client.go:195: [debug] error updating the resource "zipkin-proxy":
         cannot patch "zipkin-proxy" with kind Service: Service "zipkin-proxy" is invalid: spec.clusterIP: Invalid value: "": field is immutable
client.go:403: [debug] Looks like there are no changes for Deployment "zipkin-proxy"
upgrade.go:293: [debug] warning: Upgrade "zipkin-proxy" failed: cannot patch "zipkin-proxy" with kind Service: Service "zipkin-proxy" is invalid: spec.clusterIP: Invalid value: "": field is immutable
Error: UPGRADE FAILED: cannot patch "zipkin-proxy" with kind Service: Service "zipkin-proxy" is invalid: spec.clusterIP: Invalid value: "": field is immutable
helm.go:75: [debug] cannot patch "zipkin-proxy" with kind Service: Service "zipkin-proxy" is invalid: spec.clusterIP: Invalid value: "": field is immutable
helm.sh/helm/v3/pkg/kube.(*Client).Update
        /home/circleci/helm.sh/helm/pkg/kube/client.go:208
helm.sh/helm/v3/pkg/action.(*Upgrade).performUpgrade
        /home/circleci/helm.sh/helm/pkg/action/upgrade.go:248
helm.sh/helm/v3/pkg/action.(*Upgrade).Run
        /home/circleci/helm.sh/helm/pkg/action/upgrade.go:93
main.newUpgradeCmd.func1
        /home/circleci/helm.sh/helm/cmd/helm/upgrade.go:137
github.com/spf13/cobra.(*Command).execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:826
github.com/spf13/cobra.(*Command).ExecuteC
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:914
github.com/spf13/cobra.(*Command).Execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:864
main.main
        /home/circleci/helm.sh/helm/cmd/helm/helm.go:74
runtime.main
        /usr/local/go/src/runtime/proc.go:203
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1357
UPGRADE FAILED
main.newUpgradeCmd.func1
        /home/circleci/helm.sh/helm/cmd/helm/upgrade.go:139
github.com/spf13/cobra.(*Command).execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:826
github.com/spf13/cobra.(*Command).ExecuteC
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:914
github.com/spf13/cobra.(*Command).Execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:864
main.main
        /home/circleci/helm.sh/helm/cmd/helm/helm.go:74
runtime.main
        /usr/local/go/src/runtime/proc.go:203
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1357

当舵图版本更改并具有现有部署时,我遇到了这个问题。

使用Helm v3.2.0

我可以确认降级到3.1.2是可行的。

@ gor181我们如何重现它? 是什么在3.2上中断了,但在3.1上起作用了? 图表(或至少是svc模板)和命令是我们需要能够找出更改的内容。

@azarudeena @ alexandrsemak-对你们俩来说, --force标志是导致此问题的原因。 如果删除--force ,升级是否起作用?

@technosophos确实尝试不使用武力是行不通的。 计划尝试3.1.2

@azarudeena您能否提供一组说明来重现您的问题? 您显示了服务和部署模板的一些输出,但随后还引用了values.yaml.tmp ,而我们既不知道它的输出,也不知道Chart.yaml。

您能否提供示例图表,以便我们用来重现您的问题?

@bacongobbler我正在共享结构。

图表

apiVersion: v1
description: Deploys Stackdriver Trace Zipkin Proxy
name: zipkin-proxy
version: 1.0.0

我已经将模板yaml放在上面,

我的值yaml.tmp如下

zipkinProxy:
  replicaCount: 1

image:
  repository: openzipkin/zipkin

我将其打包为头盔包--version使用相同的升级。 让我知道这个是否奏效? 我尝试使用3.1.2时将在此处更新

编辑

尝试将其降级为3.1.2和3.1.1。 仍然无法对此进行修补。

我遇到了同样的问题,但是要通过Terraform Helm提供程序升级Helm图表。
在将force_update = true更改force_update = false ,错误消失了。

当舵图版本更改并具有现有部署时,我遇到了这个问题。

使用Helm v3.2.0

禁用--force标志使其起作用。

@technosophos --force解决了当您迁移到头盔3时ClusterIP的问题,因为头盔2请勿尝试在头盔3升级时升级ClusterIP。
头盔3无法解决以matchLabels提交的不可变问题

Kubernetes修改服务的spec:部分

从根本上讲,这是否应该被视为Kubernetes的设计缺陷? https://kubernetes.io/docs/concepts/services-networking/service/#choosing-您自己的IP地址未提及此行为。 我本来希望将分配的值放在status部分中。

(存在类似的行为为.spec.nodeNamePod ,但是这不大可能影响到头盔的用户。)

v3.2.3:使用--force失败,不使用--force。 图表模板中没有ClusterIP: 。 我猜https://github.com/helm/helm/pull/8000/files应该可以解决。

upgrade.go:121: [debug] preparing upgrade for eos-eve-srv-d1
upgrade.go:129: [debug] performing update for eos-eve-srv-d1
upgrade.go:308: [debug] creating upgraded release for eos-eve-srv-d1
client.go:173: [debug] checking 6 resources for changes
client.go:432: [debug] Replaced "eos-eve-srv-d1-fsnode" with kind ServiceAccount for kind ServiceAccount
client.go:432: [debug] Replaced "eos-eve-srv-d1-fsnode-imagepullsecret" with kind Secret for kind Secret
client.go:432: [debug] Replaced "eos-eve-srv-d1-fsnode-config" with kind ConfigMap for kind ConfigMap
client.go:205: [debug] error updating the resource "eos-eve-srv-d1-fsnode":
         failed to replace object: Service "eos-eve-srv-d1-fsnode" is invalid: spec.clusterIP: Invalid value: "": field is immutable
client.go:432: [debug] Replaced "eos-eve-srv-d1-fsnode" with kind Deployment for kind Deployment
client.go:432: [debug] Replaced "eos-eve-srv-d1-fsnode" with kind Ingress for kind Ingress
upgrade.go:367: [debug] warning: Upgrade "eos-eve-srv-d1" failed: failed to replace object: Service "eos-eve-srv-d1-fsnode" is invalid: spec.clusterIP: Invalid value: "": field is immutable
Error: UPGRADE FAILED: failed to replace object: Service "eos-eve-srv-d1-fsnode" is invalid: spec.clusterIP: Invalid value: "": field is immutable
helm.go:84: [debug] failed to replace object: Service "eos-eve-srv-d1-fsnode" is invalid: spec.clusterIP: Invalid value: "": field is immutable
helm.sh/helm/v3/pkg/kube.(*Client).Update
        /private/tmp/helm-20200608-50972-gq0j1j/src/helm.sh/helm/pkg/kube/client.go:218
helm.sh/helm/v3/pkg/action.(*Upgrade).performUpgrade
        /private/tmp/helm-20200608-50972-gq0j1j/src/helm.sh/helm/pkg/action/upgrade.go:322
helm.sh/helm/v3/pkg/action.(*Upgrade).Run
        /private/tmp/helm-20200608-50972-gq0j1j/src/helm.sh/helm/pkg/action/upgrade.go:130
main.newUpgradeCmd.func1
        /private/tmp/helm-20200608-50972-gq0j1j/src/helm.sh/helm/cmd/helm/upgrade.go:144
github.com/spf13/cobra.(*Command).execute
        /private/tmp/helm-20200608-50972-gq0j1j/pkg/mod/github.com/spf13/[email protected]/command.go:842
github.com/spf13/cobra.(*Command).ExecuteC
        /private/tmp/helm-20200608-50972-gq0j1j/pkg/mod/github.com/spf13/[email protected]/command.go:950
github.com/spf13/cobra.(*Command).Execute
        /private/tmp/helm-20200608-50972-gq0j1j/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main
        /private/tmp/helm-20200608-50972-gq0j1j/src/helm.sh/helm/cmd/helm/helm.go:83
runtime.main
        /usr/local/Cellar/[email protected]/1.13.12/libexec/src/runtime/proc.go:203
runtime.goexit
        /usr/local/Cellar/[email protected]/1.13.12/libexec/src/runtime/asm_amd64.s:1357
UPGRADE FAILED
main.newUpgradeCmd.func1
        /private/tmp/helm-20200608-50972-gq0j1j/src/helm.sh/helm/cmd/helm/upgrade.go:146
github.com/spf13/cobra.(*Command).execute
        /private/tmp/helm-20200608-50972-gq0j1j/pkg/mod/github.com/spf13/[email protected]/command.go:842
github.com/spf13/cobra.(*Command).ExecuteC
        /private/tmp/helm-20200608-50972-gq0j1j/pkg/mod/github.com/spf13/[email protected]/command.go:950
github.com/spf13/cobra.(*Command).Execute
        /private/tmp/helm-20200608-50972-gq0j1j/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main
        /private/tmp/helm-20200608-50972-gq0j1j/src/helm.sh/helm/cmd/helm/helm.go:83
runtime.main
        /usr/local/Cellar/[email protected]/1.13.12/libexec/src/runtime/proc.go:203
runtime.goexit
        /usr/local/Cellar/[email protected]/1.13.12/libexec/src/runtime/asm_amd64.s:1357

我在3.2.3上观察到此问题,但在3.2.0上观察不到。 禁用武力也是一种可用的解决方法。

仅供参考,OP提出的问题以及此处提出的有关--force是单独的,独立的问题。 让我们尝试在这里重点讨论OP的问题。

为了澄清,OP描述的问题是在https://github.com/helm/helm/issues/7956#issuecomment -620749552中确定的@ n1koo潜在回归。 那似乎是一个合法的错误。

从Kubernetes的角度来看,其他评论提到删除为他们工作的--force是故意的和预期的行为。 使用--force ,您正在请求Helm对Kubernetes发出PUT请求。 实际上,您是在要求Kubernetes将目标清单(从helm upgrade绘制到图表中的模板)作为真相的来源,并用呈现的清单覆盖集群中的资源。 这与kubectl apply --overwrite

在大多数情况下,您的模板没有指定群集IP,这意味着helm upgrade --force要求删除(或更改)服务的群集IP。 从Kubernetes的角度来看,这是非法操作。

这也记录在#7082中。

这也是为什么删除--force起作用的原因:Helm进行PATCH操作,与实时状态不同,将群集IP合并到修补的清单中,并在升级时保留群集IP。

如果要像在Helm 2中一样强行删除并重新创建对象,请查看#7431。

希望这能使事情澄清。

展望未来,让我们尝试在此处重点关注OP的问题。

有任何已知的解决方法吗? 尝试将https://github.com/helm/charts/tree/master/stable/rabbitmq-ha从1.34.1升级到1.46.4时遇到相同的问题。 显然--force或将头盔降级到3.1.3没有帮助,删除有问题的服务, helm upgrade确实有帮助

@EvgeniGordeev这将是对我有效的粗略解决方案,停机时间短。 卸载图表/重新安装。

我们也通过nginxinc入口图实现了这一点。 我们通常使用--force

由于此问题仍未解决,是否有计划解决此问题的计划,或者该解决方案是否被视为按设计工作(很难区别于此问题和其他行为相同的问题)? 我读过一个解释,认为这是图表的问题,不应使用本身和clusterIP: "" ,而是应完全省略该值。

这是我们应该跟图表开发者一起追赶的东西吗?

@cdunford-建议修复它以停止使用--force如建议的https://github.com/helm/helm/issues/7956#issuecomment -643432099。

该PR还可解决以下问题:#7431(在该评论中建议)...

我们连续N次遇到此问题,我们也在管道中使用--force标志。

最初的问题与helm2一起出现,那么也可以在helm2中解决吗? @bacongobbler

@bacongobbler为什么您说提供“力”与如果剥离它或降级有帮助的问题有所不同?

我的意思是,我刚刚遇到了Helm 3.3.4, https://artifacthub.io/packages/helm/bitnami/nginx图表的问题,并且没有更改任何值。 在三种不同的云上进行了测试:GCP / GKE,Azure / AKS和AWS / EKS,在这三种云上均失败。

在我将Helm降级为3.1.3并在3.3.4上也没有“ --force”标记的情况下立即工作。

我以为我在较早的评论中已经很清楚地指出,有两种单独的,独特的情况,用户可以看到此错误。 一种是OP的情况。 另一个是使用--force。 我们在这里关注OP的问题。

出于对与OP遇到相同问题的人们的尊重,请停止劫持此线程以谈论--force。 我们正在尝试讨论如何解决OP的问题。 如果您要讨论与OP描述的问题无关的主题,请打开新票证或查看我之前提出的建议。

@tibetsam关于为头盔2修复此问题:不。 我们不再为Helm 2提供错误修复。有关更多信息,请参见https://helm.sh/blog/helm-v2-deprecation-timeline/

我认为我成功地通过jupytherhub舵图重现了OP的问题。
希望按照下面的说明,您将能够重现该问题:


重要的
Jupyterhub舵图在其服务规格中包含spec.clusterIP字段,例如,您可以在此处查看(例如): https :


我正在掌舵并善意地重现该问题:

➜ helm version
version.BuildInfo{Version:"v3.4.0", GitCommit:"7090a89efc8a18f3d8178bf47d2462450349a004", GitTreeState:"clean", GoVersion:"go1.14.10"}

➜ kind version
kind v0.9.0 go1.15.2 linux/amd64

➜ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.1", GitCommit:"206bcadf021e76c27513500ca24182692aabd17e", GitTreeState:"clean", BuildDate:"2020-09-14T07:30:52Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}

如何繁殖

  1. 创建新的集群
kind create cluster
  1. 创建一个名为config.yaml的文件,其中包含以下内容(随机生成的十六进制):
proxy:
  secretToken: "3a4bbf7405dfe1096ea2eb9736c0df299299f94651fe0605cfb1c6c5700a6786"

仅供参考,我正在按照Helm文件安装说明进行操作(链接

  1. 添加头盔库
helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/
helm repo update
  1. 安装图表(带有--force选项)
RELEASE=jhub
NAMESPACE=jhub

helm upgrade --cleanup-on-fail --force \
  --install $RELEASE jupyterhub/jupyterhub \
  --namespace $NAMESPACE \
  --create-namespace \
  --version=0.9.0 \
  --values config.yaml
  1. 重复步骤5

错误:

Error: UPGRADE FAILED: failed to replace object: PersistentVolumeClaim "hub-db-dir" is invalid: spec: Forbidden: spec is immutable after creation except resources.requests for bound claims
  core.PersistentVolumeClaimSpec{
        AccessModes:      []core.PersistentVolumeAccessMode{"ReadWriteOnce"},
        Selector:         nil,
        Resources:        core.ResourceRequirements{Requests: core.ResourceList{s"storage": {i: resource.int64Amount{value: 1073741824}, s: "1Gi", Format: "BinarySI"}}},
-       VolumeName:       "",
+       VolumeName:       "pvc-c614de5c-4749-4755-bd3a-6e603605c44e",
-       StorageClassName: nil,
+       StorageClassName: &"standard",
        VolumeMode:       &"Filesystem",
        DataSource:       nil,
  }
 && failed to replace object: Service "hub" is invalid: spec.clusterIP: Invalid value: "": field is immutable && failed to replace object: Service "proxy-api" is invalid: spec.clusterIP: Invalid value: "": field is immutable && failed to replace object: Service "proxy-public" is invalid: spec.clusterIP: Invalid value: "": field is immutable

我掌舵3.3.4,这仍然是一个问题

Helm 2.14.1问题(带/不带) --force

解决方法:切换到type.spec: NodePort修复了我的helmchart升级。

在v3.4.1上,我们使用--force标志存在相同的问题。

@bacongobbler我知道您一直在保持警觉,以防止被劫持OP的问题(与#6378分开)。 我认为这可能有助于那些发帖者查看其错误消息,以了解此线程是否适合他们:

是您的错误消息,_did USE_ --force在你的命令“错误:升级失败未能_replace_ ......”和? 转到#6378

是您的错误消息“错误:升级失败:无法_patch_ ...”,并且您_在命令中未使用_ --force吗? 请在本期中发布您如何复制它。

@zpittmansf

helm3 upgrade concourse concourse/concourse -f temp.yaml  --force
Error: UPGRADE FAILED: failed to replace object: Service "concourse-web" is invalid: spec.clusterIP: Invalid value: "None": field is immutable && failed to replace object: Service "concourse-web-prometheus" is invalid: spec.clusterIP: Invalid value: "": field is immutable && failed to replace object: Service "concourse-web-worker-gateway" is invalid: spec.clusterIP: Invalid value: "": field is immutable

helm3 upgrade concourse concourse/concourse -f temp.yaml
Error: UPGRADE FAILED: cannot patch "concourse-web" with kind Service: Service "concourse-web" is invalid: spec.clusterIP: Invalid value: "None": field is immutable

我在头盔3.4.2上遇到了同样的问题。 我运行了一个舵图,该舵图创建了一个部署,serviceaccount和service。 我在部署图表上的现有标签集中添加了一个标签,但现在它拒绝升级:

helm upgrade test-whale charts/app-template/ --install --values values.yaml --namespace whale --force
Error: UPGRADE FAILED: failed to replace object: Service "test-whale" is invalid: spec.clusterIP: Invalid value: "": field is immutable && failed to replace object: Deployment.apps "test-whale-canary" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"test-whale", "app-id":"302040", "environment":"test", "version":"latest"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable && failed to replace object: Deployment.apps "test-whale" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"test-whale", "app-id":"302040", "environment":"test", "version":"latest"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable

基本上,似乎您无法在最初的头盔部署之后添加标签。

这听起来很可怕,但是Helm能否实施一个将受到特殊对待的“不可变字段”列表?

在这种情况下,“不可变字段”将是Service对象的spec.clusterIP -Helm会认为它是不可变的,并生成这样的API请求:a)不尝试替换它,b)不尝试删除它,c)不要尝试对其进行更新。

实际上,Helm会查找不可变字段的当前值,并将该值包含在API请求的有效负载中。 结果,k8s API服务器会将Helm的请求视为“好,他们没有尝试修改此字段”。

当前的情况是,Helm尤其对于Service资源非常不可靠,因为Helm假定它拥有给定资源的真相。 这是一个导致此问题的错误假设,因为资源可能已收到Helm不知道的服务器端新属性。 因此,Helm应该知道哪些领域需要特殊对待才能成为合格的k8s公民。

PS。 kubectl还在客户端实现了很多逻辑,这使得kubectl可以执行这些隐式需求。

@ jbilliau-rcd

尝试不使用--force

@pre

我认为三路合并发生了一些古怪的事情。 也许最后应用的注释以某种方式被不正确地记录了。

我最终弄清楚了。 显然,您可以在Deployment和Pod规格上更改标签,但不能在匹配选择器上更改标签……Kubernetes不喜欢这样。 这对我来说很奇怪; 我还应该如何修改部署,以便在例如金丝雀部署期间仅选择version “ v2”上的Pod? 目前,我无法做到这一点,因此我对此感到困惑。

升级到头盔版本3.5.0解决了该问题。

升级到头盔版本3.5.0解决了该问题。

到底是什么?

升级到头盔版本3.5.0解决了该问题。

Helm 3.5.0版仍然无法正常工作。
但是没有--force可以工作。

击中头盔3.5.2

我试图删除--force但仍然遇到相同的问题。

Upgrade "gateway" failed: failed to replace object: Service "ingress"
    is invalid: spec.clusterIPs[0]: Invalid value: []string(nil): primary clusterIP
    can not be unset

到目前为止,找到了一个合理的解决方法- --reuse-values标志。 适用于我的情况。

3.5.2使用/不使用--reuse-values仍然存在此问题

3.5.3也有这个:/

此页面是否有帮助?
0 / 5 - 0 等级