<p>I have a kubernetes cluster in GKE. Inside the cluster there is an private docker registry service. A certificate for this service is generated inside a docker image by running:</p>
<pre class="lang-sh prettyprint-override"><code>openssl req -x509 -newkey rsa:4096 -days 365 -nodes -sha256 -keyout /certs/tls.key -out /certs/tls.crt -subj &quot;/CN=registry-proxy&quot;
</code></pre>
<p>When any pod that uses an image from this private registry tries to pull the image I get an error:</p>
<pre><code>x509: certificate signed by unknown authority
</code></pre>
<p>Is there any way to put the self signed certificate to all GKE nodes in the cluster to resolve the problem?</p>
<p>UPDATE</p>
<p>I put the CA certificate to each GKE node as @ArmandoCuevas recommended in his comment, but it doesn't help, still getting the error <code>x509: certificate signed by unknown authority</code>. What could cause it? How docker images are pulled into pods?</p>

<p>TL;DR: Almost all modifications you need to perform to nodes in GKE, like adding trusted root certificates to the server, can be done using Daemonsets.</p>
<p>There is an amazing guide that the user <a href="https://github.com/samos123" rel="nofollow noreferrer">Sam Stoelinga</a> created about how to perform what you are looking to do. The link can be found <a href="https://github.com/samos123/gke-node-customizations#2-deploy-daemonset-to-insert-ca-on-gke-nodes" rel="nofollow noreferrer">here</a>.</p>
<p>As a summary, the way Sam propose how to perform this changes is by distributing the cert in each of the nodes by using a Daemonsets. Since the Daemonsets guarantees that there is 1 pod on each of the nodes always, the POD will be in charge of adding your certificate to the node so you can pull your images from the private registry.</p>
<p>Normally adding the node by your own will not work since if GKE needs to recreate the node you change will be lost. This approach of using DS guarantees that even if the node is recreated, since the Daemonset will schedule one of this &quot;overhaul pod&quot; in the node, you will always going to have the cert in place.</p>
<p>The steps that Sam proposed are very simple:</p>
<ol>
<li>Create an image that with the commands needed to distribute the certificate. This step may be different if you are using Ubuntu nodes or COS nodes. If you are using COS nodes, the commands that your pod needs to run if you are using COS are perfectly outlined by SAM:</li>
</ol>
<pre><code>cp /myCA.pem /mnt/etc/ssl/certs
nsenter --target 1 --mount update-ca-certificates
nsenter --target 1 --mount systemctl restart docker
</code></pre>
<p>If you are running Ubuntu nodes, the commands are outlined in several posts in Ask Ubuntu like <a href="https://askubuntu.com/questions/73287/how-do-i-install-a-root-certificate">this one</a>.</p>
<ol start="2">
<li><p>Move the image to a container registry that your nodes currently have access like <a href="https://cloud.google.com/container-registry" rel="nofollow noreferrer">GCR</a>.</p>
</li>
<li><p>Deploy the DS using the image that adds the cert as privileged with the NET_ADMIN capability (needed to perform this operation) and mount host's &quot;/etc&quot; folder inside the POD. Sam added an example of doing this that may help, but you can use your own definition.
If you face problems while trying to deploy a privileged pod, may worth taking a look to GKE documentation about <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/pod-security-policies" rel="nofollow noreferrer">Using PodSecurityPolicies</a></p>
</li>
</ol>
