Intro (Updated 17/07/2022)
Kubernetes is made for managing your cloud resources and build scalable apps. It's considered the most popular tool for automating, deploying, and scaling your whole cloud. It runs on all major operating systems and it is the most popular open source tool in the cloud market. Kubernetes can scale your whole infrastructure, check the health of each service, work as a load balancer, automate deployments and many more. You can install & setup as many nodes (clusters) as you want, and deploy your pods (docker containers) and services across the cloud. In this tutorial you will learn how to setup Kubernetes and deploy the official web GUI dashboard where you can manage and monitor everything but first you have to install Hyper-V & Docker in order to use Kubernetes.
Step 1: Install & Setup Hyper-V
Windows as we all know, have their own virtualization software and it's called Hyper-V which is basically something like VirtualBox on steroids. Hyper-V can manage your virtual machines (VM) using the default GUI tool provided by Microsoft for free, or through command line. Enabling Hyper-V can be easily done but first, make sure your PC meets the following requirements: Your OS should be Windows 10 (Enterprise, Pro or Education) with minimum 4GB RAM and CPU Virtualization support, although you have to double check if it's enabled in your BIOS settings.
You can remove or add features that don't come up pre-installed during the installation of Windows, like Hyper-V. Always remember that some of the features require internet access to download extra components from Windows Update. Follow the next steps to enable Hyper-V on your machine.
- Go to Control Panel
- On your left panel, click on Programs
- Then click Programs and Features followed by Turn Windows features on and off.
- Check Hyper-V and Windows Hypervisor Platform
- Click OK
Your system will now start installing Hyper-V on the background, it may need to reboot a couple of times until everything is configured properly. Don't expect any notification or something! Run the following powershelgl command as Administrator and verify if Hyper-V is installed successfully on your machine: Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
Example.
PS C:\Windows\system32> Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
FeatureName : Microsoft-Hyper-V
DisplayName : Hyper-V Platform
Description : Provides the services that you can use to create and manage virtual machines and their resources.
RestartRequired : Possible
State : Enabled
Step 2: Install Docker for Windows
Kubernetes is build on top of Docker, theoretically is just a tool that communicate with your Docker containers and manage everything on enterprise level. To install Docker just grab & run the following installer https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe . During installation Docker will ask you to choose between Hyper-V and WSL. For better security uncheck WSL 2. Docker will setup a Linux virtual machine on top of Hyper-V and start all the necessary services without manually configure anything. After the installation, you can either "communicate" with Docker using the CLI tool docker
or running HTTP requests though its API.
Step 3: Install Kubernetes on Windows 10
Docker comes with a handy GUI tool where you can modify some settings or install & enable Kubernetes. Follow the following instructions, WARNING! If Docker is installed successfully and you can't locate its tray icon, you have to reboot your system. If the problem persists, check the official troubleshooting guide here https://docs.docker.com/docker-for-windows/troubleshoot/. Now follow the instructions to install Kubernetes.
- Right-click the Docker tray icon
- Click "Settings"
- On the left panel click "Kubernetes"
- Check
Enable Kubernetes
and click "Apply"
*** If you're behind a firewall, don't forget to allow:
C:\program files\docker\docker\frontend\docker desktop.exe
C:\program files\docker\docker\resources\com.docker.backend.exe
C:\program files\docker\docker\resources\bin\kubectl.exe
C:\program files\docker\docker\resources\com.docker.vpnkit.exe
During installation, Docker is going to install additional packages and dependencies. It may take around 5~10 minutes and the installation time depends on your Internet speed and your PC performance. Wait until the 'Installation complete!' popup message is shown up. After installing Kubernetes you can make sure that everything is working fine using the Docker app. If both services (Docker & Kubernetes) are running successfully without any errors then both icons at bottom left will go green.
Example.
OR
Step 4: Install Kubernetes Dashboard
Kubernetes Dashboard is the official web-based UI where you can manage Kubernetes resources. It's not installed by default. Deploying applications with Kubernetes can be easily managed using the cli tool called kubectl
where you can interact with your cloud and manage your Pods, Nodes, or Clusters. If you pass the apply
argument followed by your YAML configuration file you can easily create or update Kubernetes resources. Run the following commands to deploy & enable the Kubernetes Dashboard using the following commands.
- Go to https://github.com/kubernetes/dashboard/releases
- Scroll down to
Installation
and download latest yaml configuration file for example https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.0/aio/deploy/recommended.yaml - Deploy it using
kubectl apply -f .\recommended.yaml
- Verify that it's running using the following command:
kubectl.exe get -f .\recommended.yaml.txt
Example.
PS C:\Users\user\Desktop> kubectl.exe get -f .\recommended.yaml.txt
NAME STATUS AGE
namespace/kubernetes-dashboard Active 2m10s
NAME SECRETS AGE
serviceaccount/kubernetes-dashboard 1 2m10s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes-dashboard ClusterIP 10.97.3.127 <none> 443/TCP 2m9s
Step 5: Access the dashboard
There are two ways to access the dashboard with tokens, the first one (deprecated, works only for older versions) is using the default token that was crated during the installation of Kubernetes and the second (more secure) way is by creating users, giving them permissions, and then get the generated token.
Newest version
-
Create a new configuration file:
dashboard-admin.yaml
apiVersion: v1 kind: ServiceAccount metadata: name: admin-user namespace: kubernetes-dashboard --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: admin-user roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: admin-user namespace: kubernetes-dashboard
Deploy it using
kubectl.exe apply -f .\dashboard-admin.yaml.txt
Generate token using
kubectl.exe -n kubernetes-dashboard create token admin-user
Run
kubectl proxy
Copy paste the token to http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
Old version (deprecated)
- Run the following command powershell (not cmd)
((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1]
- Copy the generated token
- Run
kubectl proxy
. - Open the following link on your browser: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
- Select
Token
& paste the generated token - Sign In
Finally
If everything is configured properly you'll be able to see the dashboard and your cloud resources. From there you can do almost all the "hard" work without dealing with the CLI every time. You may sometimes get your hands dirty with the command line but if you don't understand the concept of Docker and Kubernetes or you don't have time to for maintaining your own cloud, it's better to stick with some PaaS providers that can cost you a fortune.
Support
If you liked this article please follow me on Twitter :)
https://twitter.com/devcrafter91
Top comments (6)
localhost:8001/api/v1/namespaces/k...
Getting error
the server could not find the requested resource (get ingresses.extensions)
If you use Windows 10 Home, Can't find Hyper-V in 'Turn Windows features on and off' menu. Please check below link.
itechtics.com/enable-hyper-v-windo...
You can't run Hyper-V on Home editions AFAIK. It's a restriction from Microsoft or something.
that helped to activate hyper -v
dashboard server cant be reached on windows 11.
cant get secret
thank you!