我有要部署的使用 Helm 图表的应用程序。在第一个 helm update --install
命令中,一切都按预期工作,但第二次出现此错误:
Error: UPGRADE FAILED: failed to replace object: PersistentVolumeClaim "logs" is invalid: spec: Forbidden: is immutable after creation except resources.requests for bound claims && failed to replace object: Service "application" is invalid: spec.clusterIP: Invalid value: "": field is immutable
这是我的application-deployment.yaml
:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: application
name: application
spec:
selector:
matchLabels:
app: application
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: application
spec:
imagePullSecrets:
- name: aws-registry
containers:
- image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: Always
name: application
resources: {}
volumeMounts:
- mountPath: /app/var/logs
name: logs
restartPolicy: Always
volumes:
- name: logs
persistentVolumeClaim:
claimName: logs
这里是application-service.yaml
:
apiVersion: v1
kind: Service
metadata:
labels:
app: application
name: application
spec:
ports:
- port: 9000
protocol: TCP
targetPort: 9000
selector:
app: application
这里是logs-pvc.yaml
:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: middleware-logs
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 400Mi
status: {}
我不知道如何解决这个问题,一旦创建 pvc 或服务就不可能更改,所以我猜测我做错了什么,但不确定是什么。
最佳答案
从 helm Upgrade 中删除 --force 解决了我的问题。
关于kubernetes - Helm 升级过程中无法重新创建部署,因为 PersistentVolumeClaim 和 Service 无法替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64659951/