Skip to content

Instantly share code, notes, and snippets.

@JoooostB
Created October 5, 2022 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoooostB/fd8a470df3d77e1fe19df195cb5df2ed to your computer and use it in GitHub Desktop.
Save JoooostB/fd8a470df3d77e1fe19df195cb5df2ed to your computer and use it in GitHub Desktop.
ExternalSecret to create Docker Hub- or any other imagePullSecret from AWS Secret Manager
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: es-docker-hub-token
spec:
data:
- remoteRef:
key: /eks/docker-hub-token
secretKey: token
refreshInterval: 1h
secretStoreRef:
kind: ClusterSecretStore
name: test
target:
name: docker-hub-token
template:
data:
.dockerconfigjson: '{{ .token | toString }}'
engineVersion: v2
type: kubernetes.io/dockerconfigjson
@JoooostB
Copy link
Author

JoooostB commented Oct 5, 2022

First, generate a base64 encoded string from your username and password or token combination:

echo -n <username>:<password|token> | base64

Then, create a secret in AWS Secret Manager in the following format:

{
    "auths": {
        "https://index.docker.io/v1/": {
            "auth": "<base64-content>"
        }
    }
}

If you're configuring the secret for another container registry than Docker Hub, make sure to modify the URL in the json above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment