<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tak</title>
    <description>The latest articles on DEV Community by Tak (@tak0122).</description>
    <link>https://dev.to/tak0122</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4231530%2F6ea79d85-d46a-4396-ac6b-2376d633fecd.png</url>
      <title>DEV Community: Tak</title>
      <link>https://dev.to/tak0122</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tak0122"/>
    <language>en</language>
    <item>
      <title>Building a Lightweight Kubernetes Environment on K3s and the kubectl command on WSL2 Windows 11</title>
      <dc:creator>Tak</dc:creator>
      <pubDate>Tue, 10 Nov 2026 12:00:00 +0000</pubDate>
      <link>https://dev.to/tak0122/building-a-lightweight-kubernetes-environment-on-k3s-and-the-kubectl-command-on-wsl2-windows-11-9pc</link>
      <guid>https://dev.to/tak0122/building-a-lightweight-kubernetes-environment-on-k3s-and-the-kubectl-command-on-wsl2-windows-11-9pc</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Step 1: Installation of K3s on Google Cloud&lt;/li&gt;
&lt;li&gt;Step 2: Installation of kubectl command on WSL2 Windows 11&lt;/li&gt;
&lt;li&gt;
Step 3: kubectl commands gets the response from K3s &lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A. Book: Kubernetes and Helm: A Primer&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Introduction &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;When you start learning Kubernetes and Helm in your local environment, you often struggle to install the software stack. This brief tutorial explains the step-by-step instructions to build a lightweight Kubernetes environment with &lt;strong&gt;K3s&lt;/strong&gt; on a Google VM and install the &lt;strong&gt;kubectl&lt;/strong&gt; command on WSL2 on Windows 11.&lt;/p&gt;

&lt;p&gt;Before you proceed to the following steps, you have already installed Ubuntu on a Google Cloud VM (e.g., 2 vCPU, 6GB memory, 50GB SSD) and Ubuntu on WSL2 on Windows 11. They are connected via the network. The detailed step-by-step guide for preparing the computing environments for the client and server and installing microservice applications is referred to in &lt;strong&gt;the book section&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Step 1: Installation of K3s on Google Cloud &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Before you install K3s on Ubuntu VM on Google Cloud, you check the version and release number of the operating system with the "&lt;strong&gt;cat /etc/os-release&lt;/strong&gt;" command in &lt;strong&gt;Listing 1&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;Listing 1: Operating System version&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@rookie-gc-ubuntu-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /etc/os-release
&lt;span class="nv"&gt;PRETTY_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Ubuntu 26.04 LTS"&lt;/span&gt;
&lt;span class="nv"&gt;NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Ubuntu"&lt;/span&gt;
&lt;span class="nv"&gt;VERSION_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"26.04"&lt;/span&gt;
&lt;span class="nv"&gt;VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"26.04 LTS (Resolute Raccoon)"&lt;/span&gt;
&lt;span class="nv"&gt;VERSION_CODENAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;resolute
...
...
...
rookie@rookie-gc-ubuntu-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You can also check the available memory and swap space using the &lt;em&gt;free&lt;/em&gt; command in &lt;strong&gt;Listing 2&lt;/strong&gt;. As shown in the output, the system has a total memory of approximately &lt;strong&gt;6 GB&lt;/strong&gt; (6,059,484 KiB), with around &lt;strong&gt;5.2 GB&lt;/strong&gt; (5,217,884 KiB) available. The "Swap: 0 0 0" line confirms that &lt;strong&gt;no swap space&lt;/strong&gt; is currently configured on the system.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 2: Check memory size and the swap file&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@rookie-gc-ubuntu-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;free
               total        used        free      shared  buff/cache   available
