Minikube is a high available cluster for education and prototyping purpose only but not for the production use because of security, performance and stability issues.

Minikube

Lean the basics here.

If you want to run Minikube locally, follow the instructions for Mac or here.

Install Minikube

Check the version of Minikube available with you

minikube version

check the latest

minikube update-check

To display current configuration settings

minikube update-check

You can metrics-server and dashboard is available.

to start the cluster

minikube start

Verify Minikube is running

minikube status

To get the IP of the Minikube

minikube ip

Get logs

minikube logs

To stop the cluster

minikube stop

To delete the cluster

minikube delete

To ssh

minikube ssh

Cluster

Kubectl is the tool to adminstating the Minikube cluster

find the version of current Kubectl tool:

kubectl version

To find the nodes in the cluster

kubectl get nodes

To get indepth information about node (because this is single cluster)

kubectl describe node minikube

or for other related services such as health check of the cluster

kubectl get componentstatus

for the cluster information

kubectl cluster-info

For the configuration

kubectl config view

to get the context

kubectl config get-contexts

You can get the cluster name and the namespace.

List all the events:

kubectl get events

Addons

To list all the add-ons and check which are enabled and disabled

minikube addons list

To enable the add-on, for example metrics-server:

minikube addons enable metrics-server

Now you can run the top command

kubectl top node

To inspect pods of all the namespaces

kubectl top pods --all-namespaces

Services

Some services exposed via ports to access externally,

minikube service list

The URLs for these services can be listed:

minikube service --namespace kube-system kubernetes-dashboard-katacoda --url

The port information can be listed as

kubectl get service kubernetes-dashboard-katacoda -n kube-system

You can enable dashboard as follows

minikube addons enable dashboard
# to run
minikube dashboard

Configure Minikube

Creating namespace

kubectl create namespace myspace

To get all the namespaces

ubectl get namespaces

Label the namespace

kubectl label namespace myspace customer=ojitha

verify the label

kubectl describe namespace myspace

Use the label to view only the namespace associated with that:

Labels you can find in the dashboard as well.

Deployment

You can deploy images

kubectl create deployment my-deployment --image=<image>

to verify the my deployment

kubectl get pods

If you deployed web server, you can expose the prot to access via external browser:

kubectl expose deployment my-deployment --port=80 --type=NodePort

to get the port


kubectl get svc my-deployment -o go-template='{{range.spec.ports}}{{if .nodePort}}{{.nodePort}}{{"\n"}}{{end}}{{end}}'

You can view your deployment in the dashboard as well.

This is example yml to deploy your web application

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ojwebapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ojwebapp
  template:
    metadata:
      labels:
        app: ojwebapp
    spec:
      containers:
      - name: ojwebapp
        image:<image>:latest
        ports:
        - containerPort: 80

to deploy above deployment.yaml

kubectl create -f deployment.yaml

now you can verify kubectl get deployment

Get the deployment information:

kubectl describe deployment ojwebapp

You can control network configuration via yaml

apiVersion: v1
kind: Service
metadata:
  name: ojwebapp-svc
  labels:
    app: ojwebapp
spec:
  type: NodePort
  ports:
  - port: 80
    nodePort: 30000
  selector:
    app: ojwebapp

To create ojwebapp-svc, deploy the service.yaml as follows:

kubectl create -f service.yaml

To get the all services:

kubectl get svc

To get only about ojwebapp-svc:

kubectl describe svc ojwebapp-svc

Now you can run curl command curl <host>:30000 to get the page.

You can change the number of replicas into 4 and apply the changes. If you run the kubectl get deployment.