diff --git a/crea_VM copy.sh b/crea_VM copy.sh new file mode 100755 index 0000000..642ea8f --- /dev/null +++ b/crea_VM copy.sh @@ -0,0 +1,37 @@ +# Crea variables +# ID de VM +VMID="919200" + +# lugar de almacenamiento para el disco +### VMSTORAGE="VMs_storage-E" +VMSTORAGE="local" + +# network +### VMNET="k8s" +VMNET="vmbr0" + +# 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 ubuntu-cloud --memory 2048 --cores 2 --net0 virtio,bridge=$VMNET --cpu host --agent enabled=1 --tags k8s + +# 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-server-cloudimg-amd64.img local --format qcow2 + +qm set $VMID --scsihw virtio-scsi-pci --scsi0 $VMSTORAGE:$VMID/vm-$VMID-disk-0.qcow2 + +qm set $VMID --ide2 VMs_storage-E:cloudinit +qm set $VMID --boot c --bootdisk scsi0 +qm set $VMID --serial0 socket --vga serial0 + +qm disk resize $VMID scsi0 10G + +qm set $VMID --ipconfig0 ip=dhcp + +qm set $VMID --cicustom "user=VMs_storage-E:snippets/user_data.yaml" + +qm start $VMID diff --git a/crea_VM.sh b/crea_VM.sh index 4f8665d..0ee7f36 100755 --- a/crea_VM.sh +++ b/crea_VM.sh @@ -18,20 +18,12 @@ qm stop $VMID qm destroy $VMID qm create $VMID --name ubuntu-cloud --memory 2048 --cores 2 --net0 virtio,bridge=$VMNET --cpu host --agent enabled=1 --tags k8s +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-server-cloudimg-amd64.img local --format qcow2 - -qm set $VMID --scsihw virtio-scsi-pci --scsi0 $VMSTORAGE:$VMID/vm-$VMID-disk-0.qcow2 - -qm set $VMID --ide2 VMs_storage-E:cloudinit -qm set $VMID --boot c --bootdisk scsi0 -qm set $VMID --serial0 socket --vga serial0 - +qm set $VMID --scsihw virtio-scsi-pci --scsi0 $VMSTORAGE:$VMID/vm-$VMID-disk-0.qcow2 qm disk resize $VMID scsi0 10G - -qm set $VMID --ipconfig0 ip=dhcp - -qm set $VMID --cicustom "user=VMs_storage-E:snippets/user_data.yaml" +qm set $VMID --ipconfig0 ip=dhcp --cicustom "user=VMs_storage-E:snippets/user_data.yaml" qm start $VMID diff --git a/genera_yaml_k8s.sh b/genera_yaml_k8s.sh index e438a90..050f713 100755 --- a/genera_yaml_k8s.sh +++ b/genera_yaml_k8s.sh @@ -30,7 +30,7 @@ runcmd: - cd /root - git clone https://git.lfgut.duckdns.org/luis/infra_cloudinit.git - cd infra_cloudinit - - ./k8s.sh +# - ./k8s.sh EOF echo "Archivo user_data.yaml creado con éxito." diff --git a/k8s_001.sh b/k8s_001.sh new file mode 100755 index 0000000..449e08d --- /dev/null +++ b/k8s_001.sh @@ -0,0 +1,59 @@ +apt update +apt upgrade -y +apt install apt-transport-https qemu-guest-agent -y +systemctl enable --now qemu-guest-agent + +# https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/ +# version 1.32 + +curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg +chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg + +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 +chmod 644 /etc/apt/sources.list.d/kubernetes.list + +apt update +apt install kubelet kubeadm kubectl -y +apt-mark hold kubelet kubeadm kubectl + + +# Enable kernel modules +modprobe overlay +modprobe br_netfilter + +# Add some settings to sysctl +tee /etc/sysctl.d/kubernetes.conf<