Skip to content

helm upgrade fails when updating the apiVersion of a k8s resource #2885

@bismarck

Description

@bismarck

helm upgrade is failing when updating the apiVersion of a k8s resource

How to reproduce it?

helm create foo

Add the following NetworkPolicy to your templates directory

apiVersion: extensions/v1beta1
kind: NetworkPolicy
metadata:
  name: {{ template "name" . }}
spec:
  podSelector:
    matchLabels:
      app: {{ template "name" . }}
  ingress:
    - ports:
      - protocol: TCP
        port: 3128

Install chart

helm install ./foo -n foo

Replace the NetworkPolicy with

{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
apiVersion: networking.k8s.io/v1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: NetworkPolicy
metadata:
  name: {{ template "name" . }}
spec:
  podSelector:
    matchLabels:
      app: {{ template "name" . }}
  ingress:
    - ports:
      - protocol: TCP
        port: 3128

Upgrade release

helm upgrade foo ./foo --debug

You should see the following output

[debug] Created tunnel using local port: '58205'

[debug] SERVER: "localhost:58205"

Error: UPGRADE FAILED: no resource with the name "foo" found

If you run upgrade for a second time, it works.

Versions:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.4", GitCommit:"793658f2d7ca7f064d2bdf606519f9fe1229c381", GitTreeState:"clean", BuildDate:"2017-08-17T17:03:51Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.4", GitCommit:"793658f2d7ca7f064d2bdf606519f9fe1229c381", GitTreeState:"clean", BuildDate:"2017-08-17T08:30:51Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

$ helm version
Client: &version.Version{SemVer:"v2.6.0", GitCommit:"5bc7c619f85d74702e810a8325e0a24f729aa11a", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.6.0", GitCommit:"5bc7c619f85d74702e810a8325e0a24f729aa11a", GitTreeState:"clean"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions