I have the following two secrets for two different docker registries:
secret1-registry.yaml:
apiVersion: v1
data:
.dockerconfigjson: somevalue1
kind: Secret
metadata:
name: metadata1
type: kubernetes.io/dockerconfigjson
secret2-registry.yaml:
apiVersion: v1
data:
.dockerconfigjson: somevalue2
kind: Secret
metadata:
name: metadata2
type: kubernetes.io/dockerconfigjson
Is it possible to combine the two secrets?
2
Answers
If you want to manually combine, the .dockerconfigjson field should be a base64-encoded representation of the combined Docker configuration JSON. To create the base64-encoded data, you can use a tool like echo -n ‘<json_data>’ | base64 -w 0.
You can also use kubectl commands to create the combined secret. Assuming you have the content of somevalue1 and somevalue2 as actual Docker configuration JSONs.
Why would you want to combine those secrets? When you specify an imagePullSecret for a Deployment or a similar resource, you can provide a list of imagePullSecrets to use during the container image pull phase.