Mem:         6059484      495828     5217884         984      587048     5563656
Swap:              0           0           0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Before installing K3s on Ubuntu, run the "&lt;strong&gt;which kubectl&lt;/strong&gt;" command to check whether the &lt;em&gt;kubectl&lt;/em&gt; binary file is already installed. As shown in &lt;strong&gt;Listing 3&lt;/strong&gt;, the &lt;em&gt;which&lt;/em&gt; command returns no output, confirming that the &lt;em&gt;kubectl&lt;/em&gt; binary file is not yet present on the system.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 3: which kubectl (1)&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@rookie-gc-ubuntu-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;which kubectl
rookie@rookie-gc-ubuntu-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Installing K3s requires only a few simple steps. For a first-time installation, you can follow &lt;a href="https://docs.k3s.io/quick-start" rel="noopener noreferrer"&gt;the official Quick Start Guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Run the installation script as shown in &lt;strong&gt;Listing 4&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;curl -sfL &lt;a href="https://get.k3s.io" rel="noopener noreferrer"&gt;https://get.k3s.io&lt;/a&gt; | sh -s - server &lt;code&gt;--&lt;/code&gt;tls-san s.s.s.s&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Be sure to include the "&lt;code&gt;--tls-san s.s.s.s&lt;/code&gt;" option, replacing &lt;em&gt;s.s.s.s&lt;/em&gt; (IPv4 address) with the external IPv4 address of your VM on Google Cloud. This parameter adds the external IPv4 address to the TLS certificate's Subject Alternative Names (SAN). This step is essential because VM instances on Google Cloud assign internal IPv4 addresses to their local network interfaces, which differ from their public-facing external IPv4 addresses.&lt;/p&gt;

&lt;p&gt;Once command execution is complete, the K3s server will be fully installed and operational.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 4: K3s installation&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@rookie-gc-ubuntu-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-sfL&lt;/span&gt; https://get.k3s.io | sh &lt;span class="nt"&gt;-s&lt;/span&gt; - server &lt;span class="nt"&gt;--tls-san&lt;/span&gt; s.s.s.s
&lt;span class="o"&gt;[&lt;/span&gt;INFO]  Finding release &lt;span class="k"&gt;for &lt;/span&gt;channel stable
&lt;span class="o"&gt;[&lt;/span&gt;INFO]  Using v1.35.5+k3s1 as release
...
...
...
&lt;span class="o"&gt;[&lt;/span&gt;INFO]  systemd: Starting k3s
rookie@rookie-gc-ubuntu-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After installing K3s, run the "&lt;strong&gt;which kubectl&lt;/strong&gt;" command again to verify the installation. As shown in &lt;strong&gt;Listing 5&lt;/strong&gt;, the command returns "/usr/local/bin/kubectl" message, confirming that the &lt;em&gt;kubectl&lt;/em&gt; binary file was automatically installed alongside K3s.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 5: which kubectl (2)&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@rookie-gc-ubuntu-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;which kubectl
/usr/local/bin/kubectl
rookie@rookie-gc-ubuntu-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Next, run the "&lt;strong&gt;sudo kubectl get node&lt;/strong&gt;" command to check the status of the installed K3s node in &lt;strong&gt;Listing 6&lt;/strong&gt;. The output displays the "Ready" under the "&lt;strong&gt;STATUS&lt;/strong&gt;" column, confirming that the node is active and prepared to handle workloads. K3s has been successfully installed on your Ubuntu VM on Google Cloud in &lt;strong&gt;Listing 6&lt;/strong&gt;. Your installed K3s version may differ from "v1.35.5+k3s1", as the latest version of K3s will be installed on your Ubuntu VM in Google Cloud.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 6: kubectl get node&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@rookie-gc-ubuntu-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;kubectl get nodes
NAME                 STATUS   ROLES           AGE     VERSION
rookie-gc-ubuntu-1   Ready    control-plane   1m34s   v1.35.5+k3s1
rookie@rookie-gc-ubuntu-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Copy the &lt;em&gt;k3s.yaml&lt;/em&gt; configuration file to your home directory and update its file ownership, as shown in &lt;strong&gt;Listing 7&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 7: Copy k3s.yaml and change owner of the file&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@rookie-gc-ubuntu-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo cp&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /etc/rancher/k3s/k3s.yaml ~/
rookie@rookie-gc-ubuntu-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo chown &lt;/span&gt;rookie:rookie ~/k3s.yaml
rookie@rookie-gc-ubuntu-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
total 4
&lt;span class="nt"&gt;-rw-------&lt;/span&gt; 1 rookie rookie 2945 Jun  3 14:00 k3s.yaml
rookie@rookie-gc-ubuntu-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Step 2: Installation of kubectl command on WSL2 Windows 11  &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;At first, run the &lt;em&gt;mkdir&lt;/em&gt; and &lt;em&gt;chmod&lt;/em&gt; commands shown in &lt;strong&gt;Listing 8&lt;/strong&gt; to create and secure the "~/.kube" directory for your Kubernetes configuration file.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 8: Make the directory and change the mode&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/.kube
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; ~/.kube
drwxr-xr-x 2 rookie rookie 4096 Jun  5 00:48 /home/rookie/.kube
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;700 ~/.kube
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; ~/.kube
drwx------ 2 rookie rookie 4096 Jun  5 00:48 /home/rookie/.kube
rookie@Tak-Win11-Pro-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Next, run the following &lt;em&gt;scp&lt;/em&gt; command, which is also shown in &lt;strong&gt;Listing 9&lt;/strong&gt;, to copy the &lt;em&gt;k3s.yaml&lt;/em&gt; file from the Ubuntu VM on Google Cloud to your Ubuntu WSL2 on Windows 11.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;scp -p s.s.s.s:~/k3s.yaml ~/.kube/config&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;em&gt;k3s.yaml&lt;/em&gt; file of K3s is already copied in the home directory since you have completed in the previous chapter.&lt;/p&gt;

