Zum Inhalt springen
Kubernetes

Kubernetes

Kubernetes ist ein Container-Orchestrierungssystem, das von Google entwickelt wurde.
Wie es verschiedene Linux-Distributionen gibt, existieren auch verschiedene Kubernetes-Distributionen.
K3s ist eine schlanke Kubernetes-Distribution der Firma Rancher.

Alle diese Projekte werden heute von der Cloud Native Computing Foundation verwaltet.

Werkzeug-Installation

k3sup ist ein Kommandozeilenwerkzeug zum Deployment eines K3s-Clusters auf einer oder mehreren Maschinen.
Wir installieren es mit pkgx.
~/tp $ yq -i e '.dependencies["github.com/alexellis/k3sup"]="^0.13.1"' pkgx.yaml
~/tp $ yq '.dependencies["github.com/alexellis/k3sup"]' pkgx.yaml
^0.13.1

Deployment eines k3s-Clusters

~/tp $ cat <<'EOS' > deploy-k3s.bash
#!/bin/bash

declare -r BOOTSTRAP_IP="$(terraform output -raw bootstrap_ip)"
declare -r BOOTSTRAP_USER="$(terraform output -raw bootstrap_user)"
declare -a COMPUTE_IP=($(terraform output -json | jq -j '.compute_ip.value|join(" ")'))
declare -a COMPUTE_USER=($(terraform output -json | jq -j '.compute_user.value|join(" ")'))

k3sup install \
    --cluster \
    --host "${BOOTSTRAP_IP}" \
    --user "${BOOTSTRAP_USER}" \
    --k3s-channel stable

ssh -l ${BOOTSTRAP_USER} ${BOOTSTRAP_IP} <<'EOF'
curl -fsS https://pkgx.sh |sh
eval "$(pkgx integrate)"

mkdir -p work
cat <<EOT > work/pkgx.yaml
dependencies:
  jq: ^1.7
  helm.sh: ^3.12.3
  k9s: ^0.27.4
  gnu.org/coreutils: ^9.4.0
EOT
cd work
dev
EOF

for i in ${!COMPUTE_IP[@]}; do \
    k3sup join \
        --server-host "${BOOTSTRAP_IP}" \
        --server-user "${BOOTSTRAP_USER}" \
        --host "${COMPUTE_IP[$i]}" \
        --user "${COMPUTE_USER[$i]}" \
        --k3s-channel stable
done
EOS
~/tp $ bash deploy-k3s.bash