Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

A simple Kubernetes client-go application that creates and patches imagePullSecrets to service accounts in all Kubernetes namespaces to allow cluster-wide authenticated access to private container registry.

License

Notifications You must be signed in to change notification settings

goglides/imagepullsecret-patcher

Open more actions menu
 
 

Repository files navigation

imagepullsecret-patcher

Build Status Go Report Card Codecov GitHub tag (latest SemVer) GitHub issues

A simple Kubernetes client-go application that creates and patches imagePullSecrets to service accounts in all Kubernetes namespaces to allow cluster-wide authenticated access to private container registry.

screenshot

A blog post: https://medium.com/titansoft-engineering/kubernetes-cluster-wide-access-to-private-container-registry-with-imagepullsecret-patcher-b8b8fb79f7e5

Installation and configuration

To install imagepullsecret-patcher, can refer to deploy-example as a quick-start.

Below is a table of available configurations:

Config name ENV Command flag Default value Description
force CONFIG_FORCE -force true overwrite secrets when not match
debug CONFIG_DEBUG -debug false show DEBUG logs
serviceaccounts CONFIG_SERVICEACCOUNTS -serviceaccounts "default" comma-separated list of serviceaccounts to patch
all service account CONFIG_ALLSERVICEACCOUNT -allserviceaccount false if true, list and patch all service accounts and the -servicesaccounts argument is ignored
dockerconfigjson CONFIG_DOCKERCONFIGJSON -dockerconfigjson "" json credential for authenicating container registry
secret name CONFIG_SECRETNAME -secretname "image-pull-secret" name of managed secrets
excluded namespaces CONFIG_EXCLUDED_NAMESPACES -excluded-namespaces "" comma-separated namespaces excluded from processing

And here are the annotations available:

Annotation Object Description
k8s.titansoft.com/imagepullsecret-patcher-exclude namespace If a namespace is set this annoation with "true", it will be excluded from processing by imagepullsecret-patcher.

Why

To deploy private images to Kubernetes, we need to provide the credential to the private docker registries in either

With the second approach, a Kubernetes cluster admin configures the default service accounts in each namespace, and a Pod deployed by developers automatically inherits the image-pull-secret from the default service account in Pod's namespace.

This is done manually by following command for each Kubernetes namespace.

kubectl create secret docker-registry image-pull-secret \
  -n <your-namespace> \
  --docker-server=<your-registry-server> \
  --docker-username=<your-name> \
  --docker-password=<your-pword> \
  --docker-email=<your-email>

kubectl patch serviceaccount default \
  -p "{\"imagePullSecrets\": [{\"name\": \"image-pull-secret\"}]}" \
  -n <your-namespace>

And it could be automated with a simple program like imagepullsecret-patcher.

Contribute

Development Environment

  • Go 1.13

About

A simple Kubernetes client-go application that creates and patches imagePullSecrets to service accounts in all Kubernetes namespaces to allow cluster-wide authenticated access to private container registry.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 98.8%
  • Dockerfile 1.2%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.