Difference between revisions of "Microk8s on LXD 2"
Jump to navigation
Jump to search
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | ``` | ||
+ | snap install microk8s --classic --channel=1.22/stable | ||
+ | microk8s enable dns helm ingress rbac registry storage | ||
+ | microk8s add-node | ||
+ | |||
+ | # NAS | ||
+ | lxc storage volume create default nas1zfs --type=block size=200GiB | ||
+ | lxc config device add nas1 nas1zfs disk pool=default source=nas1zfs | ||
+ | # lxc profile device add default root disk path=/ pool=default | ||
+ | curl -LO https://raw.githubusercontent.com/jeremybusk/nfs/main/nfs-k8s-localpath.sh && chmod +x nfs-k8s-localpath.sh | ||
+ | apt install -y uuid | ||
+ | uuid | ||
+ | ``` | ||
+ | |||
+ | |||
+ | |||
+ | See https://microk8s.io/docs/high-availability | ||
+ | |||
``` | ``` | ||
for i in kub1 kube2 kube3; do | for i in kub1 kube2 kube3; do | ||
Line 7: | Line 25: | ||
lxc exec $i -- printf "alias kubectl='microk8s kubectl'\nalias k='microk8s kubectl'" >> /root/.bashrc | lxc exec $i -- printf "alias kubectl='microk8s kubectl'\nalias k='microk8s kubectl'" >> /root/.bashrc | ||
joincmd=$(lxc exec kub1 -- microk8s add-node | sed -n '2p') | joincmd=$(lxc exec kub1 -- microk8s add-node | sed -n '2p') | ||
− | done | + | $($joincmd) |
+ | done | ||
+ | ``` | ||
+ | |||
+ | lxc shell kube1 | ||
+ | ``` | ||
+ | microk8s enable dns helm ingress rbac registry storage | ||
+ | ``` | ||
+ | |||
+ | Using Kubectl instead of aliasing microk8s.kubectl | ||
+ | ``` | ||
+ | mkdir $HOME/.kube | ||
+ | microk8s config > $HOME/.kube/config | ||
+ | snap install kubectl --classic | ||
+ | kubectl get nodes | ||
+ | ``` | ||
+ | |||
+ | |||
+ | # openebs jiva | ||
+ | - https://docs.openebs.io/docs/next/prerequisites.html#ubuntu | ||
+ | - https://docs.openebs.io/docs/next/installation.html | ||
+ | |||
+ | ``` | ||
+ | systemctl enable --now iscsid | ||
+ | ``` | ||
+ | |||
+ | |||
+ | # NFS as default storage | ||
+ | |||
+ | |||
+ | ## NFS Server | ||
+ | nfs server centos 8 with hostname nas in dns | ||
+ | ``` | ||
+ | sudo dnf install nfs-utils uuid | ||
+ | systemctl enable --now nfs-server | ||
+ | systemctl status nfs-server | ||
+ | mkdir -p /kub/default-storage | ||
+ | chmod 0777 /kub/default-storage | ||
+ | mkdir -p /kub/standard-ebf8a3e6-89ba-11eb-9e15-00163e0308c0 | ||
+ | chmod 0777 /kub/standard-ebf8a3e6-89ba-11eb-9e15-00163e0308c0 | ||
+ | ``` | ||
+ | |||
+ | /etc/exports | ||
+ | ``` | ||
+ | /kub/default-storage *(rw,sync,no_subtree_check,insecure,no_root_squash) | ||
+ | /kub/standard-ebf8a3e6-89ba-11eb-9e15-00163e0308c0 *(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 | ||
+ | ``` | ||
+ | |||
+ | |||
+ | https://github.com/rancher/local-path-provisioner | ||
+ | ``` | ||
``` | ``` |
Latest revision as of 19:54, 11 August 2021
snap install microk8s --classic --channel=1.22/stable microk8s enable dns helm ingress rbac registry storage microk8s add-node # NAS lxc storage volume create default nas1zfs --type=block size=200GiB lxc config device add nas1 nas1zfs disk pool=default source=nas1zfs # lxc profile device add default root disk path=/ pool=default curl -LO https://raw.githubusercontent.com/jeremybusk/nfs/main/nfs-k8s-localpath.sh && chmod +x nfs-k8s-localpath.sh apt install -y uuid uuid
See https://microk8s.io/docs/high-availability
for i in kub1 kube2 kube3; do lxc init ubuntu:20.04 $i --vm -c limits.cpu=4 -c limits.memory=8GB lxc config device override $i root size=32GB lxc start $i lxc exec $i -- snap install microk8s --classic lxc exec $i -- printf "alias kubectl='microk8s kubectl'\nalias k='microk8s kubectl'" >> /root/.bashrc joincmd=$(lxc exec kub1 -- microk8s add-node | sed -n '2p') $($joincmd) done
lxc shell kube1
microk8s enable dns helm ingress rbac registry storage
Using Kubectl instead of aliasing microk8s.kubectl
mkdir $HOME/.kube microk8s config > $HOME/.kube/config snap install kubectl --classic kubectl get nodes
openebs jiva
- https://docs.openebs.io/docs/next/prerequisites.html#ubuntu
- https://docs.openebs.io/docs/next/installation.html
systemctl enable --now iscsid
NFS as default storage
NFS Server
nfs server centos 8 with hostname nas in dns
sudo dnf install nfs-utils uuid systemctl enable --now nfs-server systemctl status nfs-server mkdir -p /kub/default-storage chmod 0777 /kub/default-storage mkdir -p /kub/standard-ebf8a3e6-89ba-11eb-9e15-00163e0308c0 chmod 0777 /kub/standard-ebf8a3e6-89ba-11eb-9e15-00163e0308c0
/etc/exports
/kub/default-storage *(rw,sync,no_subtree_check,insecure,no_root_squash) /kub/standard-ebf8a3e6-89ba-11eb-9e15-00163e0308c0 *(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
https://github.com/rancher/local-path-provisioner
<br />