我们拥有Helm 3.0.3和1.18 k8,自一年以来,我们没有遇到过以下任何问题。我们通过头盔将多个微服务部署到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
service.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
答案 0 :(得分:2)
将public class BackgroundServerFacade implements Runnable {
@Override
public void run() {
ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
UpdateCenterImpl updateCenterImpl = new UpdateCenterImpl(newSingleThreadExecutor);
updateCenterThread = new Thread(updateCenterImpl);
updateCenterThread.start();
}
}
与--force
一起使用时,掌舵使用的是替换策略,而不是补丁。
看看以下helm code:
helm upgrade
替换策略导致您看到的错误。 如果您想知道为什么会发生这种情况,请查看this kubectl issue。
答案 1 :(得分:0)
@matt是正确的 --force
使用替换策略。
我最近在使用Helm更新服务选择器时遇到了这个问题,因此,为了快速修复/破解,我直接编辑服务并进行所需的更改(更新选择器),然后运行helm命令进行同步(帮助)升级--force release_name )。
它不会显示服务的任何更改。 (纯技巧,但有帮助)