Skip to content

Instantly share code, notes, and snippets.

@busyboy77
Forked from superseb/rke2-commands.md
Created September 30, 2024 13:10
Show Gist options
  • Save busyboy77/b8bef991dad4b9d90a8ca37d10cad14a to your computer and use it in GitHub Desktop.
Save busyboy77/b8bef991dad4b9d90a8ca37d10cad14a to your computer and use it in GitHub Desktop.
RKE2 commands

RKE2 commands

Various exploration/debug commmands for RKE2

binaries

Necessary binaries unpacked from image and symlinked in /usr/local/bin (only when using install.sh script)

-rwxr-xr-x 1 root root 151543800 Jul 22 06:22 rke2
-rwxr-xr-x 1 root root      1014 Jul 22 06:22 rke2-uninstall.sh
-rwxr-xr-x 1 root root      1716 Jul 22 06:22 rke2-killall.sh
lrwxrwxrwx 1 root root       106 Jul 22 06:23 containerd -> /var/lib/rancher/rke2/data/e54e0eb8ba58f4f8e5e252bb58a07022700890934ec360ab816c01fe5d90ddef/bin/containerd
lrwxrwxrwx 1 root root       119 Jul 22 06:23 containerd-shim-runc-v1 -> /var/lib/rancher/rke2/data/e54e0eb8ba58f4f8e5e252bb58a07022700890934ec360ab816c01fe5d90ddef/bin/containerd-shim-runc-v1
lrwxrwxrwx 1 root root       111 Jul 22 06:23 containerd-shim -> /var/lib/rancher/rke2/data/e54e0eb8ba58f4f8e5e252bb58a07022700890934ec360ab816c01fe5d90ddef/bin/containerd-shim
lrwxrwxrwx 1 root root       119 Jul 22 06:23 containerd-shim-runc-v2 -> /var/lib/rancher/rke2/data/e54e0eb8ba58f4f8e5e252bb58a07022700890934ec360ab816c01fe5d90ddef/bin/containerd-shim-runc-v2
lrwxrwxrwx 1 root root        99 Jul 22 06:23 ctr -> /var/lib/rancher/rke2/data/e54e0eb8ba58f4f8e5e252bb58a07022700890934ec360ab816c01fe5d90ddef/bin/ctr
lrwxrwxrwx 1 root root       103 Jul 22 06:23 kubelet -> /var/lib/rancher/rke2/data/e54e0eb8ba58f4f8e5e252bb58a07022700890934ec360ab816c01fe5d90ddef/bin/kubelet
lrwxrwxrwx 1 root root       103 Jul 22 06:23 kubectl -> /var/lib/rancher/rke2/data/e54e0eb8ba58f4f8e5e252bb58a07022700890934ec360ab816c01fe5d90ddef/bin/kubectl
lrwxrwxrwx 1 root root       100 Jul 22 06:23 runc -> /var/lib/rancher/rke2/data/e54e0eb8ba58f4f8e5e252bb58a07022700890934ec360ab816c01fe5d90ddef/bin/runc

systemd

  • /etc/systemd/system/rke2.service.env
  • /etc/systemd/system/rke2.service

kubeconfig

export KUBECONFIG=/etc/rancher/rke2/rke2.yaml
kubectl get nodes
kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get nodes

containerd

  • socket located at /run/k3s/containerd/containerd.sock

ctr

List containers using ctr

ctr --address /run/k3s/containerd/containerd.sock --namespace k8s.io container ls

crictl (not installed/included by default)

export CRI_CONFIG_FILE=/var/lib/rancher/rke2/agent/etc/crictl.yaml
crictl ps
crictl --config /var/lib/rancher/rke2/agent/etc/crictl.yaml ps
crictl --runtime-endpoint unix:///run/k3s/containerd/containerd.sock ps -a

logging

  • journalctl -u rke2
  • /var/lib/rancher/rke2/agent/containerd/containerd.log
  • /var/lib/rancher/rke2/agent/logs/kubelet.log

etcd

etcdcontainer=$(crictl ps --label io.kubernetes.container.name=etcd --quiet)
  • etcdctl check perf
crictl exec $etcdcontainer sh -c "ETCDCTL_ENDPOINTS='https://127.0.0.1:2379' ETCDCTL_CACERT='/var/lib/rancher/rke2/server/tls/etcd/server-ca.crt' ETCDCTL_CERT='/var/lib/rancher/rke2/server/tls/etcd/server-client.crt' ETCDCTL_KEY='/var/lib/rancher/rke2/server/tls/etcd/server-client.key' ETCDCTL_API=3 etcdctl check perf"
  • etcdctl endpoint status
crictl exec $etcdcontainer sh -c "ETCDCTL_ENDPOINTS='https://127.0.0.1:2379' ETCDCTL_CACERT='/var/lib/rancher/rke2/server/tls/etcd/server-ca.crt' ETCDCTL_CERT='/var/lib/rancher/rke2/server/tls/etcd/server-client.crt' ETCDCTL_KEY='/var/lib/rancher/rke2/server/tls/etcd/server-client.key' ETCDCTL_API=3 etcdctl endpoint status --write-out=table"
  • etcdctl endpoint health
crictl exec $etcdcontainer sh -c "ETCDCTL_ENDPOINTS='https://127.0.0.1:2379' ETCDCTL_CACERT='/var/lib/rancher/rke2/server/tls/etcd/server-ca.crt' ETCDCTL_CERT='/var/lib/rancher/rke2/server/tls/etcd/server-client.crt' ETCDCTL_KEY='/var/lib/rancher/rke2/server/tls/etcd/server-client.key' ETCDCTL_API=3 etcdctl endpoint health --write-out=table"
  • etcdctl alarm list
crictl exec $etcdcontainer sh -c "ETCDCTL_ENDPOINTS='https://127.0.0.1:2379' ETCDCTL_CACERT='/var/lib/rancher/rke2/server/tls/etcd/server-ca.crt' ETCDCTL_CERT='/var/lib/rancher/rke2/server/tls/etcd/server-client.crt' ETCDCTL_KEY='/var/lib/rancher/rke2/server/tls/etcd/server-client.key' ETCDCTL_API=3 etcdctl alarm list"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment