Skip to content

Container Orchestrator Kubernetes

Giovanni Emanuele Nocco edited this page Mar 11, 2021 · 4 revisions

Main components

  1. Kubernetes
  2. kubectl
  3. minikube
  4. microk8s

Kubernetes: The orchestrator

kubectl: The orchestator cli

minikube: Allow to have a local cluster with a single node (used to test kubernetes locally)

microk8s: Allows to define a multicluster kubernetes node on linux ubuntu running on both bare metal, VM or on windows WSL2

First check

kubectl version
kubectl --help


minikube version
minikube --help

The basic commands to monitor your cluster -official-

kubectl get deployments
kubectl get nodes
kubectl get services
kubectl get pods

kubectl get storageclass

# Delete resources
kubectl delete --all storageclass
kubectl delete --all services
kubectl delete --all pods
kubectl delete --all deployments
kubectl delete --all nodes

kubectl get service --watch

kubectl get service qrcode-backend-service --watch

How to create a namespace

kubectl create namespace genocs

How to run a deployment

kubectl apply -f azure-vote.yaml

How to run single image (will be removed)

kubectl run kuberneteters-boocamp --image=gcr.io/google-samples/kuberneters-bootcamp:v1 --port=8080
kubectl run genocs-qrcode2 --image=genocs/qrcode:latest --port=8083

Setup microk8s on ubuntu

The following procedure can be used both on bare metal VM or WSL2

The procedure has been validated on Ubuntu 20.04

Check snap

snap list
snap refresh microk8s -edge
kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:kubeconfig-sa
$TOKENNAME=`kubectl -n kube-system get serviceaccount/kubeconfig-sa -o jsonpath='{.secrets[0].name}'`
kubectl -n kube-system get secret $TOKENNAME -o jsonpath='{.data.token}'

How to get the token

token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
microk8s kubectl -n kube-system describe secret $token

How to check the list of services and forward the post to allow access to the dashboard from windows host

microk8s kubectl get services -A
microk8s kubectl -n kube-system port-forward --address 0.0.0.0 service/kubernetes-dashboard 5000:443
redis-server-7db4b86f-frmnl
kubectl port-forward genocs-solomon-frontend-68bd5f656c-7xxzr 5002:5002

How to run dashboard

  1. Install the dashboard plugin
  2. Get the daskboard login token
  3. Run the daskboard
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
kubectl -n kube-system describe secret token
kubectl proxy

To run the dashboard

minikube dashboard (--url)

The dashboard URL

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/(. | #/login)

How to get the wsl2 ip address from the windows host

wsl hostname -I

microk8s

microk8s status
microk8s kubectl get all --all-namespaces
microk8s kubectl apply -f qrcode.yaml

Check the list of services and forward the post to allow access to the dashboard from windows host

microk8s kubectl get services -A
microk8s kubectl -n kube-system port-forward --address 0.0.0.0 service/kubernetes-dashboard 5000:443
kubectl port-forward 'service name' 5002:5002

AKS Azure Kubernetes Services

AWS Kubernetes - Daskboard

az group create --name RG-k8 --location eastus
az aks create --resource-group RG-k8 --name genocsAKSCluster --node-count 1 --enable-addons monitoring --generate-ssh-keys

az aks get-credentials --resource-group RG-k8 --name genocsAKSCluster

kubectl get nodes

az acr list --resource-group RG-k8 --query "[].{acrLoginServer:loginServer}" --output table
az aks create --resource-group RG-k8 --name genocsAKSCluster --node-count 1 --enable-addons monitoring --generate-ssh-keys --attach-acr genocsContainerRegistry
kubectl get service solomonbesearch --watch

az login

az acr login --name 'acrName'
az acr login --name genocsContainerRegistry
  • Setup the project

    • Describe the idea
    • Identify the product shape
  • Project management

    • Define the MVP (Minimum Viable Product)
    • Identify the KPIs (Key Performance Indicators)
    • Define the process
    • Identify and define the roadmap, checkpoints, deadlines
  • Implement the solution

    • Patterns and practices
    • Technologial Stack
    • Tools, languages, libraries and services
  • Operations maintenance support and feedback

    • Strategical organization
    • Pratical implementation

Clone this wiki locally