Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Get image pull secrets via serviceAccounts #1291

Merged
merged 6 commits into from
Aug 21, 2018

Conversation

squaremo
Copy link
Member

It is possible, and often more economical, to give ImagePullSecrets to
a service account (perhaps the default for the namespace), rather than
each workload individually.

So that flux will still find these secrets, look up the service
account, and its imagePullSecrets, if any. This involves one more RPC
to the API server (to get the service account), per workload.

Fixes #1043.

It is possible, and often more economical, to give ImagePullSecrets to
a service account (perhaps the default for the namespace), rather than
each workload individually.

So that flux will still find these secrets, look up the service
account, and its imagePullSecrets, if any. This involves one more RPC
to the API server (to get the service account), per workload.
Each time we refresh the list of images to fetch metadata for, we do this:

 * create a map of image->credentials
 * for each workload,
   * look up all the imagePullSecrets associated with it and merge
     them together into credentials
   * for each image used in the workload, merge with the entry in the
     map for that image

This works, but it uses far more API calls than it really needs to,
because secrets are very likely to be reused as imagePullSecrets for
different workloads.

To avoid doing extra lookups, keep track of secrets already seen
within each namespace, and don't ask for them again when they are
mentioned afterwards.
A minor refactor to pull these apart a little and make testing (and
further separation) easier.
This rationalises the use of the Kubernetes' client in
kubernetes.Cluster by using the pre-made clientset, rather than a
bunch of individual interfaces.
This makes it a bit easier to track down problems.
 - do we get creds that are mentioned as ImagePullSecrets in the pod
   spec?
 - do we get creds that are mentioned as ImagePullSecrets in the
   service account?
@squaremo squaremo requested a review from aaron7 August 16, 2018 16:22
Copy link
Contributor

@aaron7 aaron7 left a comment

Choose a reason for hiding this comment

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

lgtm :)
+1 for tests

@squaremo squaremo merged commit 3e98ee1 into master Aug 21, 2018
@squaremo squaremo deleted the issues/1043-get-image-secrets-from-sa branch August 21, 2018 14:17
@squaremo
Copy link
Member Author

Cheers 🎇

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.

2 participants