Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make the bootstrapper exit cleanly on subsequent runs #174

Merged
2 commits merged into from
Nov 28, 2023

Conversation

voxeljorge
Copy link
Contributor

@voxeljorge voxeljorge commented Oct 25, 2023

Name of feature:

Make autocert-bootstrapper exit cleanly on subsequent runs

Pain or issue this feature alleviates:

Resolve #173

Why is this important to the project (if not answered above):

Hopefully it fixes a bug

Is there documentation on how to use this feature? If so, where?

I'm not sure additional documentation is necessary here.

In what environments or workflows is this feature supported?

Any environment where pods run for a long time.

In what environments or workflows is this feature explicitly NOT supported (if any)?

None specifically

Supporting links/other PRs/issues:

According to the Kubernetes docs pods can be restarted for a couple of reasons, and in the current setup the bootstrapper will fail on subsequent runs. https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#pod-restart-reasons

@CLAassistant
Copy link

CLAassistant commented Oct 25, 2023

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the needs triage Waiting for discussion / prioritization by team label Oct 25, 2023
@voxeljorge
Copy link
Contributor Author

I have tested this change locally with microk8s by doing the following:

  1. Install microk8s with a local registry
  2. Build all 3 containers (controller, bootstrapper, renewer) from this change
docker build . -t localhost:32000/autocert-bootstrapper -f bootstrapper/Dockerfile
docker build . -t localhost:32000/autocert-controller -f controller/Dockerfile
docker build . -t localhost:32000/autocert-renewer -f renewer/Dockerfile
docker push localhost:32000/autocert-bootstrapper
docker push localhost:32000/autocert-controller
docker push localhost:32000/autocert-renewer
  1. install autocert from the helm chart, using values that look like the following:
autocert:
  image:
    repository: localhost:32000/autocert-controller
    tag: latest
    pullPolicy: Always
bootstrapper:
  image:
    repository: localhost:32000/autocert-bootstrapper
    tag: latest
    pullPolicy: Always
renewer:
  image:
    repository: localhost:32000/autocert-renewer
    tag: latest
    pullPolicy: Always
  1. Create a pod with the autocert annotation, observe it gets created and bootstraps a cert correctly
  2. Remove the generated token secret with kubectl delete secret
  3. find the pause container for this pod with ps axf and kill it to simulate the full pod getting restarted

I can confirm that following these steps, I do see a log message like the following produced by the bootstrapper the second time around:

Found existing /var/run/autocert.step.sm/root.crt, skipping bootstrap

@dopey dopey requested a review from maraino November 7, 2023 18:02
@dopey
Copy link
Contributor

dopey commented Nov 8, 2023

Hey @voxeljorge 👋 . Pleasure to e-meet you and thanks for the PR! We'll be taking a look at this shortly (within the next few weeks) - bogged down with some other work at the moment. Cheers!

Copy link
Collaborator

@maraino maraino left a comment

Choose a reason for hiding this comment

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

Thanks @voxeljorge lgtm

@maraino maraino closed this pull request by merging all changes into smallstep:master in 172596c Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Waiting for discussion / prioritization by team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Init container failing on old pods
5 participants