Configure Karpenter with Rancher on the Linode Cluster
This topic describes the steps to deploy Karpenter with Rancher on the Linode cluster.
Deploy Karpenter
The following are the steps to deploy Karpenter:
-
SSH to Rancher worker node.
-
Use the following command to get the RKE controller server and the token:
# cat /etc/rancher/rke2/config.yaml.d/50-rancher.yaml
{
"node-label": [
"rke.cattle.io/machine=d459c182-ba22-46e4-a1a9-97400437eace"
],
"private-registry": "/etc/rancher/rke2/registries.yaml",
"protect-kernel-defaults": false,
"server": "https://[IP_ADDR]:9345",
"token": "TOKEN" -
Update the
charts.yaml
orvalues.yaml
with the RKE controller URL and the token.rancherLinode:
cluster:
server: "" #base64 of "https://[IP_ADDR]:9345"
token: "" #base64 of the RKE. See /etc/rancher/rke2/config.yaml.d/50-rancher.yaml of an existing worker node
rootPass: "" #base64 of the root Password on the nodes. Please make sure the password meets linode requiremets
linodeToken: "" #base64 of the linode token. Make sure the Linode token has enough rights. -
Use the following command to deploy Karpenter:
helm upgrade --install --debug karpenter charts --namespace smart-scaler --create-namespace
Create a NodeClass
Use the following command to create a NodeClass:
cat <<EOF | kubectl apply -f -
apiVersion: karpenter.linode.sh/v1alpha1
kind: LinodeNodeClass
metadata:
name: default
spec:
imageName: linode/ubuntu20.04
rke2Version: "v1.30.7+rke2r1"
privateIP: True
#scriptUrl: "https://get.rke2.io"
#subnetID: 132000
#firewallID: 1509699
EOF
Create a NodePool
Use the following command to create a NodePool:
cat <<EOF | kubectl apply -f -
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: default
spec:
template:
spec:
requirements:
- key: kubernetes.io/arch
operator: In
values: ["amd64"]
- key: kubernetes.io/os
operator: In
values: ["linux"]
- key: topology.kubernetes.io/zone
operator: In
#values: ["eu-west", "eu-central", "se-sto", "de-fra-2"]
values: ["de-fra-2"]
nodeClassRef:
name: default
kind: LinodeNodeClass
group: karpenter.linode.sh
expireAfter: 720h # 30 * 24h = 720h
limits:
cpu: 1000
disruption:
consolidationPolicy: WhenEmptyOrUnderutilized
consolidateAfter: 2m
EOF
Update the System Agent Upgrader
Rancher System Agent Upgrader continuously deploys short-live pods on Karpenter's nodes, and Karpenter cannot disrupt those nodes even where no user pods are running. The nodes seem never to be empty to Karpenter.
To stop the Rancher System Agent Upgrader from deploying short-lived pods on Karpenter-managed nodes, follow these steps:
-
Use the following command to edit the plan:
kubectl -n cattle-system edit plan system-agent-upgrader
-
Use the following command to add add the
node.kubernetes.io/instance-type
node selector:spec:
concurrency: 10
nodeSelector:
matchExpressions:
- key: kubernetes.io/os
operator: In
values:
- linux
- key: node.kubernetes.io/instance-type
operator: In
values:
- rke2