Compare commits
28 Commits
f6f9486efe
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92effc8d42 | ||
|
|
55c736d55f | ||
|
|
fdc952020d | ||
|
|
e9773eacf2 | ||
|
|
fac09f2368 | ||
|
|
677e4d8827 | ||
|
|
31bfbbda77 | ||
|
|
937331e13a | ||
|
|
dbfd9f3053 | ||
|
|
748a4a03f7 | ||
|
|
3121598fec | ||
|
|
1e408cb79e | ||
|
|
abe437582f | ||
|
|
0713e5860a | ||
|
|
5e68ce5814 | ||
|
|
427ee381da | ||
|
|
6d31dc1584 | ||
|
|
0e723ee13f | ||
|
|
892a661dfc | ||
|
|
acc36cbdc7 | ||
|
|
e64d6525ed | ||
|
|
0da234dffd | ||
|
|
72d96550ce | ||
|
|
a4577bb70b | ||
|
|
6142bd0fad | ||
|
|
930f193a0c | ||
|
|
87ad42c701 | ||
|
|
4b7768a237 |
@@ -1,25 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Variables
|
|
||||||
|
|
||||||
kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.1/manifests/calico.yaml
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Instalar red de pods (Calico)
|
|
||||||
echo "Instalando la red de pods (Calico)..."
|
|
||||||
|
|
||||||
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.1/manifests/tigera-operator.yaml
|
|
||||||
curl -O https://raw.githubusercontent.com/projectcalico/calico/v3.29.1/manifests/custom-resources.yaml
|
|
||||||
sed -ie 's/192.168.0.0/172.24.0.0/g' custom-resources.yaml
|
|
||||||
kubectl create -f custom-resources.yaml
|
|
||||||
|
|
||||||
# curl -O https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/tigera-operator.yaml
|
|
||||||
# curl -O https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/custom-resources.yaml
|
|
||||||
|
|
||||||
# kubectl create -f tigera-operator.yaml
|
|
||||||
|
|
||||||
# kubectl apply -f https://docs.projectcalico.org/v3.25/manifests/calico.yaml
|
|
||||||
|
|
||||||
## kubectl get pods --all-namespaces -w
|
|
||||||
23
README.md
23
README.md
@@ -1,4 +1,27 @@
|
|||||||
# infra_cloudinit
|
# infra_cloudinit
|
||||||
|
|
||||||
|
https://pabpereza.notion.site/Install-kubernetes-1-28-on-Ubuntu-Server-20-04-LTS-6f8d28eadb6242f0a78c40eaa0211167
|
||||||
|
|
||||||
|
https://medium.com/@pabloperezaradros/install-kubernetes-1-28-e42ad9194d4f
|
||||||
|
|
||||||
|
|
||||||
https://www.linuxtechi.com/install-kubernetes-on-ubuntu-24-04/
|
https://www.linuxtechi.com/install-kubernetes-on-ubuntu-24-04/
|
||||||
|
|
||||||
|
|
||||||
|
#Crea una plantilla desde la VM
|
||||||
|
|
||||||
|
PLANTILLA="919200"
|
||||||
|
qm template $PLANTILLA
|
||||||
|
|
||||||
|
|
||||||
|
# Ruta del archivo a modificar
|
||||||
|
CONFIG_FILE="/etc/dhcpcd.conf"
|
||||||
|
|
||||||
|
# Comentar la línea 'duid'
|
||||||
|
sed -i 's/^duid/#duid/' "$CONFIG_FILE"
|
||||||
|
|
||||||
|
# Descomentar la línea '#clientid'
|
||||||
|
sed -i 's/^#clientid/clientid/' "$CONFIG_FILE"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
32
clonar/0.crea_VM.sh
Executable file
32
clonar/0.crea_VM.sh
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
# Crea variables
|
||||||
|
# ID de VM
|
||||||
|
VMID="920000"
|
||||||
|
|
||||||
|
# lugar de almacenamiento para el disco
|
||||||
|
### VMSTORAGE="VMs_storage-E"
|
||||||
|
VMSTORAGE="local"
|
||||||
|
|
||||||
|
# network
|
||||||
|
### VMNET="k8s"
|
||||||
|
VMNET="vmbr0"
|
||||||
|
|
||||||
|
# hostname
|
||||||
|
VMHOST="master"
|
||||||
|
|
||||||
|
# Genera la configuracion inicial de CLoudInit
|
||||||
|
./genera_yaml_k8s.sh
|
||||||
|
|
||||||
|
# apaga y borra la VM si existe antes
|
||||||
|
qm stop $VMID
|
||||||
|
qm destroy $VMID
|
||||||
|
|
||||||
|
qm create $VMID --name $VMHOST --memory 8192 --cores 4 --net0 virtio,bridge=$VMNET --cpu host --agent enabled=1 --tags clonar
|
||||||
|
qm set $VMID --ide2 VMs_storage-E:cloudinit --boot c --bootdisk scsi0 --serial0 socket --vga serial0
|
||||||
|
|
||||||
|
# qm importdisk $VMID /mnt/pve/ISOs_storage/template/iso/ubuntu-24.04-server-cloudimg-amd64.img VMs_storage-E --format qcow2
|
||||||
|
qm importdisk $VMID /mnt/pve/ISOs_storage/template/iso/ubuntu-24.04-minimal-cloudimg-amd64.img local --format qcow2
|
||||||
|
qm set $VMID --scsihw virtio-scsi-pci --scsi0 $VMSTORAGE:$VMID/vm-$VMID-disk-0.qcow2
|
||||||
|
qm disk resize $VMID scsi0 40G
|
||||||
|
qm set $VMID --ipconfig0 ip=dhcp --cicustom "user=VMs_storage-E:snippets/user_data-clonar.yaml"
|
||||||
|
|
||||||
|
qm start $VMID
|
||||||
8
clonar/50-cloud-init.yaml
Normal file
8
clonar/50-cloud-init.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
network:
|
||||||
|
version: 2
|
||||||
|
ethernets:
|
||||||
|
eth0:
|
||||||
|
dhcp4: true
|
||||||
|
dhcp-identifier: mac
|
||||||
|
set-name: "eth0"
|
||||||
|
|
||||||
40
clonar/genera_yaml_k8s copy.sh
Executable file
40
clonar/genera_yaml_k8s copy.sh
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Crea la base para la plantilla para kubernetes, borrando el machine-id y apagandola
|
||||||
|
# Despues usar qm template para convertirla
|
||||||
|
#
|
||||||
|
|
||||||
|
USER="curso"
|
||||||
|
PASSWORD="1"
|
||||||
|
PASSWORD_HASH=$(openssl passwd -6 "$PASSWORD")
|
||||||
|
PUB_KEY=$(cat ~/.ssh/id_rsa.pub)
|
||||||
|
VMHOST="k8scp"
|
||||||
|
|
||||||
|
cat <<EOF > /mnt/pve/VMs_storage-E/snippets/user_data-clonar.yaml
|
||||||
|
#cloud-config
|
||||||
|
|
||||||
|
system_info:
|
||||||
|
default_user:
|
||||||
|
name: $USER
|
||||||
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||||
|
shell: /bin/bash
|
||||||
|
lock_passwd: false
|
||||||
|
passwd: $PASSWORD_HASH
|
||||||
|
# passwd: \$6\$ogQI1CDWE.wdcMWI\$6kIrEjVBNC5.YxxFwBY9CxFGnIg1SDhndG4niMn5Sz11NNqay4icJS4AAddY6WbcM7LZJsLzwiYeUCLq2ddmL0
|
||||||
|
ssh_authorized_keys:
|
||||||
|
- $PUB_KEY
|
||||||
|
ssh_pwauth: true
|
||||||
|
hostname: $VMHOST
|
||||||
|
manage_etc_hosts: true
|
||||||
|
fqdn: $VMHOST
|
||||||
|
runcmd:
|
||||||
|
- apt update && apt install git -y
|
||||||
|
- cd /root
|
||||||
|
- git clone https://git.lfgut.duckdns.org/luis/infra_cloudinit.git
|
||||||
|
- cd infra_cloudinit/clonar
|
||||||
|
- ./k8s.sh
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Archivo user_data.yaml creado con éxito."
|
||||||
|
|
||||||
|
|
||||||
41
clonar/genera_yaml_k8s.sh
Executable file
41
clonar/genera_yaml_k8s.sh
Executable file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Crea la base para la plantilla para kubernetes, borrando el machine-id y apagandola
|
||||||
|
# Despues usar qm template para convertirla
|
||||||
|
#
|
||||||
|
|
||||||
|
USER="curso"
|
||||||
|
PASSWORD="1"
|
||||||
|
PASSWORD_HASH=$(openssl passwd -6 "$PASSWORD")
|
||||||
|
PUB_KEY=$(cat ~/.ssh/id_rsa.pub)
|
||||||
|
VMHOST="k8scp"
|
||||||
|
|
||||||
|
cat <<EOF > /mnt/pve/VMs_storage-E/snippets/user_data-clonar.yaml
|
||||||
|
#cloud-config
|
||||||
|
|
||||||
|
system_info:
|
||||||
|
default_user:
|
||||||
|
name: $USER
|
||||||
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||||
|
shell: /bin/bash
|
||||||
|
lock_passwd: false
|
||||||
|
passwd: $PASSWORD_HASH
|
||||||
|
# passwd: \$6\$ogQI1CDWE.wdcMWI\$6kIrEjVBNC5.YxxFwBY9CxFGnIg1SDhndG4niMn5Sz11NNqay4icJS4AAddY6WbcM7LZJsLzwiYeUCLq2ddmL0
|
||||||
|
ssh_authorized_keys:
|
||||||
|
- $PUB_KEY
|
||||||
|
ssh_pwauth: true
|
||||||
|
hostname: $VMHOST
|
||||||
|
manage_etc_hosts: true
|
||||||
|
fqdn: $VMHOST
|
||||||
|
# package_update: true
|
||||||
|
runcmd:
|
||||||
|
- apt update && apt install git -y
|
||||||
|
- cd /root
|
||||||
|
- git clone https://git.lfgut.duckdns.org/luis/infra_cloudinit.git
|
||||||
|
- cd infra_cloudinit/clonar
|
||||||
|
- ./k8s.sh
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Archivo user_data.yaml creado con éxito."
|
||||||
|
|
||||||
|
|
||||||
12
clonar/k8s.sh
Executable file
12
clonar/k8s.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cp 50-cloud-init.yaml /etc/netplan/
|
||||||
|
|
||||||
|
# Actualización del sistema
|
||||||
|
apt update
|
||||||
|
|
||||||
|
# Instalación del agente
|
||||||
|
apt install qemu-guest-agent -y
|
||||||
|
systemctl enable --now qemu-guest-agent
|
||||||
|
apt upgrade
|
||||||
|
reboot
|
||||||
19
docker/0.crea_VM.sh
Executable file
19
docker/0.crea_VM.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
source config.sh
|
||||||
|
|
||||||
|
|
||||||
|
# Genera la configuracion inicial de CLoudInit
|
||||||
|
./genera_yaml_k8s.sh
|
||||||
|
|
||||||
|
# apaga y borra la VM si existe antes
|
||||||
|
qm stop $VMID
|
||||||
|
qm destroy $VMID
|
||||||
|
|
||||||
|
qm create $VMID --name $VMHOST --memory $VRAM --cores $VCORES --net0 virtio,bridge=$VMNET --cpu host --agent enabled=1 --tags docker
|
||||||
|
qm set $VMID --ide2 $VMSTORAGE:cloudinit --boot c --bootdisk scsi0 --serial0 socket --vga serial0
|
||||||
|
|
||||||
|
qm importdisk $VMID /mnt/pve/ISOs_storage/template/iso/ubuntu-24.04-minimal-cloudimg-amd64.img $VMSTORAGE --format qcow2
|
||||||
|
qm set $VMID --scsihw virtio-scsi-pci --scsi0 $VMSTORAGE:$VMID/vm-$VMID-disk-0.qcow2
|
||||||
|
qm disk resize $VMID scsi0 40G
|
||||||
|
qm set $VMID --ipconfig0 ip=dhcp --cicustom "user=$VMSTORAGE:snippets/user_data-docker.yaml"
|
||||||
|
|
||||||
|
qm start $VMID
|
||||||
29
docker/1.instala_docker.sh
Executable file
29
docker/1.instala_docker.sh
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
USER="curso" # Usuario con acceso sudo
|
||||||
|
|
||||||
|
# Actualizar sistema
|
||||||
|
echo "Actualizando el sistema..."
|
||||||
|
sudo apt-get update && sudo apt-get upgrade -y
|
||||||
|
|
||||||
|
|
||||||
|
# Add Docker's official GPG key:
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install ca-certificates curl
|
||||||
|
sudo install -m 0755 -d /etc/apt/keyrings
|
||||||
|
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
||||||
|
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||||
|
|
||||||
|
# Add the repository to Apt sources:
|
||||||
|
echo \
|
||||||
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
|
||||||
|
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
|
||||||
|
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
sudo apt-get update
|
||||||
|
|
||||||
|
|
||||||
|
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
|
||||||
|
|
||||||
|
# añade el usuario curso al grupo docker
|
||||||
|
usermod -aG docker $USER
|
||||||
8
docker/50-cloud-init.yaml
Normal file
8
docker/50-cloud-init.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
network:
|
||||||
|
version: 2
|
||||||
|
ethernets:
|
||||||
|
eth0:
|
||||||
|
dhcp4: true
|
||||||
|
dhcp-identifier: mac
|
||||||
|
set-name: "eth0"
|
||||||
|
|
||||||
32
docker/config.sh
Normal file
32
docker/config.sh
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# config.sh
|
||||||
|
|
||||||
|
# Crea variables
|
||||||
|
# ID de VM
|
||||||
|
VMID="930000"
|
||||||
|
|
||||||
|
# lugar de almacenamiento para el disco
|
||||||
|
VMSTORAGE="VMs_storage-E"
|
||||||
|
### VMSTORAGE="local"
|
||||||
|
|
||||||
|
# recursos
|
||||||
|
VRAM=4096
|
||||||
|
VCORES=2
|
||||||
|
|
||||||
|
|
||||||
|
# network
|
||||||
|
### VMNET="k8s"
|
||||||
|
VMNET="vmbr0"
|
||||||
|
|
||||||
|
# hostname
|
||||||
|
VMHOST="docker"
|
||||||
|
|
||||||
|
# usuario y password
|
||||||
|
USER="curso"
|
||||||
|
PASSWORD="1"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# calculos con lo que hay
|
||||||
|
|
||||||
|
PASSWORD_HASH=$(openssl passwd -6 "$PASSWORD")
|
||||||
|
PUB_KEY=$(cat ~/.ssh/id_rsa.pub)
|
||||||
37
docker/genera_yaml_k8s.sh
Executable file
37
docker/genera_yaml_k8s.sh
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Crea la base para la plantilla para kubernetes, borrando el machine-id y apagandola
|
||||||
|
# Despues usar qm template para convertirla
|
||||||
|
#
|
||||||
|
|
||||||
|
source config.sh
|
||||||
|
|
||||||
|
cat <<EOF > /mnt/pve/VMs_storage-E/snippets/user_data-docker.yaml
|
||||||
|
#cloud-config
|
||||||
|
|
||||||
|
system_info:
|
||||||
|
default_user:
|
||||||
|
name: $USER
|
||||||
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||||
|
shell: /bin/bash
|
||||||
|
lock_passwd: false
|
||||||
|
passwd: $PASSWORD_HASH
|
||||||
|
# passwd: \$6\$ogQI1CDWE.wdcMWI\$6kIrEjVBNC5.YxxFwBY9CxFGnIg1SDhndG4niMn5Sz11NNqay4icJS4AAddY6WbcM7LZJsLzwiYeUCLq2ddmL0
|
||||||
|
ssh_authorized_keys:
|
||||||
|
- $PUB_KEY
|
||||||
|
ssh_pwauth: true
|
||||||
|
hostname: $VMHOST
|
||||||
|
manage_etc_hosts: true
|
||||||
|
fqdn: $VMHOST
|
||||||
|
# package_update: true
|
||||||
|
runcmd:
|
||||||
|
- apt update && apt install git -y
|
||||||
|
- cd /root
|
||||||
|
- git clone https://git.lfgut.duckdns.org/luis/infra_cloudinit.git
|
||||||
|
- cd infra_cloudinit/docker
|
||||||
|
- ./k8s.sh
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Archivo user_data.yaml creado con éxito."
|
||||||
|
|
||||||
|
|
||||||
16
docker/k8s.sh
Executable file
16
docker/k8s.sh
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cp 50-cloud-init.yaml /etc/netplan/
|
||||||
|
|
||||||
|
# Actualización del sistema
|
||||||
|
apt update
|
||||||
|
|
||||||
|
# Instalación del agente
|
||||||
|
apt install qemu-guest-agent -y
|
||||||
|
systemctl enable --now qemu-guest-agent
|
||||||
|
apt upgrade -y
|
||||||
|
|
||||||
|
./1.instala_docker.sh
|
||||||
|
|
||||||
|
|
||||||
|
reboot
|
||||||
@@ -54,24 +54,30 @@ sudo apt install containerd.io -y
|
|||||||
# sudo mkdir -p /etc/containerd
|
# sudo mkdir -p /etc/containerd
|
||||||
sudo containerd config default|sudo tee /etc/containerd/config.toml >/dev/null 2>&1
|
sudo containerd config default|sudo tee /etc/containerd/config.toml >/dev/null 2>&1
|
||||||
sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/g' /etc/containerd/config.toml
|
sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/g' /etc/containerd/config.toml
|
||||||
|
sudo sed -i 's/pause:3.8/pause:3.10/g' /etc/containerd/config.toml
|
||||||
|
|
||||||
# restart containerd
|
# restart containerd
|
||||||
sudo systemctl restart containerd
|
sudo systemctl restart containerd
|
||||||
# sudo systemctl enable containerd
|
# sudo systemctl enable containerd
|
||||||
# systemctl status containerd
|
# systemctl status containerd
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Configurar el repositorio de Kubernetes
|
# Configurar el repositorio de Kubernetes
|
||||||
echo "Agregando el repositorio de Kubernetes..."
|
echo "Agregando el repositorio de Kubernetes..."
|
||||||
### sudo apt-get install apt-transport-https ca-certificates curl -y
|
### sudo apt-get install apt-transport-https ca-certificates curl -y
|
||||||
# If the folder `/etc/apt/keyrings` does not exist, it should be created before the curl command, read the note below.
|
# If the folder `/etc/apt/keyrings` does not exist, it should be created before the curl command, read the note below.
|
||||||
# sudo mkdir -p -m 755 /etc/apt/keyrings
|
# sudo mkdir -p -m 755 /etc/apt/keyrings
|
||||||
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/k8s.gpg
|
##### curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/k8s.gpg
|
||||||
##### curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
|
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
|
||||||
#sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg # allow unprivileged APT programs to read this keyring
|
#sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg # allow unprivileged APT programs to read this keyring
|
||||||
|
|
||||||
# This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list
|
# This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list
|
||||||
echo 'deb [signed-by=/etc/apt/keyrings/k8s.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/k8s.list
|
##### echo 'deb [signed-by=/etc/apt/keyrings/k8s.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/k8s.list
|
||||||
##### echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
||||||
#sudo chmod 644 /etc/apt/sources.list.d/kubernetes.list # helps tools such as command-not-found to work correctly
|
#sudo chmod 644 /etc/apt/sources.list.d/kubernetes.list # helps tools such as command-not-found to work correctly
|
||||||
|
|
||||||
|
|
||||||
@@ -98,5 +104,5 @@ sudo apt-mark hold kubelet kubeadm kubectl
|
|||||||
# sudo systemctl restart containerd
|
# sudo systemctl restart containerd
|
||||||
# sudo systemctl enable containerd
|
# sudo systemctl enable containerd
|
||||||
|
|
||||||
sudo kubeadm config images pull
|
#sudo kubeadm config images pull
|
||||||
|
|
||||||
@@ -3,10 +3,10 @@
|
|||||||
# Variables
|
# Variables
|
||||||
USER="curso" # Usuario con acceso sudo
|
USER="curso" # Usuario con acceso sudo
|
||||||
|
|
||||||
|
sudo kubeadm config images pull
|
||||||
|
|
||||||
echo "Inicializando el nodo maestro..."
|
echo "Inicializando el nodo maestro..."
|
||||||
sudo kubeadm init --control-plane-endpoint=k8scp
|
sudo kubeadm init --control-plane-endpoint=k8s01 --upload-certs --pod-network-cidr=172.24.0.0/16
|
||||||
|
|
||||||
|
|
||||||
# sudo kubeadm init --pod-network-cidr=174.24.0.0/16 --cri-socket=unix:///run/containerd/containerd.sock --upload-certs --control-plane-endpoint=k8scp
|
# sudo kubeadm init --pod-network-cidr=174.24.0.0/16 --cri-socket=unix:///run/containerd/containerd.sock --upload-certs --control-plane-endpoint=k8scp
|
||||||
31
k8s/3.instala_calico.sh
Executable file
31
k8s/3.instala_calico.sh
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# instala con operator -ok-
|
||||||
|
|
||||||
|
curl -O https://raw.githubusercontent.com/projectcalico/calico/v3.29.1/manifests/tigera-operator.yaml
|
||||||
|
curl -O https://raw.githubusercontent.com/projectcalico/calico/v3.29.1/manifests/custom-resources.yaml
|
||||||
|
|
||||||
|
sed -i 's/192.168.0.0/172.24.0.0/g' custom-resources.yaml
|
||||||
|
|
||||||
|
|
||||||
|
kubectl create -f tigera-operator.yaml
|
||||||
|
kubectl create -f custom-resources.yaml
|
||||||
|
|
||||||
|
|
||||||
|
kubectl get pods -A
|
||||||
|
|
||||||
|
|
||||||
|
### kubectl get pods -A -w
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## instala con manifest -deprecated-
|
||||||
|
|
||||||
|
# kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.1/manifests/calico.yaml
|
||||||
|
|
||||||
|
#### wget https://raw.githubusercontent.com/projectcalico/calico/v3.29.1/manifests/calico.yaml
|
||||||
|
#### sed -ie 's/192.168.0.0/172.24.0.0/g' calico.yaml
|
||||||
|
|
||||||
|
|
||||||
@@ -7,6 +7,24 @@ kubectl create deployment nginx-app --image nginx --replicas 2 --namespace demo-
|
|||||||
kubectl get deployment -n demo-app
|
kubectl get deployment -n demo-app
|
||||||
kubectl get pods -n demo-app
|
kubectl get pods -n demo-app
|
||||||
|
|
||||||
|
kubectl scale --replicas=20 deployment nginx-app -n demo-app
|
||||||
|
|
||||||
|
kubectl delete deployment nginx-app -n demo-app
|
||||||
|
|
||||||
|
kubectl expose deployment nginx-app -n demo-app --type NodePort --port 80
|
||||||
|
kubectl get svc -n demo-app
|
||||||
|
|
||||||
|
# poner la IP obtenida
|
||||||
|
#### curl http://<Any-worker-IP>:<puerto>
|
||||||
|
|
||||||
|
curl http://localhost:30336
|
||||||
|
|
||||||
|
|
||||||
|
kubectl create ns demo-app
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
kubectl run test-pod2 --image=busybox -- sleep 3600
|
kubectl run test-pod2 --image=busybox -- sleep 3600
|
||||||
|
|
||||||
kubectl create deployment gitea-app2 --image gitea/gitea:latest --replicas 2 --namespace demo-app
|
kubectl create deployment gitea-app2 --image gitea/gitea:latest --replicas 2 --namespace demo-app
|
||||||
7
k8s/5.autocomplete_in_bash.sh
Executable file
7
k8s/5.autocomplete_in_bash.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo 'source <(kubectl completion bash)' >>~/.bashrc
|
||||||
|
|
||||||
|
# Reload sourcefile again (located on home)
|
||||||
|
source .bashrc
|
||||||
|
|
||||||
15
k8s/6.borra_cluster.sh
Executable file
15
k8s/6.borra_cluster.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
|
||||||
|
sudo kubeadm reset -f
|
||||||
|
|
||||||
|
sudo rm -rf /etc/cni/net.d
|
||||||
|
|
||||||
|
sudo ip link show | grep cni
|
||||||
|
sudo ip link delete <nombre-del-bridge>
|
||||||
|
|
||||||
|
sudo rm -rf /var/lib/kubelet /var/lib/dockershim /var/lib/etcd /var/lib/cni
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
33
k8s/add-nodo.md
Normal file
33
k8s/add-nodo.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
Your Kubernetes control-plane has initialized successfully!
|
||||||
|
|
||||||
|
To start using your cluster, you need to run the following as a regular user:
|
||||||
|
|
||||||
|
mkdir -p $HOME/.kube
|
||||||
|
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
|
||||||
|
sudo chown $(id -u):$(id -g) $HOME/.kube/config
|
||||||
|
|
||||||
|
Alternatively, if you are the root user, you can run:
|
||||||
|
|
||||||
|
export KUBECONFIG=/etc/kubernetes/admin.conf
|
||||||
|
|
||||||
|
You should now deploy a pod network to the cluster.
|
||||||
|
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
|
||||||
|
https://kubernetes.io/docs/concepts/cluster-administration/addons/
|
||||||
|
|
||||||
|
You can now join any number of control-plane nodes running the following command on each as root:
|
||||||
|
|
||||||
|
kubeadm join k8s01:6443 --token mlv46u.o92gie7d9wseptfx \
|
||||||
|
--discovery-token-ca-cert-hash sha256:2c20f2d546d59772bb0a82fae16c213c8c7a35b80365f39cd6e5be037f84a94a \
|
||||||
|
--control-plane --certificate-key 8985eb6d3979f371b7c2dbd98e14f071fe7fd1a86468112d501c29ffe7e6843e
|
||||||
|
|
||||||
|
Please note that the certificate-key gives access to cluster sensitive data, keep it secret!
|
||||||
|
As a safeguard, uploaded-certs will be deleted in two hours; If necessary, you can use
|
||||||
|
"kubeadm init phase upload-certs --upload-certs" to reload certs afterward.
|
||||||
|
|
||||||
|
Then you can join any number of worker nodes by running the following on each as root:
|
||||||
|
|
||||||
|
kubeadm join k8s01:6443 --token mlv46u.o92gie7d9wseptfx \
|
||||||
|
--discovery-token-ca-cert-hash sha256:2c20f2d546d59772bb0a82fae16c213c8c7a35b80365f39cd6e5be037f84a94a
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user