-
Notifications
You must be signed in to change notification settings - Fork 113
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
deterministic ordering of kubernetes.io/service-account-token secrets and SAs #514
Comments
So using:
appears to solve the issue. The question is whether the expectation is that users are going to have to know this and add the annotations themselves, or whether kapp could somehow accomodate this automatically. |
A solution to this if possible would be an inbuilt rule to create secrets of type |
@GrahamDumpleton , thank your for the full analysis and way to reproduce the issue. This really helps. will take up on priority. |
it's not that it's not visible, it's that it's deleted by k8s immediately (with tiny delay for some controller to notice) since k8s sees that there is no associated SA. you can repro this reliably just by creating this single resource
kapp deploy may actually succeed but if you look just a tiny second later secret is gone from k8s. if you rerun kapp deploy it will show you that it's trying to create secret again because it doesnt exist. k8s will not delete secret with that annotation if SA already exists in the server. |
Initially I didn't know what was going on so that was best guess, but as I got to in the end I did surmise it was purely ordering requirement. :-) The question is whether kapp can embody a rule that if a secret is of type |
my 2c: this use case seems pretty rare, i think its worth seeing how common this problem becomes/is before promoting this behavior to a default rule. |
We have noticed this in a couple of instances lately (especial when there are multiple SAs and Secrets present in the app). We should consider having some default rules to cover this. |
+100 There should be a default rule for the secrets of |
This was fixed in kapp v0.61.0 with #895, not sure why the automation didn't close the issue. |
In Kubernetes 1.24 there have been changes to how REST API access tokens are handled. This affects use of
kapp-controller
as described in separate issue carvel-dev/kapp-controller#687. With such changes one can expect people to start using secrets of typekubernetes.io/service-account-token
more often, butkapp
appears to experience intermittent failures when presented with secrets of that type. This is even when using Kubernetes 1.23.The actual error one gets is like:
So
kapp
thinks the secret doesn't exist, even though it logged that it created it. Expectation is that the secret doesn't appear to be visible immediately as the Kubernetes admission controller takes time to inject the credentials and certificate into the token secret, since what a user creates is effectively a place holder with Kubernetes filling in the real details.What steps did you take:
Initially only saw the problem twice, a week apart, but believe have a recipe for replicating the issue.
Create a
resources.yaml
file containing:Then run:
Increase the count value high enough that keeps trying many times in a single run with hope that it triggers the issue. Success may depend on the Kubernetes cluster being used. Issue has currently been seen on local Kind cluster.
What happened:
It would error with:
For a full debug log see
kapp.log
attachment.In this case the issue was only triggered on very last iteration, but have seen it occur earlier, just have to be lucky.
The result in the namespace at the point of failure was:
Note not sure if issue may in part be that
kapp
is reordering resources to create the secret before the service account. The Kubernetes docs say for token secrets:The docs thus say existing and since the secret has to have an annotation added with the uid of the service account, the order may actually be important. Thus if kapp does change order they are created, this would delay perhaps the secret being made visible if admission controller holds it for a bit until service account exists.
What did you expect:
Work reliably. :-)
Anything else you would like to add:
Nope.
Environment:
kapp --version
):/etc/os-release
):kubectl version
)Vote on this request
This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.
👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"
We are also happy to receive and review Pull Requests if you want to help working on this issue.
kapp.log
The text was updated successfully, but these errors were encountered: