Skip to content

Instantly share code, notes, and snippets.

@l1ahim
Created September 3, 2020 13:21
Show Gist options
  • Save l1ahim/9a966ff541de0362e61374abb04abc77 to your computer and use it in GitHub Desktop.
Save l1ahim/9a966ff541de0362e61374abb04abc77 to your computer and use it in GitHub Desktop.
Rancher k3s installation and group configuration
# API server: nodes should be able to reach k3s server tcp port 6443
# flannel vxlan: udp port 8472 for nodes to communicate (server and agents)
# metrics server: it collects resource metrics from kubelets and exposes them in k8s api server through metrics api. tcp port 10250
# https://rancher.com/docs/k3s/latest/en/installation/install-options/
# run the installation script
curl -sfL https://get.k3s.io | sh -
# create k3s group and add user to avoid using always sudo
sudo groupadd k3s
sudo usermod -aG k3s $USER
sudo chown root:k3s /etc/rancher/k3s/k3s.yaml
sudo chmod 740 /etc/rancher/k3s/k3s.yaml
# node configuration using the agent
# the token can be found on control server at: /var/lib/rancher/k3s/server/node-token
curl -sfL https://get.k3s.io | K3S_URL=https://k3sserver:6443 K3S_TOKEN=mynodetoken sh -
# create test pod
cat <<EOF > podtemplate.yaml
apiVersion: v1
kind: Pod
metadata:
name: cowfortune
spec:
containers:
- name: funbox-cow
image: wernight/funbox
command: ["fortune | cowsay"]
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment