To enable ingress:
- Docker desktop - https://kubernetes.github.io/ingress-nginx/deploy/#docker-for-mac
- Using kubectl -
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.3.0/deploy/static/provider/cloud/deploy.yaml
- Using helm -
helm upgrade --install ingress-nginx ingress-nginx \ --repo https://kubernetes.github.io/ingress-nginx \ --namespace ingress-nginx --create-namespace
- Using kubectl -
- Minikube -
minikube addons enable ingress
If you want to test application inside repository - do not forget to:
- Span all preparation containers - kubectl apply -f kubernetes/preparation
- Build application - docker build -t $registry/$image_name:$tag $directory
- Push application - docker push -t (tag from previous step)
- Change image section in deployment.yaml file to new $registry/$image_name:$tag
To access docker registry:
- Register on https://hub.docker.com/
- Now your image tag will look like $your_login/$image_name:$tag
To create your own registry:
To use minikube registry:
To install image directly to minikube:
- minikube image build -t $image:$tag -f $dockerfile_path $dockerfile_directory
- minikube image build -t books:minikube -f Dockerfile . (Example)
Step-by-step instruction - Application with Cluster IP service and Ingress
- kubectl apply -f kubernetes/examples/application-cluster-ip
- Do not forget to turn Ingress addon on if you are using minikube
- Add IP of your cluster to /etc/hosts file (Windows C:\Windows\System32\drivers\etc\hosts):
- Check if it is working: curl -v ingress.local
Step-by-step instruction - Application with NodePort service
- kubectl apply -f kubernetes/examples/application-nodeport
- Check if it is working: curl $(minikube ip):30007 | curl localhost:30007
- Be aware, on OS (Windows, Mac with Minikube) abstraction won't be reachable. Don't be afraid, it is working.
- Access NodePort on minikube (https://minikube.sigs.k8s.io/docs/handbook/accessing/)
- kubernetes/application - application abstractions
- kubernetes/configuration - configuration abstractions
- kubernetes/network - network abstractions
- kubernetes/preparation - abstractions for presentation
- kubernetes/job - abstractions for job
- kubernetes/examples - ready to deploy applications based on Nginx image
Short names:
- configmap – cm
- pod – po
- services – svc
- ingress – ing
All contexts are placed in file: ~/.kube/config
- kubectl config get-contexts – find all available contexts
- kubect config use-context $-context_name- – use the context for kubectl
- kubectl edit $resource -n $namespace $resource_name
- Example: kubectl edit secrets -n trends plutus-tls
- kubectl describe $resource -n $namespace $resource_name
- Example: kubectl describe pod -n trends plutus-integ-asdasd-123we
- kubectl get $resource -n $namespace $resource_name -o $format some.$format – download resource as file with specific format (json, yaml).
- Example: kubectl get cm -n trends coolmap -o yaml some.yaml
- kubectl get $resource -n $namespace – all resources in the namespace
- kubectl get $resource --all-namespaces – all resource in all namespaces
- kubectl exec -n $namespace -it $pod_name - - /bin/sh – working inside a container
- kubectl logs -n $namespace $pod_name – get pod logs
- minikube node add - add another node for minikube
- minikube addons list - all addons for minikube
- minikube addons enable $addon_name - enable any addon for minikube
- minikube image build -t $tag $directory - build image directly to minikube
- minikube mount $from:$to - mount directory to minikube
- minikube ip - show ip address of minikube
- minikube —help - help description of minikube commands