Skip to content

Getting started with kubernetes, tutorial for beginners, kubernetes tutorial

Notifications You must be signed in to change notification settings

zoltan-nz/playing-with-kubernetes

Repository files navigation

Playing with Kubernetes

The following instruction is mainly relevant for macOS.

Getting started with Kubernetes

Readings

Setup WebUI(Dashboard) or Use Octant

$ brew install octant
$ octant

Console based manager tool k9s

brew install derailed/k9s/k9s

Using Waveworks Scope

kubectl apply -f "https://cloud.weave.works/k8s/scope.yaml?k8s-version=$(kubectl version | base64 | tr -d '\n')"
kubectl port-forward -n weave "$(kubectl get -n weave pod --selector=weave-scope-component=app -o jsonpath='{.items..metadata.name}')" 4040

Open: http://localhost:4040

Getting information about your cluster and nodes

$ kubectl cluster-info
$ kubectl get nodes

Monitoring

Helm

brew install helm
helm init --service-account tiller

Deployment

Source

Let's create our simple application in Node.js

  • Check ./hello-world-app folder.
  • Check ./hello-world-app/Dockerfile.
$ docker build -t zoltannz/kubernetes-app.
$ docker run -p 3000:3000 zoltannz/kubernetes-app
$ docker push zoltannz/kubernetes-app

Deploy

$ kubectl get nodes
$ open localhost:8001
$ kubectl run hello-world --image=zoltannz/kubernetes-app --port=3000
  • searched for a suitable node where an instance of the application could be run (we have only 1 available node)
  • scheduled the application to run on that Node
  • configured the cluster to reschedule the instance on a new Node when needed
  • Check pods on Dashboard.
  • Deploy container with GUI.
$ kubectl get deployments
  • Kubernetes run pods in an isolated network, we have to open it up.
$ kubectl proxy
$ open http://localhost:8001/api/v1/proxy/namespaces/default/pods/hello-world-542297729-zc06m/

Playing with our deployed containers:

$ kubectl get
$ kubectl describe
$ kubectl logs
$ kubectl exec

Expose to public:

$ kubectl get services
$ kubectl expose deployment hello-world --type=NodePort --port 3000
$ minikube service hello-world

Running command inside in our Pod container

$ kubectl exec -ti hello-world-4149272534-4627k /bin/sh

Namespace

Create namespace for the-pipeline:

kubectl create namespace the-pipeline

Create the-pipeline context for the the-pipeline namespace.

kubectl config set-context the-pipeline --namespace=the-pipeline

Minikube

Prerequisites:

brew install hyperkit
brew install docker-machine-driver-hyperkit

Trying to create a new docker-machine but dnsmasq dhcp options not picked up.

docker-machine create --driver hyperkit --engine-opt dns=10.254.254.254

Add listen-address=192.168.64.1 to dnsmasq.conf. But it works only if the cluster already started.

brew install kubernetes-cli
brew cask install minikube

Start minikube with hyperkit VM, custom domain name, custom cpu number, and hard drive allocation.

minikube start --vm-driver hyperkit --dns-domain "minikube.loc" --cpus 4 --memory 6114 --disk-size 64g

Kubernetes vs Openshift

Create a Registry in Minikube

Kubernetes Cheat Sheet

Using MicroK8s with Multipass on macOS

Install Multipass Ubuntu virtual machine runner tool with brew:

brew cask install multipass

Run a virtual machine. The following command will create a vm with 100G disk, 16G memory and 8 cores CPU.

multipass launch -n primary -c 8 -d 100G -m 16G
multipass exec primary -- sudo apt update -y && sudo apt dist-upgrade -y
multipass exec primary -- sudo snap install microk8s --classic
multipass exec primary -- sudo usermod -a -G microk8s multipass
multipass exec primary -- sudo iptables -P FORWARD ACCEPT

About

Getting started with kubernetes, tutorial for beginners, kubernetes tutorial

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published