Difference between revisions of "Microk8s on LXD"
Jump to navigation
Jump to search
(9 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | # Kubernetes Cluster in less than 15 minutes on Ubuntu | ||
+ | - https://medium.com/@ridwanfajar/getting-started-with-microk8s-up-and-running-kubernetes-locally-310640dae156 | ||
+ | - https://linuxcontainers.org/lxd/getting-started-cli/ | ||
- https://microk8s.io/docs/lxd | - https://microk8s.io/docs/lxd | ||
+ | |||
+ | Begin with a simple Ubuntu 20.04 host with LXD installed: snap install lxd - https://linuxcontainers.org/lxd/getting-started-cli/ | ||
``` | ``` | ||
lxc profile create microk8s | lxc profile create microk8s | ||
Line 10: | Line 15: | ||
``` | ``` | ||
− | + | h1 | |
``` | ``` | ||
lxc exec h1 /bin/bash | lxc exec h1 /bin/bash | ||
Line 18: | Line 23: | ||
``` | ``` | ||
− | + | h2 | |
+ | ``` | ||
+ | snap install microk8s --classic --channel=1.19/stable | ||
+ | microk8s join 10.28.99.198:25000/<output from existing node microk8s add-node> | ||
+ | ``` | ||
+ | |||
+ | h3 | ||
``` | ``` | ||
snap install microk8s --classic --channel=1.19/stable | snap install microk8s --classic --channel=1.19/stable | ||
microk8s join 10.28.99.198:25000/<output from existing node microk8s add-node> | microk8s join 10.28.99.198:25000/<output from existing node microk8s add-node> | ||
``` | ``` | ||
+ | |||
+ | Enable dash on h1 | ||
+ | ``` | ||
+ | microk8s enable dashboard | ||
+ | token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1) | ||
+ | microk8s kubectl -n kube-system describe secret $token | ||
+ | microk8s kubectl port-forward -n kube-system service/kubernetes-dashboard 11443:443 | ||
+ | ``` | ||
+ | lxc config device add h1 tcp33443 proxy listen=tcp:0.0.0.0:33443 connect=tcp:127.0.0.1:11443 | ||
+ | |||
+ | browse to https://mylxdhostfromcmdabove:33443/ | ||
+ | |||
+ | # Namespace Getters in kubernetes | ||
+ | - https://kubernetes.io/docs/reference/kubectl/cheatsheet/#viewing-finding-resources | ||
+ | - https://microk8s.io/docs | ||
+ | ``` | ||
+ | # alias kubectl='microk8s kubectl' | ||
+ | microk8s kubectl get all | ||
+ | microk8s kubectl get nodes | ||
+ | microk8s kubectl get services | ||
+ | microk8s kubectl get pods | ||
+ | |||
+ | ``` | ||
+ | |||
+ | |||
+ | # Other | ||
+ | |||
- https://kubernetes.io/docs/reference/kubectl/cheatsheet/#viewing-finding-resources | - https://kubernetes.io/docs/reference/kubectl/cheatsheet/#viewing-finding-resources | ||
Line 40: | Line 78: | ||
``` | ``` | ||
+ | |||
+ | # NFS as default storage | ||
+ | |||
+ | |||
+ | # NFS Server | ||
+ | nfs server centos 8 with hostname nas in dns | ||
+ | ``` | ||
+ | sudo dnf install nfs-utils | ||
+ | systemctl enable --now nfs-server | ||
+ | systemctl status nfs-server | ||
+ | ``` | ||
+ | |||
+ | /etc/exports | ||
+ | ``` | ||
+ | /kub/default-storage *(rw,sync,no_subtree_check,insecure,no_root_squash) | ||
+ | # var/nfs 10.x.x.x/32(rw,sync,no_subtree_check,insecure) 10.x.x.x/32(rw,sync,no_subtree_check,insecure) 10.x.x.x/32(rw,sync,no_subtree_check,insecure) | ||
+ | # /nas/share *(rw,sync,no_subtree_check,insecure) | ||
+ | ``` | ||
+ | |||
+ | # NFS Clients on Each Kubernetes Node | ||
+ | |||
+ | Make default storage class (hostpath) an nfs hostpath | ||
+ | ``` | ||
+ | sudo apt install -y nfs-client | ||
+ | mkdir /var/snap/microk8s/common/default-storage | ||
+ | echo "nas:/kub/default-storage /var/snap/microk8s/common/default-storage nfs" >> /etc/fstab | ||
+ | mount -a | ||
+ | microk8s stop && microk8s start | ||
+ | ``` | ||
# Refs | # Refs |
Latest revision as of 20:24, 20 March 2021
Kubernetes Cluster in less than 15 minutes on Ubuntu
- https://medium.com/@ridwanfajar/getting-started-with-microk8s-up-and-running-kubernetes-locally-310640dae156
- https://linuxcontainers.org/lxd/getting-started-cli/
- https://microk8s.io/docs/lxd
Begin with a simple Ubuntu 20.04 host with LXD installed: snap install lxd - https://linuxcontainers.org/lxd/getting-started-cli/
lxc profile create microk8s wget https://raw.githubusercontent.com/ubuntu/microk8s/master/tests/lxc/microk8s-zfs.profile -O microk8s.profile cat microk8s.profile | lxc profile edit microk8s lxc launch -p default -p microk8s ubuntu:20.04 h1 lxc launch -p default -p microk8s ubuntu:20.04 h2 lxc launch -p default -p microk8s ubuntu:20.04 h3
h1
lxc exec h1 /bin/bash snap install microk8s --classic --channel=1.19/stable microk8s status microk8s add-node
h2
snap install microk8s --classic --channel=1.19/stable microk8s join 10.28.99.198:25000/<output from existing node microk8s add-node>
h3
snap install microk8s --classic --channel=1.19/stable microk8s join 10.28.99.198:25000/<output from existing node microk8s add-node>
Enable dash on h1
microk8s enable dashboard token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1) microk8s kubectl -n kube-system describe secret $token microk8s kubectl port-forward -n kube-system service/kubernetes-dashboard 11443:443
lxc config device add h1 tcp33443 proxy listen=tcp:0.0.0.0:33443 connect=tcp:127.0.0.1:11443
browse to https://mylxdhostfromcmdabove:33443/
Namespace Getters in kubernetes
- https://kubernetes.io/docs/reference/kubectl/cheatsheet/#viewing-finding-resources
- https://microk8s.io/docs
# alias kubectl='microk8s kubectl' microk8s kubectl get all microk8s kubectl get nodes microk8s kubectl get services microk8s kubectl get pods
Other
LXD issues with app armour
Run on all k8s nodes
aa-status apparmor_parser --add /var/lib/snapd/apparmor/profiles/snap.microk8s.*
micro-k8s status micro-k8s add-node
NFS as default storage
NFS Server
nfs server centos 8 with hostname nas in dns
sudo dnf install nfs-utils systemctl enable --now nfs-server systemctl status nfs-server
/etc/exports
/kub/default-storage *(rw,sync,no_subtree_check,insecure,no_root_squash) # var/nfs 10.x.x.x/32(rw,sync,no_subtree_check,insecure) 10.x.x.x/32(rw,sync,no_subtree_check,insecure) 10.x.x.x/32(rw,sync,no_subtree_check,insecure) # /nas/share *(rw,sync,no_subtree_check,insecure)
NFS Clients on Each Kubernetes Node
Make default storage class (hostpath) an nfs hostpath
sudo apt install -y nfs-client mkdir /var/snap/microk8s/common/default-storage echo "nas:/kub/default-storage /var/snap/microk8s/common/default-storage nfs" >> /etc/fstab mount -a microk8s stop && microk8s start
Refs
- https://microk8s.io/high-availability
- https://microk8s.io/docs/clustering
- https://microk8s.io/docs/addon-dashboard
- https://blog.getambassador.io/explore-the-ambassador-api-gateway-with-microk8s-f75a7a295113#:~:text=With%20MicroK8s%20v1.,a%20great%20fit%20for%20MicroK8s.&text=Ambassador%20is%20now%20ready%20for,Controller%20in%20your%20local%20cluster.
- https://www.getambassador.io/docs/latest/topics/running/running/
- https://kubernetes.io/docs/tutorials/stateless-application/expose-external-ip-address/