<p>I have the following two secrets for two different docker registries:</p>
<p>secret1-registry.yaml:</p>
<pre><code>apiVersion: v1
data:
  .dockerconfigjson: somevalue1
kind: Secret
metadata:
  name: metadata1
type: kubernetes.io/dockerconfigjson
</code></pre>
<p>secret2-registry.yaml:</p>
<pre><code>apiVersion: v1
data:
  .dockerconfigjson: somevalue2
kind: Secret
metadata:
  name: metadata2
type: kubernetes.io/dockerconfigjson
</code></pre>
<p>Is it possible to combine the two secrets?</p>

Marc
<p>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 '&lt;json_data&gt;' | base64 -w 0.</p>
<pre><code>apiVersion: v1
data:
  .dockerconfigjson: combined_base64_encoded_data
kind: Secret
metadata:
  name: combined-docker-secrets
type: kubernetes.io/dockerconfigjson

</code></pre>
<p>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.</p>
<pre><code># Base64 encode the combined Docker configuration JSON
combined_data=$(echo -n '{&quot;auths&quot;:{&quot;registry1&quot;:{&quot;auth&quot;:&quot;somevalue1&quot;},&quot;registry2&quot;:{&quot;auth&quot;:&quot;somevalue2&quot;}}}' | base64 -w 0)

# Create the combined secret
kubectl create secret generic combined-docker-secrets \
  --from-literal=.dockerconfigjson=$combined_data \
  --type=kubernetes.io/dockerconfigjson
</code></pre>
