Instruction
How to prepare microk8s in ubuntu24.10 for application development
Required resources
- [X] ubuntu 24.10
- [X] 24Gb memory
- [X] 10 cores
Steps
- prepare ubuntu 24.10 (vm or install to your PC)
- make sure that you have static local ip for your ubuntu (if ip will change, microk8s become unavailable)
- install microk8s, kubectl and helm
for package in "microk8s --classic" "helm --classic" "kubectl --classic" ; do sudo snap install $package; done
- fix permissons to microk8s for non root user
sudo usermod -a -G microk8s $USER
mkdir ~/.kube
- enable important k8s operators for development
microk8s enable dns
microk8s enable dashboard
microk8s enable storage
microk8s enable ingress
microk8s enable registry
microk8s enable cert-manager
microk8s enable prometheus
- check k8s single node cluster status
microk8s status
- save root user kubeconfig
microk8s config > ~/.kube/config
chmod 600 ~/.kube/config
- check that kubectl works
kubectl version
- get kubectl web dashboard token
kubectl get secret microk8s-dashboard-token --namespace=kube-system -o jsonpath="{.data.token}" | base64 --decode ; echo
Create ingress for operators
- create dasboard-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dashboard
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
ingressClassName: nginx
tls:
- hosts:
- dashboard.k8s.localhost
rules:
- host: dashboard.k8s.localhost
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kubernetes-dashboard
port:
number: 443
- create grafana-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: grafana
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
spec:
tls:
- hosts:
- 'grafana.k8s.localhost'
ingressClassName: nginx
rules:
- host: 'grafana.k8s.localhost'
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kube-prom-stack-grafana
port:
number: 80
- create prometeus-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: prometheus
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
ingressClassName: nginx
tls:
- hosts:
- prometheus.k8s.localhost
rules:
- host: prometheus.k8s.localhost
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: prometheus-operated
port:
number: 9090
- deploy ingresses
kubectl apply -f dasboard-ingress.yaml --namespace=kube-system
kubectl apply -f grafana-ingress.yaml --namespace=observability
kubectl apply -f prometeus-ingress.yaml --namespace=observability
- in web browser try to login to kubernetes dashboard https://dashboard.k8s.localhost with token
Create self signed certificates issuer
- create selfsigned-cluster-issuer.yaml
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: selfsigned-cluster-issuer
spec:
selfSigned: {}
- deploy selfsigned-cluster-issuer
kubectl apply -f selfsigned-cluster-issuer.yaml --namespace=cert-manager
Create custom application namespace
- create applicatoins-ns.yaml
kind: Namespace
apiVersion: v1
metadata:
name: applications
- deploy applicatoins namespace
kubectl apply -f applicatoins-ns.yaml
Documentation
How to use microk8s single node cluster
- switch to applications namespace
kubectl config set-context --current --namespace=applications
- get current namespace
kubectl config view --minify -o jsonpath='{..namespace}'; echo
Feel free to use it!
Cluster hot links:
- https://dashboard.k8s.localhost
- https://grafana.k8s.localhost/?orgId=1 (admin/prom-operator)
- https://prometheus.k8s.localhost/targets?search=
Persistent volumes for microk8s
- default persistent volumes stogare path: /var/snap/microk8s/common/default-storage