sudo snap install microk8s --classic
sudo usermod -a -G microk8s $USER
newgrp microk8s
microk8s status --wait-ready
alias kubectl="microk8s kubectl"
Note
Its recommended to enable the features one by one, this way you can troubleshoot any issues that may arise.
microk8s enable dns
microk8s enable dashboard
microk8s enable ingress
microk8s enable cert-manager
nano addon_letsencrypt_cluster.yml
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
email: [email protected] # Replace with your email
server: https://acme-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: letsencrypt-prod
solvers:
- http01:
ingress:
class: public
mkctl apply -f addon_letsencrypt_cluster.yml
mkctl get clusterissuer -o wide
mkctl apply -f express-api-nginx-ingress.yml # With cert-manager
#or
mkctl apply -f express-api2-nginx-ingress.yml # Without cert-manager
mkctl get pods -o wide
http://<hostname>
mkctl config > config
scp config $USER@$HOSTNAME:~/.kube/config
nano ~/.kube/config
# find this line
server: https://<ip>:16443
# replace it with
server: https://<public-ip>:16443
kubectl get pods -o wide
Note
If you get an error about accessing the cluster, because your IP is not whitelisted, you can try the following:
sudo nano /var/snap/microk8s/current/certs/csr.conf.template
IP.1=<your-ip> # Continue adding your IP until you reach the last IP
microk8s stop
microk8s start
openssl x509 -in /var/snap/microk8s/current/certs/server.crt -noout -text | grep "IP Address"
# you should see your IP in the output