Benutzer-Werkzeuge

Webseiten-Werkzeuge


it-wiki:kubernetes:installation

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
it-wiki:kubernetes:installation [2024/11/04 10:03] – [Initialisierung des Clusters] markoit-wiki:kubernetes:installation [2025/04/04 08:40] (aktuell) marko
Zeile 1: Zeile 1:
 ====== Kubernetes Installation ====== ====== Kubernetes Installation ======
 ===== Manuelle Installation der Kubernetes-Binaries ===== ===== Manuelle Installation der Kubernetes-Binaries =====
-**Kernel-Module in die ''/etc/modules'' eintragen:**+**Kernel-Module in die ''/etc/modules-load.d/modules.conf'' eintragen:**
 <code bash> <code bash>
 br_netfilter br_netfilter
Zeile 13: Zeile 13:
 </code> </code>
  
-**System-Konfiguration anpassen (''/etc/sysctl.conf''): **+**System-Konfiguration anpassen (''/etc/sysctl.d/90.kubernetes.conf''): **
 <code bash> <code bash>
 net.ipv4.ip_forward=1 net.ipv4.ip_forward=1
Zeile 22: Zeile 22:
 **System-Konfiguration laden: ** **System-Konfiguration laden: **
 <code bash> <code bash>
-sysctl -p /etc/sysctl.conf+sysctl -p /etc/sysctl.d/90.kubernetes.conf
 </code> </code>
  
Zeile 33: Zeile 33:
 **Docker-Repository hinzufügen (''/etc/apt/sources.list.d/docker.list''): ** **Docker-Repository hinzufügen (''/etc/apt/sources.list.d/docker.list''): **
 <code bash> <code bash>
-deb https://download.docker.com/linux/debian/ bullseye stable+deb https://download.docker.com/linux/debian/ bookworm stable
 </code> </code>
  
Zeile 53: Zeile 53:
 ''containerd-Konfiguration ''/etc/containerd/config.toml'' anpassen:'' ''containerd-Konfiguration ''/etc/containerd/config.toml'' anpassen:''
 <code bash> <code bash>
