2

I have application that is using Helm charts to be deployed. On first helm upgrade --install command everything works as expected but second time I have this error:

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

here is my 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

here is application-service.yaml:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: application
  name: application
spec:
  ports:
  - port: 9000
    protocol: TCP
    targetPort: 9000
  selector:
    app: application

and here is logs-pvc.yaml:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: middleware-logs
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 400Mi
status: {}

I don't have any idea how to solve this it is impossible that once created pvc or service can't be change so I am guessint that I am doing something wrong but not sure what.

Most31
  • 400
  • 4
  • 18
  • 1
    I suspect trying to force `status:` to be empty in the very very last line causes at least part of this; does deleting that line help? – David Maze Nov 03 '20 at 11:52
  • @DavidMaze I already tried that and it didn't change error at all – Most31 Nov 03 '20 at 12:28
  • The problem was because I was doing upgrade with --force parameter – Most31 Nov 03 '20 at 13:39
  • 1
    @Most31 did you solve removing the flag `--force` from the command? Please post an answer explaining how did you solve it. About `--force` your can check this [`link`](https://stackoverflow.com/questions/60426241/error-upgrade-failed-failed-to-replace-object-service-api-is-invalid-spec/60543378#60543378) that explains how it works. – Mr.KoopaKiller Nov 05 '20 at 12:03

1 Answers1

2

Removing --force from helm upgrade solved my issue.

  • 1
    OP also stated that this resolved the issue, but did not provide additional details. If you could do that here, that would help everyone coming to this question. – ryanwebjackson May 16 '22 at 12:14