Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Provide deployment info to webhook cert manager pod #987

Merged
merged 1 commit into from
Jun 11, 2021

Conversation

thisisnotashwin
Copy link

Changes proposed in this PR:

  • Pass -deployment-name and -deployment-namespace to webhook cert manager. This allows the cert-manager to set the deployment as the owner of the secrets it creates.

How I've tested this PR: Manually with a helm install and uninstall. The secrets get deleted post install. Additionally, performing a helm upgrade on a previous helm install adds an OwnerReference to the secret which should allow people upgrade to this version of the chart to have their secrets owned by the deployment.

How I expect reviewers to test this PR: Repeat above steps.

Checklist:

  • CHANGELOG entry added (HashiCorp engineers only, community PRs should not add a changelog entry)

Comment on lines 41 to 44
- get
- list
- watch
- patch
Copy link
Member

Choose a reason for hiding this comment

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

should only need get I think?

Copy link
Author

Choose a reason for hiding this comment

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

yeah..was a copypasta slipup

@thisisnotashwin thisisnotashwin force-pushed the webhook-secrets-owner branch from 7b72269 to 8078622 Compare June 10, 2021 21:10
@thisisnotashwin thisisnotashwin requested a review from lkysow June 10, 2021 21:14
Copy link
Contributor

@kschoche kschoche left a comment

Choose a reason for hiding this comment

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

hugely amaze.
reminder to update changelog yet.

When the certificate secret is created or updated, set an OwnerReference on the secret as the webhook-cert-manager deployment. This ensures that deletion of the deployment will also delete the secrets. This addresses the race condition bug that we sometimes see when re-installing consul on a cluster that had a consul deleted from it. This was because the helm delete would not delete the existing secrets with certificates. When the controller would get created with a new installation, it would mount the existing secret (which was stale) and the secret on disk would get rotated before the cert watcher started which would lead to the controller using certificates signed by a CA different from the CA bundle on the MWC which would lead to x509 errors.

This change would ensure the secrets get deleted every single time and hence, a new secret would always get created during a helm install. This also ensure an existing secret, when updated is updated with the owner ref ensuring helm upgrades or installs to a cluster with an existing secret give people the desired behavior as well.
@thisisnotashwin thisisnotashwin force-pushed the webhook-secrets-owner branch from 8078622 to adec53c Compare June 11, 2021 00:29
@thisisnotashwin thisisnotashwin merged commit a5564b7 into master Jun 11, 2021
@thisisnotashwin thisisnotashwin deleted the webhook-secrets-owner branch June 11, 2021 00:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants