Repository navigation
Description
According to https://github.com/kubernetes/helm/blob/master/docs/chart_best_practices/third_party_resources.md option 2 you can phase the creation of ThirdPartyResources using a pre-install hook however this doesn't work.
When trying to use helm to install the following test templates:
% ls templates
00-thirdpartyresource.yaml 20-certificate.yaml
% cat templates/00-thirdpartyresource.yaml
---
apiVersion: extensions/v1beta1
kind: ThirdPartyResource
description: "A test tpr resource defintion to test pre-hooks"
metadata:
name: "testtpr.helm.something"
annotations:
"helm.sh/hook": pre-install
versions:
- name: v1
% cat templates/20-certificate.yaml
---
apiVersion: "helm.something/v1"
kind: "Testtpr"
metadata:
name: "test-testtpr"
spec:
domain: "test.domain"
I get the following
% helm install .
Error: apiVersion "helm.something/v1" in helm-test/templates/20-certificate.yaml is not available
Tiller logs show this:
[tiller] 2017/07/12 14:20:47 preparing install for
[storage] 2017/07/12 14:20:47 getting release "rolling-olm.v1"
[tiller] 2017/07/12 14:20:47 rendering helm-test chart using values
[tiller] 2017/07/12 14:20:47 failed install prepare step: apiVersion "helm.something/v1" in helm-test/templates/20-certificate.yaml is not available
When I create these sequentially using kubectl it works fine
% kubectl create -f templates/00-thirdpartyresource.yaml
thirdpartyresource "testtpr.helm.something" created
% kubectl create -f templates/20-certificate.yaml
testtpr "test-testtpr" created
% kubectl get thirdpartyresource
NAME DESCRIPTION VERSION(S)
testtpr.helm.something A test tpr resource defintion to test pre-hooks v1
% kubectl get testtpr
NAME KIND
test-testtpr Testtpr.v1.helm.something
If I try and do something similar with helm by moving 20-certifcate.yaml out of the templates folder and doing a helm install it fails yet still creates the resource. However the helm chart isn't created.
% mv templates/20-certificate.yaml ./
% ls templates
00-thirdpartyresource.yaml
% helm install .
Error: the server rejected our request for an unknown reason (get thirdpartyresources.extensions)
% kubectl get thirdpartyresource
NAME DESCRIPTION VERSION(S)
testtpr.helm.something A test tpr resource defintion to test pre-hooks v1
% helm list
NAME REVISION UPDATED STATUS CHART NAMESPACE
If I remove the hook though it works.
% cat templates/00-thirdpartyresource.yaml
---
apiVersion: extensions/v1beta1
kind: ThirdPartyResource
description: "A test tpr resource defintion to test pre-hooks"
metadata:
name: "testtpr.helm.something"
#annotations:
# "helm.sh/hook": pre-install
versions:
- name: v1
% helm install .
NAME: existing-jaguar
LAST DEPLOYED: Wed Jul 12 15:38:43 2017
NAMESPACE: default
STATUS: DEPLOYED
RESOURCES:
==> v1beta1/ThirdPartyResource
NAME DESCRIPTION VERSION(S)
testtpr.helm.something A test tpr resource defintion to test pre-hooks v1
I can then move the second template back into the folder and do a helm upgrade.
% mv 20-certificate.yaml templates
% ls templates
00-thirdpartyresource.yaml 20-certificate.yaml
% helm upgrade existing-jaguar .
Release "existing-jaguar" has been upgraded. Happy Helming!
LAST DEPLOYED: Wed Jul 12 15:40:56 2017
NAMESPACE: default
STATUS: DEPLOYED
RESOURCES:
==> v1/Testtpr
NAME KIND
test-testtpr Testtpr.v1.helm.something
==> v1beta1/ThirdPartyResource
NAME DESCRIPTION VERSION(S)
testtpr.helm.something A test tpr resource defintion to test pre-hooks v1
I have tested hooks without ThirdPartyResources and they seem fine so the issue seems to lie with ThirdPartyResources and hooks. I have tested using a post-install hook for ThirdPartyResources to similar effect.
Helm and Kubernetes versions
% helm version
Client: &version.Version{SemVer:"v2.5.0", GitCommit:"012cb0ac1a1b2f888144ef5a67b8dab6c2d45be6", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.5.0", GitCommit:"012cb0ac1a1b2f888144ef5a67b8dab6c2d45be6", GitTreeState:"clean"}
% kubectl version
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"clean", BuildDate:"2017-05-19T18:44:27Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"clean", BuildDate:"2017-05-19T18:33:17Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
Activity
seh commentedon Jul 13, 2017
The Kubernetes client used by Tiller is not using a
runtime.Schemeimpregnated with knowledge of your TPR types. kubectl uses the "discovery" interface to learn of such types before interacting further with the API server.lhopki01 commentedon Jul 13, 2017
@seh my understanding of a pre-install hook is that it should install the TPR kind first before it tries to install the TPR types so it shouldn't have this conflict.
Also why would having a pre-install hook create issues when only a TPR kind is being installed by helm?
seh commentedon Jul 15, 2017
I'm still having trouble following your description of what works and what doesn't work, but I suspect this problem has nothing to do with hooks. The following possibilities come to mind:
That doesn't look like the case here, as we're not seeing failures that look to be related to authorization.
Normally after one creates a TPR kind, the client must poll the API server to wait until the TPR is ready for use. What happens if you add another intervening hook that stalls after creating the TPR for, say, 20 seconds?
I am not sure of the consequences of not registering the TPR's kinds with the Kubernetes client's
runtime.Scheme, but in my own project I've done that, following approximately the (now deprecated) example in the kubernetes/client-go repository.lhopki01 commentedon Jul 18, 2017
@seh
Option 1 doesn't apply because it can create TPRs when there is no hook set.
Option 2 won't work because as above when I try and only create a TPR with a pre-install hook it fails.
I don't even know what option 3 is quite but Tiller Kubernetes client can create TPRs just not when a hook is specified.
fejta-bot commentedon Jan 1, 2018
Issues go stale after 90d of inactivity.
Mark the issue as fresh with
/remove-lifecycle stale.Stale issues rot after an additional 30d of inactivity and eventually close.
Prevent issues from auto-closing with an
/lifecycle frozencomment.If this issue is safe to close now please do so with
/close.Send feedback to sig-testing, kubernetes/test-infra and/or
@fejta./lifecycle stale
fejta-bot commentedon Jan 31, 2018
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with
/remove-lifecycle rotten.Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with
/close.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale
fejta-bot commentedon Mar 2, 2018
Rotten issues close after 30d of inactivity.
Reopen the issue with
/reopen.Mark the issue as fresh with
/remove-lifecycle rotten.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
dotw commentedon Mar 22, 2018
I have the same issue when my chart has a subchart of cert-manager. it reports the similar issue when an Issuer.yam is in the parent chart.
brbarnett commentedon May 22, 2018
I have the same issue as @dotw, specifically with cert-manager. I've forked cert-manager and even added the crd-install hook annotation to the issuer CRD, but I still get
apiVersion "certmanager.k8s.io/v1alpha1" in app/templates/issuer.yaml is not availableqrevel commentedon Jun 5, 2018
/reopen
/remove-lifecycle rotten
exactly the same problem than @brbarnett
mikluko commentedon Jul 26, 2018
I managed to work that around by scheduling deployment job. Snippet below is rke specific, but can probably be adapted to any cluster implementation.
systemis my top-level chart.