From 0e723ee13f7af99a15207c4e9449f1b8f2dcb314 Mon Sep 17 00:00:00 2001 From: trigkeyb Date: Sat, 1 Feb 2025 09:59:09 +0100 Subject: [PATCH] primeros ficheros --- clonar/0.crea_VM.sh | 8 ++++---- clonar/genera_yaml_k8s.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) create mode 100755 clonar/genera_yaml_k8s.sh diff --git a/clonar/0.crea_VM.sh b/clonar/0.crea_VM.sh index b462813..40a99ba 100755 --- a/clonar/0.crea_VM.sh +++ b/clonar/0.crea_VM.sh @@ -11,7 +11,7 @@ VMSTORAGE="local" VMNET="vmbr0" # hostname -VMHOST="k8scp" +VMHOST="master" # Genera la configuracion inicial de CLoudInit ./genera_yaml_k8s.sh @@ -20,13 +20,13 @@ VMHOST="k8scp" 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 k8s +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-server-cloudimg-amd64.img local --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.yaml" +qm set $VMID --ipconfig0 ip=dhcp --cicustom "user=VMs_storage-E:snippets/user_data-clonar.yaml" qm start $VMID diff --git a/clonar/genera_yaml_k8s.sh b/clonar/genera_yaml_k8s.sh new file mode 100755 index 0000000..c26d9a7 --- /dev/null +++ b/clonar/genera_yaml_k8s.sh @@ -0,0 +1,39 @@ +#!/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 < /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: + - cd /root + - git clone https://git.lfgut.duckdns.org/luis/infra_cloudinit.git + - cd infra_cloudinit + # - ./k8s.sh +EOF + +echo "Archivo user_data.yaml creado con éxito." + +