The Kasten Kickstart Part 2. Installing K3s on Rocky Linux!
We will install K3s a lightweight Kubernetes Distribution
curl -sFl https://get.k3s.io | sh -s - --disable=local-storageCreate a folder in your home directory .kube
mkdir .kube
Copy the generated Kubeconfig file and change ownership to your local username:
sudo cp /etc/rancher/k3s/k3s.yaml .kube/config
sudo chown youruser:youruser .kube/config
We need to make sure that your shell will read from this Kubeconfig file:
Add the following to your .bashrc file, vi or nano .bashrc
export KUBECONFIG=/home/yourusername/.kube/configTo make the changes kick in right away:
exec bash
Now test:
kubectl get nodes
To cut down on typing we can create aliases and enable auto completion. In Rock Linux bash autocompletion is not installed by default so will install that and push the necessary commands for our shell:
dnf install bash-completion -y
source <(kubectl completion bash) # set up autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.I will create an alias called k but you can choose whatever suits you, edit .bashrc and add:
alias k=kubectl
complete -o default -F __start_kubectl k
We will use Helm to install our storage system Longhorn and later Kasten. We need to install that as well:
sudo dnf install helm
helm list
Thinking ahead Kasten uses csi snapshots to create backups and by default K3s does not have the external snapshotter installed, follow these steps to install:
git clone https://github.com/kubernetes-csi/external-snapshotter.git
cd external-snapshotter
kubectl kustomize client/config/crd | kubectl create -f -
kubectl -n kube-system kustomize deploy/kubernetes/snapshot-controller | kubectl create -f -
Now for our storage system Longhorn. Longhorn requires open-iscsi to be installed.
sudo dnf install iscsi-initiator-utils -y
Remember in our lab we are using a single node Kubernetes installation so we don't want Longhorn to try and create its default number of replicas which are 3, since we only have 1 node.
We can influence the way Helm installs its helm charts by using value files.
Let's create the following values file: longhorn_values.yaml
defaultSettings:
defaultReplicaCount: "1"
persistence:
defaultClassReplicaCount: 1
Now we are ready to install Longhorn:
helm install longhorn longhorn/longhorn --namespace longhorn-system --create-namespace --values longhorn_values.yaml
Finally we need to create a volumesnapshotclass for Longhorn.
vi or nano longhorn_volumesnapshotclass.yaml
kind: VolumeSnapshotClass
apiVersion: snapshot.storage.k8s.io/v1
metadata:
name: longhorn
driver: driver.longhorn.io
deletionPolicy: Delete
parameters:
type: snap
Apply the manifest:
k apply -f longhorn_volumesnapshotclass.yaml