Views: 80
0 0
Read Time:5 Minute, 34 Second

In the ever-evolving landscape of cloud-native technologies, Kubernetes has emerged as the de facto standard for container orchestration. As a technical architect, harnessing the power of Kubernetes is crucial for designing and implementing scalable and resilient applications. However, setting up a Kubernetes cluster for development or testing purposes can often be daunting, especially for those new to the technology. In this guide, we’ll explore how you can easily set up and run a Kubernetes cluster on your PC, empowering you to experiment, prototype, and innovate with confidence. Let’s delve into the world of Kubernetes and unlock its potential right from the comfort of your PC.

What is kubernetes?

From the official kubernetes website (https://kubernetes.io/): Kubernetes, also known as K8s, is an open-source system for automating deployment, scaling, and management of containerized applications.

Great but in detail what actually means? Kubernetes is a platform or ecosystem that will help us to deploy and manage a bunch of docker containers. Is often referred as k8s because the 8 is “ubernete” so is “only” the number of letters between k and s, and more important is the de-facto standard for micro services deployment. More information here https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/

How do I install kubernetes on my computer?

To install/activate kubernetes on our computer we have two options:

Install kubernetes using docker desktop

If you are using docker desktop (that can be found here https://www.docker.com/products/docker-desktop) it’s already inbuilt into the distro, it just needs to be activated. Navigate to the preferences, click on kubernetes then “Enable kubernetes”, once done, “Apply & Restart”

docker-desktop-kubernetes-1024x741 Run a kubernetes cluster on your PC
docker desktop kubernetes activation – Navigate to the preferences, click on kubernetes
docker-desktop-kubernetes-activation-1024x740 Run a kubernetes cluster on your PC
docker desktop kubernetes activation – Enable kubernetes and then Apply & Restart

Install kubernetes using minikube

If you are not using docker desktop the other alternative you have is to use minikube that is another version of a “local kubernetes”. More information can be found here https://minikube.sigs.k8s.io/docs/start/

Installation is trivial

Linux

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

macOS

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64
sudo install minikube-darwin-amd64 /usr/local/bin/minikube

Windows

# using powershell
New-Item -Path 'c:\' -Name 'minikube' -ItemType Directory -Force
Invoke-WebRequest -OutFile 'c:\minikube\minikube.exe' -Uri 'https://github.com/kubernetes/minikube/releases/latest/download/minikube-windows-amd64.exe' -UseBasicParsing

# add to the PATH
$oldPath = [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::Machine)
if ($oldPath.Split(';') -inotcontains 'C:\minikube'){ `
  [Environment]::SetEnvironmentVariable('Path', $('{0};C:\minikube' -f $oldPath), [EnvironmentVariableTarget]::Machine) `
}

Then we have to start

minikube start

in the case of minkube is important to create an alias for what will be the most, in absolute, used command: kubectl

alias kubectl="minikube kubectl --"

Kubectl

kubectl is your way of interacting with the kubernetes cluster, it has an infinite amount of commands and options that we will not list here.

From your command line run

kubectl --help

you should see something like this

kubectl controls the Kubernetes cluster manager.

 Find more information at: https://kubernetes.io/docs/reference/kubectl/overview/

Basic Commands (Beginner):
  create        Create a resource from a file or from stdin
  expose        Take a replication controller, service, deployment or pod and expose it as a new Kubernetes service
  run           Run a particular image on the cluster
  set           Set specific features on objects

Basic Commands (Intermediate):
  explain       Get documentation for a resource
  get           Display one or many resources
  edit          Edit a resource on the server
  delete        Delete resources by file names, stdin, resources and names, or by resources and label selector

Deploy Commands:
  rollout       Manage the rollout of a resource
  scale         Set a new size for a deployment, replica set, or replication controller
  autoscale     Auto-scale a deployment, replica set, stateful set, or replication controller

Cluster Management Commands:
  certificate   Modify certificate resources.
  cluster-info  Display cluster information
  top           Display resource (CPU/memory) usage
  cordon        Mark node as unschedulable
  uncordon      Mark node as schedulable
  drain         Drain node in preparation for maintenance
  taint         Update the taints on one or more nodes

Troubleshooting and Debugging Commands:
  describe      Show details of a specific resource or group of resources
  logs          Print the logs for a container in a pod
  attach        Attach to a running container
  exec          Execute a command in a container
  port-forward  Forward one or more local ports to a pod
  proxy         Run a proxy to the Kubernetes API server
  cp            Copy files and directories to and from containers
  auth          Inspect authorization
  debug         Create debugging sessions for troubleshooting workloads and nodes

Advanced Commands:
  diff          Diff the live version against a would-be applied version
  apply         Apply a configuration to a resource by file name or stdin
  patch         Update fields of a resource
  replace       Replace a resource by file name or stdin
  wait          Experimental: Wait for a specific condition on one or many resources
  kustomize     Build a kustomization target from a directory or URL.

Settings Commands:
  label         Update the labels on a resource
  annotate      Update the annotations on a resource
  completion    Output shell completion code for the specified shell (bash or zsh)

Other Commands:
  api-resources Print the supported API resources on the server
  api-versions  Print the supported API versions on the server, in the form of "group/version"
  config        Modify kubeconfig files
  plugin        Provides utilities for interacting with plugins
  version       Print the client and server version information

Usage:
  kubectl [flags] [options]

Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).

Try to get some cluster information

kubectl cluster-info

and the result should be this

Kubernetes control plane is running at https://kubernetes.docker.internal:6443
CoreDNS is running at https://kubernetes.docker.internal:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Let’s list the namespaces

kubectl get namespaces

and you should see something similar to this

NAME              STATUS   AGE
default           Active   25d
kube-node-lease   Active   25d
kube-public       Active   25d
kube-system       Active   25d

At this stage you have your kubernetes cluster running.

If you are interested, in this article we are going through the configuration of a cluster and exposing some pods using NGINX

In the meantime more information and guides can be found here https://kubernetes.io/docs/tutorials/

cc4ae2d7d0e2367495d9f75c31beef8e?s=400&d=robohash&r=g Run a kubernetes cluster on your PC

About Post Author

brewedbrilliance.net

Experienced software architect with a spasmodic passion for tech, software, programming. With more than 20years of experience I've decided to share all my knowledge in pills through this blog. Please feel free to contact me if there is any topic that you would love to cover
happy Run a kubernetes cluster on your PC
Happy
0 %
sad Run a kubernetes cluster on your PC
Sad
0 %
excited Run a kubernetes cluster on your PC
Excited
0 %
sleepy Run a kubernetes cluster on your PC
Sleepy
0 %
angry Run a kubernetes cluster on your PC
Angry
0 %
surprise Run a kubernetes cluster on your PC
Surprise
0 %

Share this content:

By brewedbrilliance.net

Experienced software architect with a spasmodic passion for tech, software, programming. With more than 20years of experience I've decided to share all my knowledge in pills through this blog. Please feel free to contact me if there is any topic that you would love to cover

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x