gpt4 book ai didi

kubernetes - spec.clusterIP : Invalid value: "": field is immutable

转载 作者:行者123 更新时间:2023-12-04 12:14:02 33 4
gpt4 key购买 nike

我们有 Helm 3.0.3 和 1.18 k8s,一年以来我们没有遇到过像下面这样的任何问题。我们通过 helm 将多个微服务部署到 k8s,到目前为止一切正常。但即使我们没有对服务字段进行任何更改,我们也会收到如下错误。
这是我如何部署到 k8s 的命令。当我在 k8s 中卸载该服务并开始重新构建时,它可以正常工作,但是当我需要推送新更改时,我再次面临此错误。

+ helm upgrade --install --debug --force xx-ui-dev --values values.dev.yaml --namespace dev --set image.tag=608 .

错误
history.go:52: [debug] getting history for release xx-ui-dev
upgrade.go:120: [debug] preparing upgrade for xx-ui-dev
upgrade.go:128: [debug] performing update for xx-ui-dev
upgrade.go:292: [debug] creating upgraded release for xx-ui-dev
client.go:173: [debug] checking 7 resources for changes
client.go:432: [debug] Replaced "xx-ui-dev" with kind NetworkPolicy for kind NetworkPolicy

client.go:432: [debug] Replaced "xx-ui-dev" with kind ServiceAccount for kind ServiceAccount

client.go:432: [debug] Replaced "xx-ui-dev-auth" with kind Secret for kind Secret

client.go:432: [debug] Replaced "xx-ui-dev-config" with kind ConfigMap for kind ConfigMap

client.go:205: [debug] error updating the resource "xx-ui-dev":
failed to replace object: Service "xx-ui-dev" is invalid: spec.clusterIP: Invalid value: "": field is immutable
client.go:432: [debug] Replaced "xx-ui-dev" with kind Deployment for kind Deployment

client.go:432: [debug] Replaced "xx-ui-dev" with kind HorizontalPodAutoscaler for kind HorizontalPodAutoscaler

upgrade.go:351: [debug] warning: Upgrade "xx-ui-dev" failed: failed to replace object: Service "xx-ui-dev" is invalid: spec.clusterIP: Invalid value: "": field is immutable
Error: UPGRADE FAILED: failed to replace object: Service "xx-ui-dev" is invalid: spec.clusterIP: Invalid value: "": field is immutable
helm.go:84: [debug] failed to replace object: Service "xx-ui-dev" is invalid: spec.clusterIP: Invalid value: "": field is immutable

服务.yaml
    spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 50003
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "xx-ui.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
tier: backend
values.dev.yaml

service:
type: ClusterIP
port: 80

最佳答案

使用时 --forcehelm upgrade , helm 使用替换策略而不是补丁。
看看下面的helm code :

if force {
var err error
obj, err = helper.Replace(target.Namespace, target.Name, true, target.Object)

...

} else {
patch, patchType, err := createPatch(target, currentObj)

...

// send patch to server
obj, err = helper.Patch(target.Namespace, target.Name, patchType, patch, nil)
}
替换策略导致您看到的错误。
看看 this kubectl issue如果您想知道为什么会发生这种情况。

关于kubernetes - spec.clusterIP : Invalid value: "": field is immutable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63704993/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com