&lt;p&gt;In the &lt;em&gt;scp&lt;/em&gt; command, replace &lt;em&gt;s.s.s.s&lt;/em&gt; with the external IPv4 address of your Ubuntu VM on Google Cloud. Notice that the file is renamed from &lt;em&gt;k3s.yaml&lt;/em&gt; to &lt;em&gt;config&lt;/em&gt; during the transfer, as the &lt;em&gt;kubectl&lt;/em&gt; CLI automatically searches for its default configuration at "~/.kube/config".&lt;/p&gt;

&lt;p&gt;After copying the file, remove the &lt;em&gt;k3s.yaml&lt;/em&gt; file on your Ubuntu VM on Google Cloud using the &lt;em&gt;ssh&lt;/em&gt; command in &lt;strong&gt;Listing 9&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 9: scp command to copy k3s.yaml to config&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;scp &lt;span class="nt"&gt;-p&lt;/span&gt; s.s.s.s:~/k3s.yaml ~/.kube/config
k3s.yaml                                                                              100% 2945    11.5KB/s   00:00
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; ~/.kube/config
&lt;span class="nt"&gt;-rw-------&lt;/span&gt; 1 rookie rookie 2945 Jun  5 00:34 /home/rookie/.kube/config
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;ssh s.s.s.s &lt;span class="nb"&gt;ls
&lt;/span&gt;k3s.yaml
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;ssh s.s.s.s &lt;span class="nb"&gt;rm &lt;/span&gt;k3s.yaml
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;ssh s.s.s.s &lt;span class="nb"&gt;ls
&lt;/span&gt;rookie@Tak-Win11-Pro-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Next, verify that your K3s server is running properly by sending a request to TCP port 6443 using the &lt;em&gt;curl&lt;/em&gt; command in &lt;strong&gt;Listing 10&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Note that TCP port 6443 is the standard port for the K3s API server. When the command returns the response ("message": "Unauthorized") in &lt;strong&gt;Listing 10&lt;/strong&gt;, this is expected and confirms that the &lt;em&gt;curl&lt;/em&gt; command for the connection is working correctly and your K3s server is accessible. This step in &lt;strong&gt;Listing 10&lt;/strong&gt; simply verifies the network connectivity to the K3s server on your Ubuntu VM on Google Cloud.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 10: Check k3s server with curl command&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-k&lt;/span&gt; https://s.s.s.s:6443/
&lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"kind"&lt;/span&gt;: &lt;span class="s2"&gt;"Status"&lt;/span&gt;,
  &lt;span class="s2"&gt;"apiVersion"&lt;/span&gt;: &lt;span class="s2"&gt;"v1"&lt;/span&gt;,
  &lt;span class="s2"&gt;"metadata"&lt;/span&gt;: &lt;span class="o"&gt;{}&lt;/span&gt;,
  &lt;span class="s2"&gt;"status"&lt;/span&gt;: &lt;span class="s2"&gt;"Failure"&lt;/span&gt;,
  &lt;span class="s2"&gt;"message"&lt;/span&gt;: &lt;span class="s2"&gt;"Unauthorized"&lt;/span&gt;,
  &lt;span class="s2"&gt;"reason"&lt;/span&gt;: &lt;span class="s2"&gt;"Unauthorized"&lt;/span&gt;,
  &lt;span class="s2"&gt;"code"&lt;/span&gt;: 401
