Skip to content

Instantly share code, notes, and snippets.

@mrimp
Last active November 20, 2021 22:12
Show Gist options
  • Save mrimp/3b52c2d5561de9b370e0c2ae0a4f36ca to your computer and use it in GitHub Desktop.
Save mrimp/3b52c2d5561de9b370e0c2ae0a4f36ca to your computer and use it in GitHub Desktop.
Personal K3S Cluster managed w/kr83

Install docker

curl -sSL https://get.docker.com | sh

Fix the user permissions for running docker (seeing errors in this section is OK)

sudo usermod -aG docker $USER sudo chown "$USER":"$USER" /home/"$USER"/.docker -R sudo chmod g+rwx "/home/$USER/.docker" -R sudo chown "$USER":"$USER" /var/run/docker.sock sudo chmod g+rwx /var/run/docker.sock -R sudo systemctl enable docker

Docker Compose

sudo apt-get update && sudo apt install -qy python3-pip && pip3 install docker-compose

Arkade

curl -SLfs https://dl.get-arkade.dev | sudo sh

Add tools bin directory to PATH

echo "export PATH=$HOME/.arkade/bin:$PATH" >> ~/.bashrc

Copy bash completion script

arkade completion bash > ~/arkade_bash_completion.sh echo "source ~/arkade_bash_completion.sh" >> ~/.bashrc

Starting bash completion

source ~/.bashrc

Kubectl

arkade get kubectl

Kubectl bash completion

echo 'source <(kubectl completion bash)' >>~/.bashrc

Starting bash completion

source ~/.bashrc

Kustomize

arkade get kustomize

Helm

arkade get helm

K3sup

arkade get k3sup

Kompose for converting docker-compose

curl -L https://github.com/kubernetes/kompose/releases/download/v1.22.0/kompose-linux-amd64 -o kompose

chmod +x kompose sudo mv ./kompose /usr/local/bin/kompose echo 'source <(kompose completion bash)' >>~/.bashrc source ~/.bashrc

k3s install

k3sup install
--ip YOUR_VM_IP
--cluster
--user ubuntu
--k3s-channel stable
--local-path ~/.kube/config
--merge --context k3s
--k3s-extra-args '--no-deploy traefik --write-kubeconfig-mode 644'

Move kube config

mkdir ~/.kube cp /etc/rancher/k3s/k3s.yaml /.kube/config echo "export KUBE_CONFIG=/.kube/config" >> .bashrc

alias kubectl="k3s kubectl"

kubectl get nodes -o wide

k3sup join
--server-ip YOUR_FIRST_VM_IP
--ip CURRENT_VM_IP
--user ubuntu
--k3s-channel stable
--k3s-extra-args '--no-deploy traefik --write-kubeconfig-mode 644'

Install nginx ingress

arkade install ingress-nginx --namespace default

Cert-manager for letsencrypt certificates

arkade install cert-manager

Add the longhorn helm repository

helm repo add longhorn https://charts.longhorn.io

Update helm repos

helm repo update

Create the namespace

kubectl create namespace longhorn-system

Install longhorn

helm install longhorn longhorn/longhorn --namespace longhorn-system

Check everything went smooth

kubectl -n longhorn-system get pod

Check out the longhorn service

kubectl -n longhorn-system get svc

Forward the port to check the configuration

kubectl port-forward -n longhorn-system svc/longhorn-frontend 8002:80

You should now be able to open the longhorn dashboard from “http://localhost:8002”

Instakk kr8s

git clone https://github.com/oslabs-beta/kr8s.git cd kr8s npm install npm run start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment