0
votes

Trying to do:

helm upgrade --namespace keycloak -f k8s/sandbox/values.yaml keycloak codecentric/keycloak

Getting:

UPGRADE FAILED: cannot patch "keycloak-http" with kind Service: Service "keycloak-http" is invalid: [spec.ports[0].nodePort: Forbidden: may not be used when `type` is 'ClusterIP', spec.ports[1].nodePort: Forbidden: may not be used when `type` is 'ClusterIP']

However, initial values is NodePort, not ClusterIP:

service:
  # Annotations for headless and HTTP Services
  annotations: {}
  # Additional labels for headless and HTTP Services
  labels: {}
  # key: value
  # The Service type
  type: NodePort

Also kubectl edit shows type: NodePort

spec:
  clusterIP: <SomeIP>
  externalTrafficPolicy: Cluster
  ports:
  - name: http
    nodePort: 31062
    port: 80
    protocol: TCP
    targetPort: http
  - name: https
    nodePort: 31258
    port: 8443
    protocol: TCP
    targetPort: https
  - name: http-management
    nodePort: 32113
    port: 9990
    protocol: TCP
    targetPort: http-management
  selector:
    app.kubernetes.io/instance: keycloak
    app.kubernetes.io/name: keycloak
  sessionAffinity: None
  type: NodePort

Here is the keycloak-http service from helm template. For some reason it says ClusterIp, but both the inital values.yaml says NodePort and also kubectl edit service keycloak-http say it is NodePort:

# Source: keycloak/templates/service-http.yaml
apiVersion: v1
kind: Service
metadata:
  name: keycloak-http
  labels:
    helm.sh/chart: keycloak-10.1.0
    app.kubernetes.io/name: keycloak
    app.kubernetes.io/instance: keycloak
    app.kubernetes.io/version: "12.0.4"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: http
spec:
  type: ClusterIP
  ports:
    - name: http
      port: 80
      targetPort: http
      protocol: TCP
    - name: https
      port: 8443
      targetPort: https
      protocol: TCP
    - name: http-management
      port: 9990
      targetPort: http-management
      protocol: TCP
  selector:
    app.kubernetes.io/name: keycloak
    app.kubernetes.io/instance: keycloak

Any ideas?

2
What's the content of the new values.yaml that you to upgrade with?acid_fuji
@thomas: Only trying to upgrade the image: ``` image: # The Keycloak image repository repository: <OUR_REPOSITORY> # Overrides the Keycloak image tag whose default is the chart version tag: staging # The Keycloak image pull policy pullPolicy: Always ```globus68
Can you generate the template with helm template and paste the service part from it?acid_fuji
@thomas: The helm template output was too long for a comment, so I pasted it into the original question. It shows ClusterIP although both the initial values and kubectl edit shows NodePort.globus68

2 Answers

0
votes

Please delete the service manually and perform the helm upgrade again

0
votes

I pulled the repository and tried changing the values.yaml to NodePort and this works fine for me. The template that was printed had NodePort instead of ClusterIP. This means that you might be doing something wrong or perhaps using some wrong values file.

Now the error itself is there because you can't change the service type like that and Kubernetes won't allow it because NodePort has additional parameter included in the service template:

"ports": [
            {
                "name": "http",
                "nodePort": 30240,
                "port": 8888,
                "protocol": "TCP",
                "targetPort": "http"
            }

While this is the ClusterIP:

"ports": [
            {
                "name": "http",
                "port": 8888,
                "protocol": "TCP",
                "targetPort": "http"
            }

There are couple of possible workaround for this issue when you attempt to change service like that:

  • Install new version of the helm chart with a different release name
  • Manually change the service type with kubectl edit svc
  • Delete the existing release and install new version of the chart with the same release name