&lt;span class="o"&gt;}&lt;/span&gt;rookie@Tak-Win11-Pro-1:~&lt;span class="err"&gt;$&lt;/span&gt;
rookie@Tak-Win11-Pro-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Finally, update the K3s server IPv4 address in your "~/.kube/config" configuration file in &lt;strong&gt;Listing 11&lt;/strong&gt;. By default, the configuration file currently uses 127.0.0.1 (which is the localhost address). Change 127.0.0.1 to &lt;em&gt;s.s.s.s&lt;/em&gt; using the "&lt;strong&gt;sed -i s/127.0.0.1/s.s.s.s/ ~/.kube/config&lt;/strong&gt;" command so that the &lt;em&gt;kubectl&lt;/em&gt; CLI connects to the K3s cluster in your Ubuntu VM on Google Cloud instead of the localhost address in &lt;strong&gt;Listing 11&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To confirm that the external IPv4 address was updated successfully, run the "&lt;strong&gt;egrep s.s.s.s ~/.kube/config&lt;/strong&gt;" command as shown in &lt;strong&gt;Listing 11&lt;/strong&gt;. When this change was applied correctly, you will see output like "server: &lt;a href="https://s.s.s.s:6443" rel="noopener noreferrer"&gt;https://s.s.s.s:6443&lt;/a&gt;" message.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 11: Update IPv4 address in the configuration file&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;egrep 127.0.0.1 ~/.kube/config
    server: https://127.0.0.1:6443
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; s/127.0.0.1/s.s.s.s/ ~/.kube/config
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;egrep s.s.s.s ~/.kube/config
    server: https://s.s.s.s:6443
rookie@Tak-Win11-Pro-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Step 3: kubectl commands gets the response from K3s &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;You will install the &lt;em&gt;kubectl&lt;/em&gt; command-line tool used to manage the K3s cluster from Ubuntu WSL2 in Windows 11. Follow &lt;a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/" rel="noopener noreferrer"&gt;the official Kubernetes documentation&lt;/a&gt; for detailed installation instructions.&lt;/p&gt;

&lt;p&gt;First, download the &lt;em&gt;kubectl&lt;/em&gt; binary file and its corresponding checksum file (&lt;em&gt;kubectl.sha256&lt;/em&gt;), using the &lt;em&gt;curl&lt;/em&gt; commands as shown in &lt;strong&gt;Listing 12&lt;/strong&gt;. Since your Ubuntu WSL2 environment uses the x86-64 architecture, make sure to download the files corresponding to "x86-64 (amd64)." After downloading, verify the integrity of the binary file using the following &lt;em&gt;echo&lt;/em&gt; and &lt;em&gt;sha256sum&lt;/em&gt; commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;echo "$(cat kubectl.sha256)  kubectl" | sha256sum &lt;code&gt;--&lt;/code&gt;check&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When this verification succeeds, you will see the "kubectl: OK" message in &lt;strong&gt;Listing 12&lt;/strong&gt;. This confirms that the downloaded &lt;em&gt;kubectl&lt;/em&gt; binary file is intact and safe to use.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 12: Download kubectl binary file and its checksum file&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-LO&lt;/span&gt; &lt;span class="s2"&gt;"https://dl.k8s.io/release/&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-L&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; https://dl.k8s.io/release/stable.txt&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/bin/linux/amd64/kubectl"&lt;/span&gt;

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 56.7M  100 56.7M    0     0  10.9M      0  0:00:05  0:00:05 &lt;span class="nt"&gt;--&lt;/span&gt;:--:-- 11.0M
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-LO&lt;/span&gt; &lt;span class="s2"&gt;"https://dl.k8s.io/release/&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-L&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; https://dl.k8s.io/release/stable.txt&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/bin/linux/amd64/kubectl.sha256"&lt;/span&gt;
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    64  100    64    0     0    964      0 &lt;span class="nt"&gt;--&lt;/span&gt;:--:-- &lt;span class="nt"&gt;--&lt;/span&gt;:--:-- &lt;span class="nt"&gt;--&lt;/span&gt;:--:--   984
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;kubectl.sha256&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;  kubectl"&lt;/span&gt; | &lt;span class="nb"&gt;sha256sum&lt;/span&gt; &lt;span class="nt"&gt;--check&lt;/span&gt;
kubectl: OK
rookie@Tak-Win11-Pro-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Next, install the &lt;em&gt;kubectl&lt;/em&gt; binary file to your Ubuntu WSL2 environment&lt;br&gt;
using the &lt;em&gt;install&lt;/em&gt; command in &lt;strong&gt;Listing 13&lt;/strong&gt;. Note that because this command uses the &lt;em&gt;sudo&lt;/em&gt; command.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This command places the &lt;em&gt;kubectl&lt;/em&gt; binary file into the "/usr/local/bin/" directory while setting the owner to &lt;em&gt;root&lt;/em&gt;, the group to &lt;em&gt;root&lt;/em&gt;, and the file permissions (mode) to &lt;em&gt;0755&lt;/em&gt; so that it can be executed by any user.&lt;/p&gt;

