Skip to content

Add startup api check Job - #4234

Merged
jetstack-bot merged 6 commits into
cert-manager:masterfrom
inteon:add_startupapicheck
Aug 3, 2021
Merged

jetstack-bot merged 6 commits into
cert-manager:masterfrom
inteon:add_startupapicheck

Conversation

@inteon

@inteon inteon commented Jul 20, 2021

Copy link
Copy Markdown
Member

What this PR does / why we need it:
Add startupapicheck Job that waits for the cert-manager api to become ready.
This Job can be awaited for by adding the --wait flag to the helm install command.

Alternatively, the following kubectl command can be used to wait for the cert-manager api to be ready:

kubectl wait -n cert-manager --for=condition=complete job/cert-manager-startupapicheck

Which issue this PR fixes
fixes #4155

Release note:

Added a startup api check Job that waits for the cert-manager api to become ready

/kind feature

@jetstack-bot jetstack-bot added kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. area/deploy Indicates a PR modifies deployment configuration needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 20, 2021
@jetstack-bot

Copy link
Copy Markdown
Contributor

Hi @inteon. Thanks for your PR.

I'm waiting for a jetstack or cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jetstack-bot jetstack-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 20, 2021
@inteon
inteon force-pushed the add_startupapicheck branch from 66e9571 to 4114528 Compare July 20, 2021 17:40
@SgtCoDFish

Copy link
Copy Markdown
Member

/ok-to-test

@jetstack-bot jetstack-bot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 21, 2021
Comment thread deploy/charts/cert-manager/values.yaml Resolved
Comment thread deploy/charts/cert-manager/values.yaml Resolved

@wallrj wallrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments and questions. I'll test it and give some more feedback later.

Comment thread devel/addon/certmanager/install.sh Resolved
Comment thread deploy/charts/cert-manager/values.yaml Resolved
@jetstack-bot jetstack-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 27, 2021

@wallrj wallrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to work very well @inteon

I tested locally using helm install --atomic --wait-for-jobs followed immediately by kubectl cert-manager check api and it worked every time.

It confused me for a while why APP_VERSION was explicitly supplied as image tag, for all the other components.

And we should try and see if the cmrel tool needs updating to publish the new ctl Docker image.

Comment thread BUILD.bazel
"{STABLE_DOCKER_REGISTRY}/cert-manager-acmesolver:{STABLE_DOCKER_TAG}": "//build:acmesolver.image",
"{STABLE_DOCKER_REGISTRY}/cert-manager-webhook:{STABLE_DOCKER_TAG}": "//build:webhook.image",
"{STABLE_DOCKER_REGISTRY}/cert-manager-cainjector:{STABLE_DOCKER_TAG}": "//build:cainjector.image",
"{STABLE_DOCKER_REGISTRY}/cert-manager-ctl:{STABLE_DOCKER_TAG}": "//build:ctl.image",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +115 to +116
Manually fix the 'app' and 'name' labels to 'startupapicheck' to maintain
compatibility with the v0.9 deployment selector.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that this comment is copied from other components, but what does "compatibility with the v0.9 deployment selector" mean? Any idea?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment was introduced in #2285

So it probably just means that the value is now set to a fixed value (different from before #2285, where it was generated).
This was done to not break the deployment selector, because that might cause pods to get orphaned.

So, in conclusion I think we can do a cleanup and just replace app.kubernetes.io/name: {{ include "cainjector.name" . }} with app.kubernetes.io/name: "cainjector" everywhere.

Comment thread deploy/charts/cert-manager/values.yaml Resolved
bazel build //deploy/charts/cert-manager

# Pre-compile the kubectl plugin, so it can quickly check the api status
bazel build //hack/bin:kubectl-cert_manager

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this still apply? I suppose it must already have been compiled in order to create the Docker image.

Comment thread devel/addon/certmanager/install.sh Resolved

@wallrj wallrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything else we can we do to be sure that this is actually going to help and not inconvenience people?
Like will it work with flux fluxcd/helm-controller#271
If we enable it by default how might it break existing CI pipelines?
Does it actually allow people to create a Helm chart containing cert-manager resources that depends on the cert-manager chart?

--set image.tag="${APP_VERSION}" \
--set cainjector.image.tag="${APP_VERSION}" \
--set webhook.image.tag="${APP_VERSION}" \
--set startupapicheck.image.tag="${APP_VERSION}" \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably should make these same changes in the hack/verify-upgrade.sh script.

$ make verify_upgrade
...

$ kubectl get pods -A
NAMESPACE            NAME                                         READY   STATUS         RESTARTS   AGE
cert-manager         cert-manager-5b4b8574f8-gwvkk                1/1     Running        0          42s
cert-manager         cert-manager-cainjector-6c5c7f6c47-2czng     1/1     Running        0          42s
cert-manager         cert-manager-startupapicheck-kvght           0/1     ErrImagePull   0          42s
cert-manager         cert-manager-webhook-76c4f7d5f8-7p5mk        1/1     Running        0          42s

@jetstack-bot jetstack-bot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2021
@inteon

inteon commented Jul 29, 2021 •

Copy link
Copy Markdown
Member Author

@wallrj:

  1. If we enable it by default how might it break existing CI pipelines?
    It should not break anything, but it might be useless (eg. if you do not wait for the Job).

  2. I don't think this PR will help when installing using cert-manager as a subchart.

    1. If you want to do that, crds have to be in the crds/ folder.
    2. The order is not respected https://helm.sh/docs/topics/charts/#operational-aspects-of-using-dependencies
    3. Helm first installs the Issuer, Certificate etc. resources and only after that installs ValidatingWebhookConfiguration and MutatingWebhookConfiguration -> this causes the install to not fail if you have added the crds/ folder
  3. I just found out that by adding these labels to the Job, we do not have to add the --wait-for-jobs flag, and the Job is removed after it succeeded:

annotations:
      helm.sh/hook: post-install
      helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded

@jetstack-bot jetstack-bot added dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. and removed dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. labels Jul 30, 2021
@inteon
inteon force-pushed the add_startupapicheck branch from 40cd039 to 06e2ac2 Compare July 30, 2021 15:31
@jetstack-bot jetstack-bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. and removed dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. labels Jul 30, 2021
@maelvls maelvls mentioned this pull request Aug 3, 2021
13 tasks done

@wallrj wallrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inteon

The post-install hook approach seems to work nicely, but I think we should change the hook deletion policies to include the failure case too, otherwise the hook resources don't get removed if the chart fails.
https://helm.sh/docs/topics/charts_hooks/#hook-deletion-policies

I'm also not sure whether the confgured timeout will be long enough on deployments where the cert-manager images take a long time to download.
It was difficult to test that without having any published images though, so I propose we merge this as-is so that I can do more thorough testing using the v1.5.0-beta.0 release which is due out this afternoon.

/lgtm
/approve

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2021
@jetstack-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inteon, wallrj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jetstack-bot jetstack-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 3, 2021
@wallrj

wallrj commented Aug 3, 2021

Copy link
Copy Markdown
Member

/retest

1 similar comment
@wallrj

wallrj commented Aug 3, 2021

Copy link
Copy Markdown
Member

/retest

@wallrj

wallrj commented Aug 3, 2021

Copy link
Copy Markdown
Member

/retest

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/deploy Indicates a PR modifies deployment configuration dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webhook connection problems shortly after cert-manager installation

5 participants