You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting Up The Kubernetes Tooling On Windows 10 WSL
Nowadays software is build mostly targeting Linux. Life is great as a Mac OS user since we can pretty much install everything through brew. Unfortunately thing start going pear shape when we have Windows 10 machines as part of the team and the shared tooling just stops working.
The following post describes how to setup your Windows 10 & WSL development environment(s) so that you're able to use all the various Kubernetes tooling.
Under general, tick
the Expose daemon on tcp://localhost2375 option so that we can connect to Docker Daemon from the WSL Ubuntu VM.
You can later explore options on how to secure the connection even further if you so desire: https://hub.docker.com/r/stefanscherer/dockertls-windows/.
Make sure you share your C drive
so that you can run containers with volumes
Definitely give Docker Daemon more memory.
Maybe 6GB or more?
Enable Kubernetes (if you are not planning to use Minikube).
Just tick the Enable Kubernetes option.
IMPORTANT: Make sure you select the docker-for-desktop context through the Docker Desktop for Windows menu so that the .kube/config file appropriately configured.
Configure Docker cli
Back in your WSL ubuntu session configure the cli to talk to the Docker Daemon:
Configure Ubuntu to mount windows drives at /c or /e instead of /mnt/c or /mnt/e.
The options = "metadata" line is not necessary but it will fix folder and file permissions on WSL mounts
so everything isn’t 777 all the time within the WSL mounts:
cat <<EOF | sudo tee /etc/wsl.conf[automount]root = /options = "metadata"EOF
NOTE: The previous action might take some time to propagate so a full Windows log-off or restart is required.
Once back, enter an ubuntu session:
ubuntu
# ubuntu@windows10:~$
Validate drives were mounted at the root:
ls "/c/Program Files"
Now lets run a sample container to make sure volumes are working
Now you should be able to connect to Kubernetes on Docker for Windows
kubectl cluster-info
# Kubernetes master is running at https://localhost:6445# KubeDNS is running at https://localhost:6445/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy## To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Test kubectx
kubectx
# docker-for-desktop
Test kubens
kubens kube-system
# Context "docker-for-desktop" modified.# Active namespace is "kube-system".
kubectl get pods
# NAME READY STATUS RESTARTS AGE# etcd-docker-for-desktop 1/1 Running 1 2h# kube-apiserver-docker-for-desktop 1/1 Running 1 2h# kube-controller-manager-docker-for-desktop 1/1 Running 1 2h# kube-dns-86f4d74b45-z7n5h 3/3 Running 3 2h# kube-proxy-6568r 1/1 Running 1 2h# kube-scheduler-docker-for-desktop 1/1 Running 1 2h
Open Powershell in Administrator mode and install the downloaded package:
Add-AppxPackage .\Ubuntu.appx
Now type the following in on the terminal:
ubuntu
# Installing, this may take a few minutes...
Setup your default user
The first user account you create is automatically (https://aka.ms/wslusers) configured with a few special attributes:
It is your default user -- it signs-in automatically on launch.
It is Linux administrator (a member of the sudo group) by default.
Type in a Linux username and password for the user.
NOTE: You will need this password to perform sudo commands (dont loose it):
# Installation successful!# Please create a default UNIX user account. The username does not need to match your Windows username.# For more information visit: https://aka.ms/wslusers# Enter new UNIX username:
ubuntu
# Enter new UNIX password:
password123
# Retype new UNIX password:
password123
# passwd: password updated successfully# Default UNIX user set to: ubuntu# To run a command as administrator (user "root"), use "sudo <command>".# See "man sudo_root" for details.
You are now in an ubuntu session:
# ubuntu@windows10:~$
Having to enter a password when executing sudo commands is a pain so lets remove that.
Note that this is based on the default user being named ubuntu.
sudo su
# [sudo] password for ubuntu:
cat<<EOF > /etc/sudoers.d/ubuntu && chmod 0440 /etc/sudoers.d/ubuntuubuntu ALL=(ALL) NOPASSWD:ALLEOF
Managing distro
You can manage the Ubuntu instance from a Powershell session:
ubuntu.exe/?# Launches or configures a linux distribution.## Usage:# <no args># - Launches the distro's default behavior. By default, this launches your default shell.## run <command line># - Run the given command line in that distro, using the default configuration.# - Everything after `run ` is passed to the linux LaunchProcess call.## config [setting [value]]# - Configure certain settings for this distro.# - Settings are any of the following (by default)# - `--default-user <username>`: Set the default user for this distro to <username>## clean# - Uninstalls the distro. The appx remains on your machine. This can be# useful for "factory resetting" your instance. This removes the linux# filesystem from the disk, but not the app from your PC, so you don't# need to redownload the entire tar.gz again.## help# - Print this usage message.
You can also enter an ubuntu shell from other terminal emulators like Powershell or cmd by typing ubuntu:
ubuntu
# root@windows10:~#
You can also change the default user if you want to change it from your previously created one: