Installazione KuberAltro: differenze tra le versioni

Da GazziNet.
Vai alla navigazione Vai alla ricerca
Nessun oggetto della modifica
Nessun oggetto della modifica
 
(9 versioni intermedie di uno stesso utente non sono mostrate)
Riga 38: Riga 38:
abilitare:  
abilitare:  


  sudo sed -i 's/^disabled_plugins$/enabled_plugins/' /etc/containerd/config/config.toml;
  sudo sed -i 's/^disabled_plugins = \["cri"\]$/enabled_plugins = \["cri"\]/' /etc/containerd/config.toml
 
reboot




curl -sfL https://get.k3s.io | sh -
sudo systemctl status k3s
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
echo 'export KUBECONFIG=/etc/rancher/k3s/k3s.yaml' >> ~/.bashrc
source ~/.bashrc


FATE SNAP!!


reboot
Da Verificare:


sudo k3s server --disable traefik


# This overwrites any existing configuration in /etc/yum.repos.d/kubernetes.repo
Rancher:
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
EOF


  sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
  docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --name rancher rancher/rancher:latest
sudo systemctl enable --now kubelet
   
   
sudo modprobe overlay
Kubernetes Dashboard:
sudo modprobe br_netfilter


kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.0/aio/deploy/recommended.yaml




sudo sysctl --system


  sudo reboot
  # dashboard-adminuser.yaml
 
  apiVersion: v1
ATTENZIONE SOLO SUL NODO PRINCIPALE:
  kind: ServiceAccount
 
metadata:
kubeadm init (attenzione mettete l'opzione dell'ip)
  name: admin-user
 
  namespace: kubernetes-dashboard
 
  ---
 
  apiVersion: rbac.authorization.k8s.io/v1
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
  kind: ClusterRoleBinding
 
 
--ngix--provate--
 
 
  kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.5/config/manifests/metallb-native.yaml 
 
  kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
 
Crea un file metallb-config.yaml
 
  apiVersion: metallb.io/v1beta1
  kind: IPAddressPool
  metadata:
    name: first-pool
    namespace: metallb-system
  spec:
    addresses:
    - 172.16.1.150-172.16.1.160
 
 
 
  kubectl apply -f metallb-config.yaml
 
Crea un file YAML per il deployment di Nginx, chiamato nginx-deployment.yaml:
 
  apiVersion: apps/v1
  kind: Deployment
  metadata:
  metadata:
   name: nginx-deployment
   name: admin-user
  spec:
  roleRef:
   replicas: 3
   apiGroup: rbac.authorization.k8s.io
   selector:
   kind: ClusterRole
    matchLabels:
   name: cluster-admin
      app: nginx
subjects:
   template:
- kind: ServiceAccount
    metadata:
  name: admin-user
      labels:
  namespace: kubernetes-dashboard
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
 
kubectl apply -f nginx-deployment.yaml
 


Crea un file YAML per il servizio, chiamato nginx-service.yaml:


  apiVersion: v1
  kubectl apply -f dashboard-adminuser.yaml
kind: Service
metadata:
  name: nginx-service
spec:
  type: LoadBalancer
  loadBalancerIP: 172.16.1.150  # IP statico desiderato
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80


kubectl -n kubernetes-dashboard create token admin-user


  kubectl apply -f nginx-service.yaml
  kubectl proxy


http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/


--- aGGIUNGERE ALTRO NODO:


da /root/.kube
---------Aggiunta nodo-


scp config root@172.16.1.201:$PWD
sudo cat /var/lib/rancher/k3s/server/node-token


curl -sfL https://get.k3s.io | K3S_URL=https://172.16.1.200:6443 K3S_TOKEN=K10abcde12345fghijklmnopqrstuv sh -


guardare: https://www.youtube.com/watch?v=zNbqxPRTjFg
es. curl -sfL https://get.k3s.io | K3S_URL=https://172.16.1.200:6443 K3S_TOKEN=K10abcde12345fghijklmnopqrstuv sh -


https://goteleport.com/blog/troubleshooting-kubernetes-networking/


https://kube-vip.io/docs/troubleshooting/arp/
[root@kuber01 ~]# curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
[root@kuber01 ~]# chmod 700 get_helm.sh
[root@kuber01 ~]# ./get_helm.sh
[WARNING] Could not find git. It is required for plugin installation.
Downloading https://get.helm.sh/helm-v3.15.0-linux-amd64.tar.gz
Verifying checksum... Done.
Preparing to install helm into /usr/local/bin
helm installed into /usr/local/bin/helm

Versione attuale delle 20:46, 19 mag 2024

Prereq: Iso Oracle linux 8.9 - 4VCPU 8Gbyte di RAM - 32Gbyte disco

Tutto in inglese solo tastiera e Timezone

Software selection: Minimal Install

Partizione: ol-root 30GiB - /boot 1024Mbyte

Settare in installazione IP e Hostname.

Settare Root Password

dnf update -y;
systemctl disable firewalld;
systemctl stop firewalld;
sudo setenforce 0;
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config;
dnf install net-tools -y;
dnf install curl -y;
dnf install wget -y;
dnf install -y iproute-tc;
dnf install dnsutils -y
sudo yum install -y yum-utils;
reboot


sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo;
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin;
sudo systemctl start docker;
sudo systemctl enable docker;
sudo docker run hello-world;

Mettere a posto il file hosts con la risoluzione dei nodi es.:

172.16.1.200 kuber01 kuber01.gazzi.net
172.16.1.201 kuber02 kuber02.gazzi.net

abilitare:

sudo sed -i 's/^disabled_plugins = \["cri"\]$/enabled_plugins = \["cri"\]/' /etc/containerd/config.toml
reboot


curl -sfL https://get.k3s.io | sh -
sudo systemctl status k3s
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
echo 'export KUBECONFIG=/etc/rancher/k3s/k3s.yaml' >> ~/.bashrc
source ~/.bashrc


Da Verificare:

sudo k3s server --disable traefik

Rancher:

docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --name rancher rancher/rancher:latest

Kubernetes Dashboard:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.0/aio/deploy/recommended.yaml


# dashboard-adminuser.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kubernetes-dashboard


kubectl apply -f dashboard-adminuser.yaml
kubectl -n kubernetes-dashboard create token admin-user
kubectl proxy
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/



Aggiunta nodo-

sudo cat /var/lib/rancher/k3s/server/node-token

curl -sfL https://get.k3s.io | K3S_URL=https://172.16.1.200:6443 K3S_TOKEN=K10abcde12345fghijklmnopqrstuv sh -

es. curl -sfL https://get.k3s.io | K3S_URL=https://172.16.1.200:6443 K3S_TOKEN=K10abcde12345fghijklmnopqrstuv sh -


[root@kuber01 ~]# curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 [root@kuber01 ~]# chmod 700 get_helm.sh [root@kuber01 ~]# ./get_helm.sh [WARNING] Could not find git. It is required for plugin installation. Downloading https://get.helm.sh/helm-v3.15.0-linux-amd64.tar.gz Verifying checksum... Done. Preparing to install helm into /usr/local/bin helm installed into /usr/local/bin/helm