Docker Hub Credential Secret
1. Generate a docker hub secret token dedicated to the cluster.
From your ogranization or your user account.
2. Create a JSON file
We will base64 encode it at the end.
dockerhub.json
json
{
"auths": {
"docker.io": {
"username": "<your_username_here>",
"password": "<your_token_here>",
}
}
}
3. Base64 encode the JSON file
bash
cat dockerhub.json | base64
4. Create the secret in Kubernetes
dh-secret.yaml
yaml
```bash
apiVersion: v1
kind: Secret
metadata:
name: dh-secret
namespace: <your_namespace_here>
data:
.dockerconfigjson: <base64_encoded_json_here>
type: kubernetes.io/dockerconfigjson
5. Apply the secret
bash
kubectl apply -f dh-secret.yaml