k0s updates

This commit is contained in:
2025-10-30 22:51:17 -04:00
parent 57ae6b7e72
commit 6df02e8dff
13 changed files with 185 additions and 42 deletions

124
active/software_k0s/k0s.md Normal file
View File

@@ -0,0 +1,124 @@
# K0s
## Install Single Node Cluster
<https://docs.k0sproject.io/v0.11.0/k0s-single-node/>
```bash
# Allow all traffic in
firewall-cmd --set-default-zone=trusted
# Install k0s cli
curl -sSLf https://get.k0s.sh | sudo sh
# Setup the config
k0s config create > k0s.yaml
# Install single node cluster controller/node
k0s install controller -c k0s.yaml --enable-worker
# Start and enable the service
systemctl enable --now k0scontroller
# Enable bash completion
echo 'source <(k0s completion bash)' >>~/.bashrc
source ~/.bashrc
# Make an admin user
mkdir ~/.kube
k0s kubeconfig create --groups "system:m asters" admin > ~/.kube/config
# Remove the taint that prevents scheduling on the controller
kubectl edit node
```
## Install Multi Node Cluster
<https://docs.k0sproject.io/v0.11.0/k0s-multi-node/>
Install the controller on the controller machine
```bash
# Allow all traffic in
firewall-cmd --set-default-zone=trusted
# Install k0s cli
curl -sSLf https://get.k0s.sh | sudo sh
# Save default config
k0s config create > k0s.yaml
# Install the controller
k0s install controller
# Enable the controller
systemctl enable --now k0scontroller
# Enable bash completion
echo 'source <(k0s completion bash)' >>~/.bashrc
source ~/.bashrc
# Make an admin user (scp ~/.kube/config to your operator machine)
# kubectl config set-context --current --namespace kube-system
mkdir ~/.kube
k0s kubeconfig create --groups "system:masters" admin > ~/.kube/config
# Generate a worker join token
k0s token create --role=worker > worker0-token
```
Now on the worker machine, install the worker
```bash
# Allow all traffic in
firewall-cmd --set-default-zone=trusted
# On the operator, copy the token file from the controller to the worker
scp vm-k0s-controller:worker0-token vm-k0s-worker:token-file
# Install k0s cli
curl -sSLf https://get.k0s.sh | sudo sh
# Join the worker
k0s install worker --token-file token-file
# Start the service
systemctl enable --now k0sworker
# Enable bash completion
echo 'source <(k0s completion bash)' >>~/.bashrc
source ~/.bashrc
```
## Uninstall
```bash
systemctl stop k0scontroller
k0s reset
reboot
```
## Install Metallb
<https://docs.k0sproject.io/v1.26.0+k0s.0/examples/metallb-loadbalancer/>
1. Create a VLAN with a dedicated subnet for Metallb. Disable DHCP.
2. Attach this new VLAN to your worker nodes
3. Assign the worker nodes an address within the created network.
4. Install Metallb. Check `active/software_k0s/metallb-configmap.yaml` before proceeding.
```bash
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/metallb.yaml
kubectl apply -f active/software_k0s/metallb-configmap.yaml
```
### Uninstall Metallb
```bash
kubectl delete -f active/software_k0s/metallb-configmap.yaml
kubectl delete -f https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/metallb.yaml
kubectl delete -f https://raw.githubusercontent.com/metallb/metallb/v0.10.2/manifests/namespace.yaml
```

View File

@@ -0,0 +1,12 @@
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 192.168.123.100-192.168.123.254