Dmitrii Kostakov

Instruction

How to prepare microk8s in ubuntu24.10 for application development

Required resources

Steps

for package in "microk8s --classic" "helm --classic" "kubectl --classic" ; do sudo snap install $package; done
sudo usermod -a -G microk8s $USER
mkdir ~/.kube
microk8s enable dns
microk8s enable dashboard
microk8s enable storage
microk8s enable ingress
microk8s enable registry
microk8s enable cert-manager
microk8s enable prometheus
microk8s status
microk8s config > ~/.kube/config
chmod 600 ~/.kube/config
kubectl version
kubectl get secret microk8s-dashboard-token --namespace=kube-system -o jsonpath="{.data.token}" | base64 --decode ; echo

Create ingress for operators

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
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
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
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

Create self signed certificates issuer

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: selfsigned-cluster-issuer
spec:
  selfSigned: {}
kubectl apply -f selfsigned-cluster-issuer.yaml --namespace=cert-manager

Create custom application namespace

kind: Namespace
apiVersion: v1
metadata:
  name: applications
kubectl apply -f applicatoins-ns.yaml

Documentation

How to use microk8s single node cluster

kubectl config set-context --current --namespace=applications
kubectl config view --minify -o jsonpath='{..namespace}'; echo

Feel free to use it!

Persistent volumes for microk8s