Minikube setup

Getting started

Docker’s team creates an online platform for anyone to test out Kubernetes, and to create a cluster with 5 nodes all from browser. Awesome stuff, the quickest way to try k8s without using any your computing resources. To see how things work together beautifully. labs-play-with-k8s

https://media.giphy.com/media/IPbS5R4fSUl5S/giphy.gif

Minikube Init

You get clear instructions to build the cluster Once you loggin - take you 2 minutes to get started

playwithk8s

BareMetal - weave cni install

curl https://gitlab.com/snippets/1832483/raw | sh -

kubeadm init --apiserver-advertise-address $(hostname -i) [[ -d ~/.kube ]] || mkdir -p ~/.kube
chown $(id -u):$(id -g) ~/.kube/config

`cp -i /etc/kubernetes/admin.conf $HOME/.kube/config`
kubectl apply -n kube-system -f \
    "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 |tr -d '\n')"

After Kubernets master initialized, then join the nodes by listed at bottom

../../../_images/k8s_up.png
kubeadm token list = --token

kubeadm join 192.168.0.13:6443 --token 5h49dm.4ggeissmkhkzykm5 --discovery-token-ca-cert-hash sha256:8f9223edaac

What if I needed to delete the master node

Run kubectl get nodes on the master to see this node join the cluster.

sudo kubeadm reset

sudo apt-get purge kubeadm kubectl kubelet kubernetes-cni kube*

sudo rm -rf ~/.kube

Deploy and expose service with ingress router [Traefik](https://docs.traefik.io/routing/routers/)

Apply nginx service to the k8s

kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/application/nginx-app.yaml

apiVersion: v1
kind: Service
metadata:
  name: my-nginx-svc
  labels:
    app: nginx
spec:
  type: LoadBalancer
  ports:
  - port: 80
  selector:
    app: nginx
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-nginx
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
../../../_images/nginx.png

Confirm cluster’s name

kubectl config get-contexts

kubectl config get-clusters

Run hello kubernetes image

kubectl run hello-kubernetes –image=k8s.gcr.io/echoserver:1.4 –port=8080

Expose the service

kubectl expose deployment hello-kubernetes –type=NodePort

Verify the services

kubectl get service

kubectl get pods

Find out the cluster reachable IP address

kubectl cluster-info

kubectl cluster-info dump


VM setup - Minikube

If you have Virtualbox installed on your local machine. Minikube provides an instant VM solutions to run on single node.

(https://github.com/kubernetes/minikube) - check the latest instructions

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

Run 2x VM minikube cluster

minikube start -p secondvmk8s

After deployment and expose the services, open the url in the browser

../../../_images/expose.png

In my example http://192.168.99.120:31734/ , minikube ip - show the ip and kubectl get services with the PAT

../../../_images/hello.png

Aliases

Mapping the shortkey, save repeat typing on those 2 commands >> ~/.bash_aliases

alias k=’kubectl’

alias mk=’minikube’

Kubernetes Versioning

``kubectl get apiservices``

../../../_images/api.png

Kube-proxy - IPVS MODE

minikube start --proxy-mode ipvs

kubectl edit -n kube-system configmap/kube-proxy

Conference

[kubecon]