Skip to main content

Manually Installing on RHEL

AHD VM can be installed manually on a RedHat Enterprise Linux based virtual machine instead of a Fedora CoreOS one.

The following instructions are related to RHEL 9.4. Please refer to Red Hat for notes, requirements and support.

RHEL was chosen as a valid Linux distribution since it's also based on Fedora (just like Fedora CoreOS), but offers enterprise support.

Update RHEL configurations​

As documented in k3s documentation, either turn off firewalld or add some new rules.

To turn off firewalld:

systemctl disable firewalld --now

If you wish to keep firewalld enabled, update its rules with the following commands:

firewall-cmd --permanent --add-port=6443/tcp #apiserver
firewall-cmd --permanent --zone=trusted --add-source=10.42.0.0/16 #pods
firewall-cmd --permanent --zone=trusted --add-source=10.43.0.0/16 #services
firewall-cmd --reload

After either disabling firewalld or updating its rules, disable nm-cloud-setup:

sudo systemctl disable nm-cloud-setup.service nm-cloud-setup.timer

Finally, reboot the virtual machine:

sudo reboot

Install required packages​

Install the following packages, required by AHD VM. Some of the packages may already be present on your virtual machine.

# install utilities
sudo yum install iptables nano git bash-completion -y

# install k3s
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_CHANNEL=stable sh -

Setup AHD VM​

Through the following script you will setup folders, install and configure software for AHD. See the inline comments for more details on each command.

Save the following script as initial-setup.sh

#!/usr/bin/env sh

set -x
set -e

# create volume home directory
mkdir -p $HOME/k3s-volumes

# setup bash completion and kubeconfig
echo "source <(kubectl completion bash)" >> $HOME/.bashrc
echo "alias k=kubectl" >> $HOME/.bashrc
echo "complete -o default -F __start_kubectl k" >> $HOME/.bashrc
echo "export KUBECONFIG=/etc/rancher/k3s/k3s.yaml" >> $HOME/.bashrc

# install Helm
curl -L https://get.helm.sh/helm-v3.16.4-linux-amd64.tar.gz -o /tmp/helm.tar.gz
tar -zxvf /tmp/helm.tar.gz -C /tmp/
sudo mv /tmp/linux-amd64/helm /usr/local/bin/helm

# setup a temporary directory to work in
TMP_DIR="$(mktemp -d)"
cd "${TMP_DIR}"

# install Kubectl Krew
OS="$(uname | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
KREW="krew-${OS}_${ARCH}"
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz"
tar zxvf "${KREW}.tar.gz"

./"${KREW}" install krew
echo "export PATH=\"\${KREW_ROOT:-\$HOME/.krew}/bin:\$PATH\"" >> $HOME/.bashrc

# install troubleshoot plugins
$HOME/.krew/bin/kubectl-krew install preflight
$HOME/.krew/bin/kubectl-krew install support-bundle

# install helm diff plugin
helm plugin install https://github.com/databus23/helm-diff

# add AHD repos
helm repo add smartkit https://repo.smeup.cloud/nexus/repository/smartkit
helm repo up

# cleanup temp dir
rm -rf "${TMP_DIR}"

Run the script with bash initial-setup.sh

The script does not require sudo access.


Through the following script you will configure k3s storage and networking.

Create the file setup-config.sh with the following content:

In line 7 of the script, make sure to change 'YOUR_USERNAME' with the username of the main linux user of the virtual machine.
#!/bin/bash

set -e
set -x

# Change "YOUR_USERNAME" with the main user's name
USER=YOUR_USERNAME

# Configure volume provider
cat > /var/lib/rancher/k3s/server/manifests/smeup-k3s-storage.yaml << EOF
---
kind: ConfigMap
apiVersion: v1
metadata:
name: local-path-config
namespace: kube-system
data:
config.json: |-
{
"nodePathMap":[
{
"node":"DEFAULT_PATH_FOR_NON_LISTED_NODES",
"paths":["/home/$USER/k3s-volumes"]
}
]
}
setup: |-
#!/bin/sh
set -eu
mkdir -m 0777 -p "\${VOL_DIR}"
chmod 700 "\${VOL_DIR}/.."
teardown: |-
#!/bin/sh
set -eu
rm -rf "\${VOL_DIR}"
helperPod.yaml: |-
apiVersion: v1
kind: Pod
metadata:
name: helper-pod
spec:
containers:
- name: helper-pod
image: "rancher/mirrored-library-busybox:1.36.1"
imagePullPolicy: IfNotPresent
EOF

# set file permissions
chmod 644 /var/lib/rancher/k3s/server/manifests/traefik-cfg.yaml
chmod 644 /var/lib/rancher/k3s/server/manifests/smeup-k3s-storage.yaml

Run the script with sudo bash setup-config.sh

The script requires sudo access to interact with files under `/var/lib/rancher/k3s/...`
It will not install any new software or change any other configuration.

Test setup​

You have completed the manual installation of AHD VM on RHEL.

You can now delete the setup-config.sh and initial-setup.sh script files.

To check if everything is working correctly:

  • run the command source $HOME/.bashrc (or logout and login again) to reload the required environment variables.
  • run kubectl preflight https://smartkit-vm.smeup.cloud/preflight.yaml to perform health checks. When asked whether to run it as root, select No. Make sure that everything is "OK"

The installation of AHD VM is complete.

Next steps​

The AHD installation continues with the setup of AHD Commons.