## install ```bash # master node curl -sfL https://get.rke2.io | INSTALL_RKE2_VERSION=v1.32.12+rke2r1 sh - systemctl enable rke2-server.service systemctl start rke2-server.service journalctl -u rke2-server -f # open firewalld sudo firewall-cmd --permanent --add-port=9345/tcp sudo firewall-cmd --permanent --add-port=6443/tcp sudo firewall-cmd --permanent --add-port=10250/tcp # Kubelet sudo firewall-cmd --reload # install nerdctl # Set the version VERSION="2.2.1" # Check GitHub for the latest version # Download the tarball wget https://github.com/containerd/nerdctl/releases/download/v${VERSION}/nerdctl-${VERSION}-linux-arm64.tar.gz # Extract to your path sudo tar -C /usr/local/bin -xzvf nerdctl-${VERSION}-linux-arm64.tar.gz nerdctl # configure nerdctl sudo mkdir -p /etc/nerdctl sudo tee /etc/nerdctl/nerdctl.toml <> ~/.bashrc echo 'export PATH=$PATH:/var/lib/rancher/rke2/bin' >> ~/.bashrc source ~/.bashrc ``` ## build and deploy application ```bash # build container with nerdctl nerdctl --namespace k8s.io build --tag hello-world:latest . # export image as tar on master node nerdctl save hello-world:latest -o hello-world.tar # copy it over to worker node scp hello-world.tar novakj@192.168.64.4:~/ # import image on the agent node sudo /var/lib/rancher/rke2/bin/ctr --address /run/k3s/containerd/containerd.sock -n k8s.io images import hello-world.tar kubectl create namespace rke2-apps cat < deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: hello-world-deployment namespace: rke2-apps labels: type: staticwebapp spec: replicas: 1 selector: matchLabels: type: staticwebapp template: metadata: labels: type: staticwebapp spec: containers: - name: staticwebapp image: hello-world:latest imagePullPolicy: Never ports: - containerPort: 80 resources: requests: memory: "32Mi" cpu: "200m" limits: memory: "64Mi" cpu: "300m" EOF kubectl create -f deployment.yaml # expose deployment kubectl expose deployment hello-world-deployment --name hello-world-service --port=8080 --target-port=80 -n rke2-apps # install ingress-nginx (even though i thought that there is ingress controller already deployed) kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.2/deploy/static/provider/cloud/deploy.yaml # create ingress with "localhost" as host kubectl create ingress hello-world-ingress --class=nginx --rule="test-host/*=hello-world-service:8080" -n rke2-apps kubectl port-forward -n ingress-nginx service/ingress-nginx-controller 8081:80 # incomplete completion configuration ;-) dnf install bash-completion -y alias 'k=kubectl' # ~/.bashrc # 1. Load the main bash-completion package first # On Rocky/RHEL, it's usually at this path: [[ -r "/usr/share/bash-completion/bash_completion" ]] && . "/usr/share/bash-completion/bash_completion" # Enable kubectl bash completion source <(kubectl completion bash) # Set up the alias alias k=kubectl # Link the kubectl completion logic to the 'k' alias complete -o default -F __start_kubectl k ``` ## upgrading RKE2 ```bash # install upgrade controller kubectl apply -f https://github.com/rancher/system-upgrade-controller/releases/download/v0.9.1/system-upgrade-controller.yaml # server upgrade cat <