Skip to content

When helm uses annotations for crd-install on existing helm chart, CRDs are deleted #4704

Closed

Description

@mmerrill3

Output of helm version:
Client: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
Output of kubectl version:
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-08T16:31:16Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.7", GitCommit:"0c38c362511b20a098d7cd855f1314dad92c2780", GitTreeState:"clean", BuildDate:"2018-08-20T09:56:31Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Cloud Provider/Platform (AKS, GKE, Minikube etc.):
AWS

Hello,
When we update an existing chart using the helm annotation "helm.sh/hook": crd-install, helm will not add the to the target manifest the resources that contain the hook. So, as part of the upgrade, the CRD definitions are deleted. As a side effect, all of the CRD instances are also deleted.

The log below shows this from tiller (in bold):

[tiller] 2018/09/21 15:52:20 executing 3 pre-upgrade hooks for security
[tiller] 2018/09/21 15:52:20 hooks complete for pre-upgrade security
[kube] 2018/09/21 15:52:20 building resources from updated manifest
[kube] 2018/09/21 15:52:20 checking 16 resources for changes
[kube] 2018/09/21 15:52:20 Looks like there are no changes for ServiceAccount "sealed-secrets"
…
[kube] 2018/09/21 15:52:20 Deleting "certificates.certmanager.k8s.io" in ...
[kube] 2018/09/21 15:52:20 Deleting "clusterissuers.certmanager.k8s.io" in ...
[kube] 2018/09/21 15:52:20 Deleting "issuers.certmanager.k8s.io" in ...

[tiller] 2018/09/21 15:52:20 executing 3 post-upgrade hooks for security
[tiller] 2018/09/21 15:52:20 hooks complete for post-upgrade security
[storage] 2018/09/21 15:52:20 updating release "security.v7"
[tiller] 2018/09/21 15:52:20 updating status for updated release for security
[storage] 2018/09/21 15:52:20 updating release "security.v8"
[storage] 2018/09/21 15:52:21 getting last revision of "security"
[storage] 2018/09/21 15:52:21 getting release history for "security"

I believe the issue is with the file release_server.go

for _, m := range manifests {

The hooks are not being added to the manifests, so they are not part of the comparison later on. The CRDs contain the hook annotation, so they are omitted.

I believe the correct behavior is to include the manifest that have the hooks in the comparison. So, the hooks would need to be included in the manifests as well.

Activity

  1. mmerrill3 commented on Sep 27, 2018

    @mmerrill3
    Author

    Hi, I believe it would suffice to add the CustomResouceDefinition to the target manifests when there is a crd-install hook annotated on the resource. This would handle the use case where helm charts are deployed before this hook was implemented.

    At the very least, there should be documentation to indicate that this hook is destructive for existing CRD definitions that are deployed by helm. Let people decide how to handle this issue through internal migration processes.

  2. bacongobbler commented on Nov 29, 2018

    @bacongobbler
    Member

    Closed via #4709

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions