Skip to content

mhalder/kubernetes-training

Repository files navigation

Kubernetes Training

1. Minikube and kubectl preparation

Set hyperkit as default driver and start minikube

minikube config set driver hyperkit
minikube start

Setup context

kubectx minikube

Create namespace

kubectl create -f namespace.yaml

Setup default namespace

kubectl config set-context --current --namespace nginx-namespace

2. Use local docker image

Set docker env

eval $(minikube docker-env)

Build image

docker build --no-cache -t ubuntu:local .

Testrun in minikube

kubectl run ubuntu-local --image=ubuntu:local --image-pull-policy=Never sleep 100
kubectl get pods
kubectl exec -ti ubuntu-local -- bash
kubectl delete pods ubuntu-local

3. Pod with nodeport service and ubuntu sidecar

Create pod and service and check endpoint

kubectl create -f pod.yaml
kubectl create -f service.yaml
kubectl describe endpoints nginx-service

Test service and pod with sidecar

kubectl exec -ti nginx-pod -c ubuntu-container -- bash
ifconfig
nslookup nginx-service
curl localhost

Test service from different pod

kubectl run -ti --rm ubuntu-local --image=ubuntu:local -- bash
curl nginx-service

Test nodeport from vm

minikube ssh
ifconfig
curl localhost:30973

4. Replicaset with nodeport service

Create replicaset and service and check endpoints

kubectl create -f replicaset.yaml
kubectl create -f replicaset-service.yaml
kubectl describe endpoints nginx-replicaset-service

About

Notes for Kubernetes trainings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published