-sandbox_image = "registry.k8s.io/pause:3.9"+sandbox_image = "registry.k8s.io/pause:3.10"
  
 [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
Zeile 93: Zeile 93:
 **Kubernetes-Binaries installieren: ** **Kubernetes-Binaries installieren: **
 <code bash> <code bash>
-apt install kubeadm=1.31.1-00 kubectl=1.31.1-00 kubelet=1.31.1-00+apt install kubeadm=1.31.7-00 kubectl=1.31.7-00 kubelet=1.31.7-00
 </code> </code>
  
Zeile 153: Zeile 153:
     - name: vip_retryperiod     - name: vip_retryperiod
       value: "1"       value: "1"
-    image: ghcr.io/kube-vip/kube-vip:v0.8.    # change: to internal registry, if needed+    image: ghcr.io/kube-vip/kube-vip:v0.8.    # change: to internal registry, if needed
     imagePullPolicy: Always     imagePullPolicy: Always
     name: kube-vip     name: kube-vip
Zeile 182: Zeile 182:
 Für die Initialisierung des Clusters wird auf dem ersten Knoten (''control1.tuxnet.lab'') eine Datei mit der Cluster-Konfiguration benötigt (''init.yml''): Für die Initialisierung des Clusters wird auf dem ersten Knoten (''control1.tuxnet.lab'') eine Datei mit der Cluster-Konfiguration benötigt (''init.yml''):
 <code yaml> <code yaml>
-apiVersion: kubeadm.k8s.io/v1beta3+apiVersion: kubeadm.k8s.io/v1beta4
 kind: ClusterConfiguration kind: ClusterConfiguration
-kubernetesVersion: 1.31.1+kubernetesVersion: 1.31.7
 controlPlaneEndpoint: kubeapi.tuxnet.lab:6443 controlPlaneEndpoint: kubeapi.tuxnet.lab:6443
 networking: networking:
Zeile 194: Zeile 194:
 cgroupDriver: systemd cgroupDriver: systemd
 serverTLSBootstrap: true serverTLSBootstrap: true
 +resolvConf: /etc/resolv.conf             # kann man auch weglassen
 </code> </code>
  
Zeile 213: Zeile 214:
 kubeadm join kubeapi.tuxnet.lab:6443 --token <token> --discovery-token-ca-cert-hash sha256:<hash> --control-plane --certificate-key <key> kubeadm join kubeapi.tuxnet.lab:6443 --token <token> --discovery-token-ca-cert-hash sha256:<hash> --control-plane --certificate-key <key>
 </code> </code>
 +
 +<note important>Wenn die HA Fähigkeit mittels kube-vip angewendet wird, dann muss auf allen control-plane Nodes sowohl die kube-vip.yaml als auch die super-admin.conf kopiert werden.</note>
  
 Der Certificate-Key ist zwei Stunden gültig. Falls seit der Cluster-Initialisierung mehr als zwei Stunden vergangen sind, kann ein neuer Schlüssel erzeugt werden (die Doppelung im Befehl ist notwendig): Der Certificate-Key ist zwei Stunden gültig. Falls seit der Cluster-Initialisierung mehr als zwei Stunden vergangen sind, kann ein neuer Schlüssel erzeugt werden (die Doppelung im Befehl ist notwendig):
Zeile 253: Zeile 256:
 user0@jumphost:~$ kubectl get nodes user0@jumphost:~$ kubectl get nodes
 NAME        STATUS   ROLES           AGE     VERSION NAME        STATUS   ROLES           AGE     VERSION
-control1   NotReady   control-plane   97s   v1.31.1 +control1   NotReady   control-plane   97s   v1.31.7 
-control2   NotReady   control-plane   57s   v1.31.1 +control2   NotReady   control-plane   57s   v1.31.7 
-control3   NotReady   control-plane   55s   v1.31.1 +control3   NotReady   control-plane   55s   v1.31.7 
-node1      NotReady   <none>          5s    v1.31.1 +node1      NotReady   <none>          5s    v1.31.7 
-node2      NotReady   <none>          5s    v1.31.1+node2      NotReady   <none>          5s    v1.31.7
 </code> </code>
  
Zeile 267: Zeile 270:
 Daher wird jetzt ''Calico'' in das Cluster installiert: Daher wird jetzt ''Calico'' in das Cluster installiert:
 <code bash> <code bash>
-kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.2/manifests/calico.yaml+kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.3/manifests/calico.yaml
 </code> </code>
  
Zeile 274: Zeile 277:
 user0@jumphost:~$ kubectl get nodes user0@jumphost:~$ kubectl get nodes
 NAME        STATUS   ROLES           AGE   VERSION NAME        STATUS   ROLES           AGE   VERSION
-control1    Ready    control-plane   12m   v1.31.1 +control1    Ready    control-plane   12m   v1.31.7 
-control2    Ready    control-plane   12m   v1.31.1 +control2    Ready    control-plane   12m   v1.31.7 
-control3    Ready    control-plane   12m   v1.31.1 +control3    Ready    control-plane   12m   v1.31.7 
-node1       Ready    <none>          11m   v1.31.1 +node1       Ready    <none>          11m   v1.31.7 
-node2       Ready    <none>          11m   v1.31.1+node2       Ready    <none>          11m   v1.31.7
 </code> </code>
  
Zeile 308: Zeile 311:
 mkdir bin mkdir bin
 source .profile source .profile
-wget https://dl.k8s.io/release/v1.31.1/bin/linux/amd64/kubectl+wget https://dl.k8s.io/release/v1.31.7/bin/linux/amd64/kubectl
 chmod +x kubectl chmod +x kubectl
 mv kubectl bin mv kubectl bin
Zeile 326: Zeile 329:
 ''$ source .bash_aliases'' ''$ source .bash_aliases''
  
 +=== oder ===
 +<code bash>
 +mkdir -p ~/.local/share/bash-completion/completions/
 +kubectl completion bash > ~/.local/share/bash-completion/completions/kubectl
 +</code>
 +und in der .bashrc dann
 +<code bash>
 +# kubectl bash complition
 +source <(kubectl completion bash)
 +</code>
 +
 +=== oder ===
 +am Ende der .profile
 +<code bash>
 +# kubectl alias and bash completion
 +# https://kubernetes.io/docs/reference/kubectl/quick-reference/#bash
 +source <(kubectl completion bash)
 +alias k=kubectl
 +complete -F __start_kubectl k
 +</code>
 +
 +
 +Für Helm würde selbiges funktionieren
 +<code bash>
 +mkdir -p ~/.local/share/bash-completion/completions/
 +helm completion bash > ~/.local/share/bash-completion/completions/helm
 +</code>
 ==== Installation Krew PlugIn Manager ===== ==== Installation Krew PlugIn Manager =====
 <code yaml> <code yaml>
it-wiki/kubernetes/installation.1730714619.txt.gz · Zuletzt geändert: 2024/11/04 10:03 von marko