'Deployment can't be recreated during helm upgrade because PersistentVolumeClaim and Service failed to be replace

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.



Solution 1:[1]

Removing --force from helm upgrade solved my issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Premtim Surdulli