<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Kubernetes on K-Life Hack | Seoul Gastronomy &amp; Travel Guide</title><link>https://klifehack.com/en/tags/kubernetes/</link><description>Recent content in Kubernetes on K-Life Hack | Seoul Gastronomy &amp; Travel Guide</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Fri, 22 May 2026 13:53:13 +0900</lastBuildDate><atom:link href="https://klifehack.com/en/tags/kubernetes/index.xml" rel="self" type="application/rss+xml"/><item><title>Troubleshooting Errors in Kubernetes Deployment Automation with GitHub Actions and Windows Self-Hosted Runner</title><link>https://klifehack.com/en/p/github-actions-windows-runner-kubernetes/</link><pubDate>Fri, 22 May 2026 13:53:13 +0900</pubDate><guid>https://klifehack.com/en/p/github-actions-windows-runner-kubernetes/</guid><description>&lt;h2 id="-resolving-kubeconfig-pem-block-parsing-error-unable-to-parse-bytes-as-pem-block"&gt;🛠️ Resolving Kubeconfig PEM Block Parsing Error (unable to parse bytes as PEM block)
&lt;/h2&gt;&lt;p&gt;The following error occurred during authentication with the Kubernetes cluster when running the GitHub Actions workflow:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;error: unable to load root certificates: unable to parse bytes as PEM block
Error: Process completed with exit code 1.
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="cause"&gt;Cause
&lt;/h3&gt;&lt;p&gt;When copying and pasting the YAML text of the local &lt;b&gt;&lt;mark&gt;kubeconfig&lt;/mark&gt;&lt;/b&gt; file directly into GitHub Secrets, line ending mismatches (\n vs \r\n), indentation issues, or truncation of the Base64-encoded certificate data occurred, causing the certificate data (PEM format) parsing to fail.&lt;/p&gt;
&lt;h3 id="resolution"&gt;Resolution
&lt;/h3&gt;&lt;p&gt;To prevent data corruption, encode the Windows environment&amp;rsquo;s kubeconfig file into a Base64 string before registering it in GitHub Secrets.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open PowerShell on Windows and run the following command to Base64-encode the kubeconfig:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;[&lt;span style="color:#66d9ef"&gt;Convert&lt;/span&gt;]::ToBase64String([&lt;span style="color:#66d9ef"&gt;IO.File&lt;/span&gt;]::ReadAllBytes(&lt;span style="color:#e6db74"&gt;&amp;#34;C:\Users\Administrator\.kube\config&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Copy the outputted single-line long Base64 string.&lt;/p&gt;
&lt;ol start="2"&gt;
&lt;li&gt;
&lt;p&gt;In the GitHub repository, go to &amp;ldquo;Settings&amp;rdquo; -&amp;gt; &amp;ldquo;Secrets and variables&amp;rdquo; -&amp;gt; &amp;ldquo;Actions&amp;rdquo;, delete the existing &lt;code&gt;KUBE_CONFIG&lt;/code&gt;, and register the copied Base64 string as the new value.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Modify the decoding process in the workflow file (&lt;code&gt;.github/workflows/docker-build.yml&lt;/code&gt;) as follows:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;Set kube config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;run&lt;/span&gt;: |&lt;span style="color:#e6db74"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; mkdir -p ~/.kube
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; echo &amp;#34;${{ secrets.KUBE_CONFIG }}&amp;#34; | base64 -d &amp;amp;gt; ~/.kube/config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;
&lt;h2 id="-resolving-dns-resolution-failure-from-cloud-runner-kubernetesdockerinternal6443-no-such-host"&gt;🛠️ Resolving DNS Resolution Failure from Cloud Runner (kubernetes.docker.internal:6443: no such host)
&lt;/h2&gt;&lt;p&gt;After resolving the certificate error, the following network timeout and DNS resolution error occurred during the deployment step:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;E0528 01:43:09.437587 2260 memcache.go:265] &amp;#34;Unhandled Error&amp;#34; err=&amp;#34;couldn&amp;#39;t get current server API group list: Get \&amp;#34;https://kubernetes.docker.internal:6443/api?timeout=32s\&amp;#34;: dial tcp: lookup kubernetes.docker.internal on 127.0.0.53:53: no such host&amp;#34;
Unable to connect to the server: dial tcp: lookup kubernetes.docker.internal on 127.0.0.53:53: no such host
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="cause-1"&gt;Cause
&lt;/h3&gt;&lt;p&gt;The standard GitHub Actions hosted runner (&lt;code&gt;runs-on: ubuntu-latest&lt;/code&gt;) runs on a cloud virtual machine provided by GitHub. Consequently, it cannot resolve &lt;code&gt;kubernetes.docker.internal&lt;/code&gt;, which is the private DNS of the local development environment (Docker Desktop), and cannot route to the local Kubernetes API server.&lt;/p&gt;
&lt;h3 id="resolution-1"&gt;Resolution
&lt;/h3&gt;&lt;p&gt;To directly access resources within the local network, set up a &lt;b&gt;&lt;mark&gt;Self-Hosted Runner&lt;/mark&gt;&lt;/b&gt; on the local machine.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;In the GitHub repository, go to &amp;ldquo;Settings&amp;rdquo; -&amp;gt; &amp;ldquo;Actions&amp;rdquo; -&amp;gt; &amp;ldquo;Runners&amp;rdquo;, select &amp;ldquo;New self-hosted runner&amp;rdquo;, and specify &amp;ldquo;Windows&amp;rdquo; as the OS.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the following commands in local PowerShell to download and extract the runner package:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir actions-runner
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd actions-runner
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Invoke-WebRequest -Uri https&lt;span style="color:#960050;background-color:#1e0010"&gt;:&lt;/span&gt;//github.com/actions/runner/releases/download/v2.334.&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;/actions-runner-win-x64-&lt;span style="color:#ae81ff"&gt;2.334&lt;/span&gt;.0.zip -OutFile actions-runner-win-x64-&lt;span style="color:#ae81ff"&gt;2.334&lt;/span&gt;.0.zip
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Add-Type -AssemblyName System.IO.Compression.FileSystem
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;[&lt;span style="color:#66d9ef"&gt;System.IO.Compression.ZipFile&lt;/span&gt;]::ExtractToDirectory(&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$PWD&lt;span style="color:#e6db74"&gt;/actions-runner-win-x64-2.334.0.zip&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$PWD&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="3"&gt;
&lt;li&gt;Register the runner using the token displayed on the screen.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;.\config.cmd --url https&lt;span style="color:#960050;background-color:#1e0010"&gt;:&lt;/span&gt;//github.com/giturl-id/tomcat-k8s --token &amp;lt;your_token&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="4"&gt;
&lt;li&gt;Start the runner.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;.\run.cmd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="5"&gt;
&lt;li&gt;Modify the execution environment target in the workflow file.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Before&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;runs-on&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;ubuntu-latest&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# After&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;runs-on&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;self-hosted&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;
&lt;h2 id="-resolving-mkdir--p-command-execution-error-in-windows-environment"&gt;🛠️ Resolving mkdir -p Command Execution Error in Windows Environment
&lt;/h2&gt;&lt;p&gt;When switching the execution environment to the Windows Self-Hosted Runner, the following error occurred during the directory creation step:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;mkdir : An item with the specified name C:\Users\Administrator\.kube already exists.
At C:\study\tomcat\actions-runner\_work\_temp\836d0b14-98fc-4377-a457-faf5123b7885.ps1:2 char:1
+ mkdir -p ~/.kube
+ ~~~~~~~~~~~~~~~
 + CategoryInfo : ResourceExists: (C:\Users\Administrator\.kube:String) [New-Item], IOException
 + FullyQualifiedErrorId : DirectoryExist,Microsoft.PowerShell.Commands.NewItemCommand
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="cause-2"&gt;Cause
&lt;/h3&gt;&lt;p&gt;On a Windows Self-Hosted Runner, GitHub Actions steps run in PowerShell by default. In PowerShell, &lt;code&gt;mkdir&lt;/code&gt; is an alias for &lt;code&gt;New-Item -ItemType Directory&lt;/code&gt;, which does not support the &lt;code&gt;-p&lt;/code&gt; option. Additionally, if the target directory already exists, PowerShell throws an &lt;code&gt;IOException&lt;/code&gt; and terminates with exit code &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id="resolution-2"&gt;Resolution
&lt;/h3&gt;&lt;p&gt;Change the logic to use native PowerShell syntax to check for directory existence before creation. Also, handle the Base64 decoding entirely within PowerShell using .NET runtime features.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;Set kube config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;shell&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;powershell&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;run&lt;/span&gt;: |&lt;span style="color:#e6db74"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; if (!(Test-Path &amp;#34;$HOME\.kube&amp;#34;)) {
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; New-Item -ItemType Directory -Path &amp;#34;$HOME\.kube&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; [System.Text.Encoding]::UTF8.GetString(
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; [System.Convert]::FromBase64String(&amp;#34;${{ secrets.KUBE_CONFIG }}&amp;#34;)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; ) | Out-File &amp;#34;$HOME\.kube\config&amp;#34; -Encoding utf8&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;
&lt;h2 id="-resolving-kubernetes-pod-image-pull-error-errimagepull"&gt;🛠️ Resolving Kubernetes Pod Image Pull Error (ErrImagePull)
&lt;/h2&gt;&lt;p&gt;After executing the deployment, the pod status became &lt;code&gt;ErrImagePull&lt;/code&gt;, and the container failed to start.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kubectl get pods
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Output:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# NAME READY STATUS RESTARTS AGE&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# tomcat2-deployment-59d4ff8df8-cwwb2 0/1 ErrImagePull 0 9s&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="cause-3"&gt;Cause
&lt;/h3&gt;&lt;p&gt;Because &lt;code&gt;imagePullPolicy&lt;/code&gt; in the manifest file (&lt;code&gt;Deployment.yaml&lt;/code&gt;) is set to &lt;code&gt;Always&lt;/code&gt;, Kubernetes forces a query to the external registry (such as DockerHub) for the latest image, even if the image exists in the local Docker cache. If the image has not been pushed to the remote registry or credentials are missing, this pull process fails.&lt;/p&gt;
&lt;h3 id="resolution-3"&gt;Resolution
&lt;/h3&gt;&lt;p&gt;When using locally built images directly in a development environment, change &lt;code&gt;imagePullPolicy&lt;/code&gt; to &lt;code&gt;IfNotPresent&lt;/code&gt; to skip querying the external registry.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Modify the container definition in &lt;code&gt;Deployment.yaml&lt;/code&gt; as follows:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;spec&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;containers&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;tomcat&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;image&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;abungard/my-tomcat:latest&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;imagePullPolicy&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;IfNotPresent&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="2"&gt;
&lt;li&gt;Delete the existing deployment and reapply.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kubectl delete deployment tomcat2-deployment
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kubectl apply -f Deployment.yaml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="3"&gt;
&lt;li&gt;Verify the pod startup status.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kubectl get pods
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Verify that the status transitions to &lt;code&gt;Running&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;NAME READY STATUS RESTARTS AGE
tomcat2-deployment-59d4ff8df8-cwwb2 1/1 Running 0 12s
```&amp;lt;/your_token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;</description></item></channel></rss>