<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eugene Zaidun on Medium]]></title>
        <description><![CDATA[Stories by Eugene Zaidun on Medium]]></description>
        <link>https://medium.com/@evgeniyzaydun?source=rss-8afe6e79d9cf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*7vX8LdbegF7WKguI.</url>
            <title>Stories by Eugene Zaidun on Medium</title>
            <link>https://medium.com/@evgeniyzaydun?source=rss-8afe6e79d9cf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 07:33:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@evgeniyzaydun/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Connecting to Docker Desktop Kubernetes Remotely: A Guide for Development Purposes]]></title>
            <link>https://medium.com/@evgeniyzaydun/connecting-to-docker-desktop-kubernetes-remotely-a-guide-for-development-purposes-11cd2bc5c474?source=rss-8afe6e79d9cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/11cd2bc5c474</guid>
            <category><![CDATA[kubernetes-api]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kube-api-server]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[kubectl]]></category>
            <dc:creator><![CDATA[Eugene Zaidun]]></dc:creator>
            <pubDate>Wed, 03 Jan 2024 13:37:57 GMT</pubDate>
            <atom:updated>2024-01-03T13:37:57.452Z</atom:updated>
            <content:encoded><![CDATA[<p>In the ever-evolving landscape of software development, the necessity of remotely connecting to Docker Desktop Kubernetes centers around the straightforward need to access computational resources in your environment. To access the remote Kubernetes API server, we will regenerate the certificate and private key and adjust the API server’s bootstrap command to include a static token file with remote user credentials.</p><blockquote>S<em>ince this guide involves multiple steps of copying file content from one container and pasting it into another, each step indicates where the action should be executed, </em><strong><em>ex.: [You host os]</em></strong><em>. This ensures a seamless and error-free proce</em>ss.</blockquote><ol><li><strong>[Your host os -&gt; Docker setting]</strong></li></ol><ul><li>Enable Kubernetes in your Docker Desktop settings.</li></ul><p>2.<strong> [Your host os -&gt; Browser -&gt; Router Web Admin]</strong></p><ul><li>Configure your router, specific to its vendor settings, to expose traffic on port <strong>6444</strong> to the internet. This step is crucial for enabling remote access to your system and may vary depending on the make and model of your router.</li></ul><p>3. <strong>[Your host os -&gt; Terminal]</strong></p><pre>docker run -d -p 0.0.0.0:6444:6443 bobrik/socat TCP-LISTEN:6443,fork TCP:docker-desktop:6443</pre><ul><li>The command creates a Docker container to set up a TCP proxy to forward traffic from a local machine to the Docker Desktop&#39;s Kubernetes API server.</li></ul><p><strong>4. [Your host os -&gt; Terminal]</strong></p><pre>openssl s_client -connect YOUR_PUBLIC_IP:6444 -showcerts &lt;/dev/null 2&gt;/dev/null | \<br>openssl x509 -text -noout | \<br>awk &#39;/X509v3 Subject Alternative Name:/{flag=1; next} /X509v3/{flag=0} flag&#39;</pre><ul><li>This command is used to verify if the proxy is functioning correctly, allowing access to the Kubernetes API server, and to ensure that <strong>your IP address</strong> is not currently listed among the managed addresses, which will be addressed in subsequent steps.</li><li>The output will appear as follows:</li></ul><pre>DNS:7642d5b648b2, DNS:docker-for-desktop, DNS:kubernetes, DNS:kubernetes.default, DNS:kubernetes.default.svc, DNS:kubernetes.default.svc.cluster.local, DNS:kubernetes.docker.internal, DNS:localhost, DNS:vm.docker.internal, IP Address:10.96.0.1, IP Address:172.17.0.4, IP Address:0.0.0.0, IP Address:127.0.0.1, IP Address:192.168.65.3</pre><ul><li>Based on the output, you need to prepare the next command, which we will use later, align it with your response from the previous command, and add <strong>YOUR_PUBIC_IP</strong> as the last parameter:</li></ul><pre>kubeadm init phase certs apiserver \<br>--apiserver-cert-extra-sans docker-for-desktop \<br>--apiserver-cert-extra-sans kubernetes \<br>--apiserver-cert-extra-sans kubernetes.default \<br>--apiserver-cert-extra-sans kubernetes.default.svc \<br>--apiserver-cert-extra-sans kubernetes.default.svc.cluster.local \<br>--apiserver-cert-extra-sans kubernetes.docker.internal \<br>--apiserver-cert-extra-sans localhost \<br>--apiserver-cert-extra-sans vm.docker.internal \<br>--apiserver-cert-extra-sans 10.96.0.1 \<br>--apiserver-cert-extra-sans 0.0.0.0 \<br>--apiserver-cert-extra-sans 127.0.0.1 \<br>--apiserver-cert-extra-sans 192.168.65.3 \<br>--apiserver-cert-extra-sans YOUR_PUBLIC_IP</pre><p>5. <strong>[Your host os -&gt; Terminal]</strong></p><pre>docker run -it --rm --privileged --pid=host justincormack/nsenter1  </pre><ul><li>This command opens an interactive terminal session with privileged access to the host’s namespaces, including PID, network, and file system. It’s crucial for performing administrative tasks directly on the host machine from within the container. Keep this terminal session open until you have completed all the steps in the guide, as it will be used for executing several critical commands. Let&#39;s mark it as — <strong>HostAdminShell </strong>container.</li></ul><p>6. <strong>[Your host os -&gt; Terminal]</strong></p><pre>docker run -it --rm ubuntu bash  </pre><ul><li>This command opens an interactive terminal session to the Ubuntu container in which we will generate a new Kubernetes API server certificate. Same, keep it open until the end. Let&#39;s call it — <strong>HostCertShell </strong>container</li></ul><p>7. <strong>[Your host os -&gt; Terminal -&gt; HostCertShell]</strong></p><pre>apt-get update<br>apt-get install -y apt-transport-https ca-certificates curl gpg<br>curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg<br>echo &#39;deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /&#39; | tee /etc/apt/sources.list.d/kubernetes.list<br>apt-get update<br>apt-get install -y kubeadm<br>mkdir -p /etc/kubernetes/pki<br>cd /etc/kubernetes/pki</pre><ul><li>These commands install kubeadm, which will be used for certificate generation.</li></ul><p>8. <strong>[Your host os -&gt; Terminal -&gt; HostCertShell]</strong></p><pre>cat &lt;&lt;EOF&gt; /etc/kubernetes/pki/ca.crt<br>...<br>EOF</pre><ul><li>Replace ... with the content from the /run/config/pki/ca.crt file, which was copied in the HostAdminShell container using the following command:</li></ul><pre># [Your host os -&gt; Terminal -&gt; HostAdminShell]<br>cat /run/config/pki/ca.crt</pre><p>Repeating the same action for /run/config/pki/ca.key</p><pre>cat &lt;&lt;EOF&gt; /etc/kubernetes/pki/ca.key<br>...<br>EOF</pre><pre># [Your host os -&gt; Terminal -&gt; HostAdminShell]<br>cat /run/config/pki/ca.key</pre><p>9. <strong>[Your host os -&gt; Terminal -&gt; HostCertShell]</strong></p><pre>kubeadm init phase certs apiserver \<br>--apiserver-cert-extra-sans docker-for-desktop \<br>--apiserver-cert-extra-sans kubernetes \<br>--apiserver-cert-extra-sans kubernetes.default \<br>--apiserver-cert-extra-sans kubernetes.default.svc \<br>--apiserver-cert-extra-sans kubernetes.default.svc.cluster.local \<br>--apiserver-cert-extra-sans kubernetes.docker.internal \<br>--apiserver-cert-extra-sans localhost \<br>--apiserver-cert-extra-sans vm.docker.internal \<br>--apiserver-cert-extra-sans 10.96.0.1 \<br>--apiserver-cert-extra-sans 0.0.0.0 \<br>--apiserver-cert-extra-sans 127.0.0.1 \<br>--apiserver-cert-extra-sans 192.168.65.3 \<br>--apiserver-cert-extra-sans YOUR_PUBLIC_IP</pre><ul><li>Let&#39;s execute the earlier prepared command in the <strong>HostCertShell </strong>container. As a result, we will get apiserver.key and apiserver.crtgenerated in /etc/kubernetes/pki</li></ul><p>10. <strong>[Your host os -&gt; Terminal -&gt; HostAdminShell]</strong></p><ul><li>Replace /run/config/pki/apiserver.crt and /run/config/pki/apiserver.key with the content generated in the previous step from the HostCertShell container.</li></ul><pre>cat &lt;&lt;EOF&gt; /run/config/pki/apiserver.crt<br>...<br>EOF<br><br>cat &lt;&lt;EOF&gt; /run/config/pki/apiserver.key<br>...<br>EOF</pre><ul><li>Work out …dots.</li></ul><p>11. <strong>[Your host os -&gt; Terminal -&gt; HostAdminShell]</strong></p><pre>cat &lt;&lt;EOF&gt;/run/config/pki/tokens.csv<br>token,docker-desktop-remote-user,2,&quot;system:masters&quot;<br>EOF</pre><ul><li>Please refer to the <a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/">official documentation</a> for more information about the static token file authorization flow.</li></ul><p>12. <strong>[Your host os -&gt; Terminal -&gt; HostAdminShell]</strong></p><pre>cat /etc/kubernetes/manifests/kube-apiserver.yaml</pre><ul><li>Copy the content of the static Kubernetes API server definition into your editor and modify it by adding:</li></ul><pre>  ...<br>  - command:<br>    - kube-apiserver<br>    - --advertise-address=192.168.65.3<br>    - --allow-privileged=true<br>    - --authorization-mode=Node,RBAC<br>    ...<br>    - --token-auth-file=/run/config/pki/tokens.csv # here it is<br>...</pre><ul><li>Update /etc/kubernetes/manifests/kube-apiserver.yaml using the following command with content from your editor:</li></ul><pre>cat &lt;&lt;EOF&gt; /etc/kubernetes/manifests/kube-apiserver.yaml<br>...<br>EOF</pre><ul><li>Since we have modified the static pod definition, the Kubernetes system will update it automatically; it is unnecessary to restart it manually.</li></ul><p>13. <strong>[Your remote os -&gt; Terminal]</strong></p><ul><li>Be sure you have installed kubectl on your remote host and /Users/YOUR_USER/.kube/ has been created in which you need to store ca.crt from <strong>HostAdminShell </strong>container. You can use the following command to get the content of it:</li></ul><pre>cat /run/config/pki/ca.crt</pre><ul><li>Paste the content into /Users/YOUR_USER/kube/docker-desktop-remote-ca.crt</li><li>Lastly, you need to instruct kubectl how to connect to remove cluster</li></ul><pre>kubectl config set-cluster docker-decktop-remote --server=https://YOUR_PUBLIC_ID:6444 --certificate-authority=/Users/YOUR_USER/.kube/docker-decktop-remote-ca.crt<br>kubectl config set-context docker-decktop-remote --cluster=docker-decktop-remote --user=docker-desktop-remote-user<br>kubectl config set-credentials docker-desktop-remote-user --token=token</pre><ul><li>Set user and token values according to the token.csv file</li></ul><p>14. <strong>[Your remote os -&gt; Terminal]</strong></p><pre>kubectl --context docker-decktop-remote get nodes</pre><ul><li>Validate and use your remote...</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11cd2bc5c474" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>