Install
...
Kubernetes CLI
> brew install kubernetes-cli
Install kubectl
> brew install kubectl
Enabling shell autocompletion
> brew install bash-completion
> kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl
Install Minikube
Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day.
Install minikube
> curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.26.1/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
Start minikube
> minikube start
Start a Version of Kubernetes with Pod Security Policies Enabled
>minikube start --extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy --addons=pod-security-policy --driver=docker --alsologtostderr --kubernetes-version=v1.21.5
Other commands:
Command (minikube <command> | Description |
---|---|
start | Start minikube cluster |
stop | Stop minikube cluster |
status | Get status of minikube |
dashboard | Opens/displays the kubernetes dashboard URL for your local cluster |
ssh | Log into or run a command on a machine with SSH; similar to 'docker-machine ssh' |
load image <image>:<tag> | Load a docker image into minikube |
help | Display help |
Running a Sample
Code Block |
---|
$ minikube start
Starting local Kubernetes cluster...
Running pre-create checks...
Creating machine...
Starting local Kubernetes cluster...
$ kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.4 --port=8080
deployment "hello-minikube" created
$ kubectl expose deployment hello-minikube --type=NodePort
service "hello-minikube" exposed
# We have now launched an echoserver pod but we have to wait until the pod is up before curling/accessing it
# via the exposed service.
# To check whether the pod is up and running we can use the following:
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-minikube-3383150820-vctvh 0/1 ContainerCreating 0 3s
# We can see that the pod is still being created from the ContainerCreating status
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-minikube-3383150820-vctvh 1/1 Running 0 13s
# We can see that the pod is now Running and we will now be able to curl it:
$ curl $(minikube service hello-minikube --url)
CLIENT VALUES:
client_address=192.168.99.1
command=GET
real path=/
...
$ kubectl delete services hello-minikube
service "hello-minikube" deleted
$ kubectl delete deployment hello-minikube
deployment "hello-minikube" deleted
$ minikube stop
Stopping local Kubernetes cluster...
Stopping "minikube"... |
Open up the Dashboard
> minikube dashboard
Tips and Tricks
Set Docker Host to Minikube
Code Block |
---|
eval $(minikube docker-env) |
This above command will do the following:
Code Block |
---|
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://127.0.0.1:58211"
export DOCKER_CERT_PATH="/Users/john/.minikube/certs"
export MINIKUBE_ACTIVE_DOCKERD="minikube" |
Copying Images to Minikube
Code Block |
---|
minikube image load cybersecuritydome/kafka-stream-operator:22.0.1-SNAPSHOT |
References
Reference | URL |
---|---|
Installing Kubernetes | https://kubernetes.io/docs/tasks/tools/install-kubectl/ |
Minikube | https://github.com/kubernetes/minikube/releases |
Getting started with Minikube | https://kubernetes.io/docs/getting-started-guides/minikube/#installation |
Minikube Quickstart | https://kubernetes.io/docs/getting-started-guides/minikube/#quickstart |