Difference between revisions of "Microk8s on LXD 2"

From UVOO Tech Wiki
Jump to navigation Jump to search
Line 13: Line 13:
  
  
 +
# NFS as default storage
 +
 +
 +
## NFS Server
 +
nfs server centos 8 with hostname nas in dns
 
```
 
```
sudo apt install nfs-client
+
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
 
mkdir /var/snap/microk8s/common/default-storage
 
echo "nas:/kub/default-storage  /var/snap/microk8s/common/default-storage  nfs" >> /etc/fstab
 
echo "nas:/kub/default-storage  /var/snap/microk8s/common/default-storage  nfs" >> /etc/fstab

Revision as of 20:25, 20 March 2021

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

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