Difference between revisions of "Microk8s on LXD"

From UVOO Tech Wiki
Jump to navigation Jump to search
 
(3 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://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 75: 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

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

# 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

https://blog.sleeplessbeastie.eu/2020/07/20/how-to-deal-with-missing-apparmor-profiles-for-microk8s-on-lxd/

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