&lt;p&gt;To confirm that the permissions and ownership are configured correctly, check the file details with the "&lt;strong&gt;ls -l /usr/local/bin/kubectl&lt;/strong&gt;" command&lt;br&gt;
in &lt;strong&gt;Listing 13&lt;/strong&gt;. You see the permission of the &lt;em&gt;kubectl&lt;/em&gt; file with its output.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 13: Install kubectl command&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo install&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; root &lt;span class="nt"&gt;-g&lt;/span&gt; root &lt;span class="nt"&gt;-m&lt;/span&gt; 0755 kubectl /usr/local/bin/kubectl
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; password &lt;span class="k"&gt;for &lt;/span&gt;rookie:
rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; /usr/local/bin/kubectl
&lt;span class="nt"&gt;-rwxr-xr-x&lt;/span&gt; 1 root root 59502754 Jun  5 00:59 /usr/local/bin/kubectl
rookie@Tak-Win11-Pro-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Finally, run the "&lt;strong&gt;kubectl get nodes&lt;/strong&gt;" command to verify that your K3s cluster is operational in &lt;strong&gt;Listing 14&lt;/strong&gt;. When everything is configured correctly, you will see a list of Kubernetes nodes in the terminal in &lt;strong&gt;Listing 14&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Note that in this output in &lt;strong&gt;Listing 14&lt;/strong&gt;, the K3s version is also displayed as "v1.35.5+k3s1". Because K3s is updated frequently, the version and the release number in your output may differ slightly. It will be the latest version of K3s.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;Listing 14: kubectl get nodes command on WSL2&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rookie@Tak-Win11-Pro-1:~&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get nodes
NAME                 STATUS   ROLES           AGE   VERSION
rookie-gc-ubuntu-1   Ready    control-plane   25m   v1.35.5+k3s1
rookie@Tak-Win11-Pro-1:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Conclusion  &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Now you have a lightweight Kubernetes environment up and running! If you want to review these setup steps in detail or dive deeper into Pods, Deployments, Services, Persistent Volume Claims (PVCs), and package management with Helm, check out the book below:&lt;/p&gt;
&lt;h2&gt;
  
  
  Book:&lt;a href="https://www.amazon.com/dp/B0HQ5QPP5L" rel="noopener noreferrer"&gt;&lt;strong&gt;Kubernetes and Helm: A Prime&lt;/strong&gt;&lt;/a&gt;&lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;This tutorial is an excerpt from the 563-page hands-on book, 📖"&lt;a href="https://www.amazon.com/dp/B0HQ5QPP5L" rel="noopener noreferrer"&gt;&lt;strong&gt;Kubernetes and Helm: A Primer&lt;/strong&gt;&lt;/a&gt;", available on Amazon. The book offers comprehensive, step-by-step instructions for building a K3s cluster on Google Cloud, configuring the kubectl command on WSL2 (Windows 11), and orchestrating microservices for applications using both kubectl and helm commands.&lt;/p&gt;

&lt;p&gt;Whether you are a software developer, SRE beginner, or college/university student, this hands-on book walks you through setting up your own computing environment, deploying real-world applications (including NGINX, WordPress, Drupal, Redis, and Nextcloud), and mastering Helm using hundreds of working terminal outputs and production-ready YAML manifests.&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body flex items-center justify-between"&gt;
        &lt;a href="https://www.amazon.com/dp/B0HQ5QPP5L" rel="noopener noreferrer" class="c-link fw-bold flex items-center"&gt;
          &lt;span class="mr-2"&gt;amazon.com&lt;/span&gt;
          

        &lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>ubuntu</category>
      <category>cloudnative</category>
    </item>
  </channel>
</rss>
