Have you ever needed to play with Kubernetes on your local?
For K8s apps development or to test your changes in Helm chart or just for fun?
Recommended way for local Kubernetes is Minikube, but peronally I dont like it and let me explain why K3s + autok3s + K3d is your choise.
Why not Minikube
Minikube, in the same way as many other local Kubernetes providers is annoying me in one way - it makes your laptop/PC dirty. Creates some sophisticated networking configurations, creates SystemD units, doing some unknown changes on local filesystem, install/update some tools you dont wanted to and so on.
My solution - use K3s with K3d provider, which will setup Kubernetes in your Docker and change nothing on your local. You can create multi node cluster and remove it next minute. And NOTHING will be changed on your local!
How to
If you prepere video
If not lets move step by step.
First of all you have to add Docker and K3s applications in DevOps Pass:
You can install Docker from DOP and move on with K3s.
K3s app providing following actions:
- Install autoK3s - start autok3s tool in your Docker
- Setup k3d cluster - Setup local Kubernetes in Docker
- Open autoK3s in Browser - open autok3s in your browser
autok3s
is a tool, developed by Rancher, which allowing you to install K3s anywhere, currently supported AWS, Docker, GCP, etc. - https://github.com/cnrancher/autok3s
k3d
is one of providers k3s can use, it setups Kubernetes cluster in your local Docker and you even can specify amount of nodes you want to run.
So install autok3s first, then click "Setup k3d cluster", wait until it appear "Running" in clusters list:
And done! You have Kubernetes cluster installed locally.
You can swithc to Kubernetes app and check if context exists and installed namespaces list:
MacOS, as usual...
As usual for MacOS there is one exception... Alike Windows or Linux you can not access Docker containers from local network, you have to install additional Brew package - https://github.com/chipmk/docker-mac-net-connect
It will allow you to connect your containers and K3s services/ingress'es from host machine:
# Install via Homebrew
$ brew install chipmk/tap/docker-mac-net-connect
# Run the service and register it to launch at boot
$ sudo brew services start chipmk/tap/docker-mac-net-connect
Thats it, now you can forget about it.
If you're curious what is it: its Brew service written in Go, which refreshing MacOS routing table, to allow you access Docker networks from host machine. More details you can find in repo readme.
Install Jenkins via Helm
Go to Helm app in DOP, click "Addd Helm repo" action in right top and add Bitnami Helm repo - https://charts.bitnami.com/bitnami
Then on "Helm Repo charts" tab find Jenkins chart:
Now "Actions -> Install Chaart", it will require some values, value should be in JSON format, i.e. if its string "..."
if number 8083
if boolean true
:
service.ports.https=8443
service.ports.http=8083
jenkinsUser="user"
jenkinsPassword="12345678"
agent.enabled=true
Click "Install" and wait for Jenkins pod to be ready (you can open "default" namespace in K9s in Kubernetes app or just wait for a few mins):
Now copy this to your console to get Jenkins URL:
export SERVICE_IP=$(kubectl get svc --namespace default jenkins --template "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}")
echo "Jenkins URL: http://$SERVICE_IP:8083/"
Login to Jenkins and voila!
Removing K3s cluster
At the moment you dont need K8s cluster on your local, you can drop it. Navigate to K3s application, find cluster in the list at the bottom and find "Destroy" action.
Thats it! Not even a hint of K8s on your local, you can forget about it till you'll need it again.
Summary
I hope that workshop was interresting for you we've created K8s cluster on your local, installed some Helm charts and dropped it.
No more broken semi-configured networking rules or services, no more waste on your local.
If you likes this article, give us π and start on GitHub π€© - https://github.com/devopspass/devopspass/
Top comments (0)