How to Run Kubernetes Locally in Docker Desktop

by Sudipta Deb | Feb 20, 2023 | Kubernetes | 2 comments

Kubernetes is an open-source system for automating the deployment, scaling, and management of containerized applications. It was originally developed by Google and is now maintained by the Cloud Native Computing Foundation.

Read this blog post or watch the video below to Configure Kubernetes in your local machine with Docker Desktop.

Content

In this blog post, I will cover the installation of Docker Desktop in Local Machine and configuring Kubernetes there. Also I will be showing you how to deploy Dashboard UI for Kubernetes

Things covered today -

    • Configure Docker Desktop and enable Kubernetes
    • Verify Kubernetes Installation
    • Deploy Dashboard UI for Kubernetes

Configure Docker Desktop And Enable Kubernetes

Step 1: Install Docker based on your operating system. Link: https://docs.docker.com/desktop/install/mac-install/

Step 2: Open Docker and enable Kubernetes by going into Settings -> Kubernetes -> Check the box "Enable Kubernetes" -> Hit Apply & restart. 

Verify Kubernetes Installation

You can verify from the Docker Desktop UI like shown below

The other way to verify is open the terminal and execute the command: kubectl. You should be able to see the list of options available and also the version installed.

Deploy Dashboard UI For Kubernetes

Step 1: Deploy the Dashboard UI

For that go to the link:  https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/ and execute the command. I will always recommend going to this link and getting the official command as the link in the command keep on changing with new versions.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
Step 2: Create Admin User and Get Bearer Token

Create the YAML file and put the content as -

apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard

Then apply the below command to create the user

kubectl apply -f dashboard-adminuser.yaml

Get the bearer token of the user

kubectl -n kubernetes-dashboard create token admin-user

This will generate the token which you need to copy somewhere as we will need this soon to access the UI.

 

Step 3: Start the Proxy

Start the proxy

kubectl proxy
Step 4: Access the Dashboard

Open the below URL in browser tab

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

Enter the token we generated in the previous step and click on Sign In.

And you should be able to access the Dashboard now.

Conclusion

Kubernetes provides a highly scalable and flexible platform for deploying and managing containerized applications. By abstracting away the underlying infrastructure, it allows developers to focus on writing code and deploying applications, while the Kubernetes system handles the management and scaling of the underlying resources.

In conclusion, running Kubernetes with Docker Desktop on your local machine will provide the setup you need to explore Kubernetes in deep.

In my next post/video, I will be covering How to create Pods and Check Pod Health in Kubernetes. So stay tuned and please provide your feedback in the comment section.

Disclaimer

This article is not endorsed by Salesforce, Google, or any other company in any way. I shared my knowledge on this topic in this blog post. Please always refer to Official Documentation for the latest information.

2 Comments

  1. Tanya

    Thank you for putting things in so simple term. I am looking forward for more such contents in your blog as well as in youtube videos.

    Reply
  2. foobar

    Hi,

    I had to apply this YAML file in order to see all namespaces.

    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

    Thanx for the good video!

    Reply

Leave a Reply

Written by Sudipta Deb

Enterprise Cloud Architect, Content Creator, 20x Salesforce Certified, 1x Google Cloud Certified, 2x Copado Certified

Related Posts

My Favourite 5 Essential Kubernetes GitHub Projects

My Favourite 5 Essential Kubernetes GitHub Projects

Welcome to the world of Kubernetes, where the orchestration of containers meets scalability, resilience, and efficiency. In today’s tech landscape, where agility and scalability are paramount, Kubernetes emerges as a cornerstone technology, revolutionizing the way we deploy, manage, and scale containerized applications.

read more...
Probes In Kubernetes – Liveness Probe, Readiness Probe, Startup Probe

Probes In Kubernetes – Liveness Probe, Readiness Probe, Startup Probe

Welcome to my 4th blog post on the Kubernetes series where today I will be talking about different probes that can be used to check the health of pods or containers in Kubernetes!

Kubernetes is a popular container orchestration system that provides a scalable and reliable way to deploy, manage, and scale applications. One of the key features of Kubernetes is the ability to automatically check the health of pods and containers to ensure that they are running properly.

In this blog post, I will explore the different types of probes that Kubernetes provides and how they can be used to monitor the health of pods and containers. Whether you’re new to Kubernetes or an experienced user, this post will help you better understand how to ensure that your applications are running smoothly.

read more...
How To Create Pods And Check Pod Health In Kubernetes

How To Create Pods And Check Pod Health In Kubernetes

Kubernetes is an open-source system for automating the deployment, scaling, and management of containerized applications. It was originally developed by Google and is now maintained by the Cloud Native Computing Foundation.

In this blog post today, I will share how to create Pods in Kubernetes using a YAML file and finally what are the options to check pod’s health in Kubernetes.

read more...

2 Comments

  1. Tanya

    Thank you for putting things in so simple term. I am looking forward for more such contents in your blog as well as in youtube videos.

    Reply
  2. foobar

    Hi,

    I had to apply this YAML file in order to see all namespaces.

    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

    Thanx for the good video!

    Reply

Leave a Reply