From 482b07332cc350c242771f0e9f99db323f17856f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Rodr=C3=ADguez?= Date: Wed, 30 Oct 2024 08:27:56 +0100 Subject: [PATCH] modificado nombre carpeta --- astro.config.mjs | 2 +- .../posts/2024-10-24_k3s_ansible/index.md | 82 ------------------- .../posts/2024-10-24_k8s_ansible/index.md | 57 +++++++++++++ 3 files changed, 58 insertions(+), 83 deletions(-) delete mode 100644 src/content/posts/2024-10-24_k3s_ansible/index.md create mode 100644 src/content/posts/2024-10-24_k8s_ansible/index.md diff --git a/astro.config.mjs b/astro.config.mjs index 3bff5fa..1960409 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -31,7 +31,7 @@ const oklchToHex = str => { // https://astro.build/config export default defineConfig({ - site: 'https://fuwari.vercel.app/', + site: 'https://www.robertops.com/', base: '/', trailingSlash: 'always', integrations: [ diff --git a/src/content/posts/2024-10-24_k3s_ansible/index.md b/src/content/posts/2024-10-24_k3s_ansible/index.md deleted file mode 100644 index 7a7c9a8..0000000 --- a/src/content/posts/2024-10-24_k3s_ansible/index.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: Instalación de k3s utilizando Ansible -published: 2024-10-24 -description: '' -image: '' -tags: [] -category: '' -draft: true -lang: '' ---- -## Preparación del escenario - -Para crear el escenario se va a usar **Vagrant**, utilizando el siguiente `Vagrantfile`: -```ruby -Vagrant.configure("2") do |config| - config.vm.box = "debian/bookworm64" - config.vm.box_check_update = false - config.vm.synced_folder ".", "/vagrant", disabled: true - config.vm.provider "libvirt" do |v| - v.memory = 2048 - v.cpus = 3 - v.driver = "qemu" - end - config.vm.define "master" do |master| - master.vm.hostname = "master" - master.vm.network "private_network", - :libvirt__network_name => "k3s-vagrant", - :ip => "10.10.10.10", - :libvirt__dhcp_enabled => false, - :libvirt__forward_mode => "veryisolated" - end - config.vm.define "nodo1" do |nodo1| - nodo1.vm.hostname = "nodo1" - nodo1.vm.network "private_network", - :libvirt__network_name => "k3s-vagrant", - :ip => "10.10.10.20", - :libvirt__dhcp_enabled => false, - :libvirt__forward_mode => "veryisolated" - end - config.vm.define "nodo2" do |nodo2| - nodo2.vm.hostname = "nodo2" - nodo2.vm.network "private_network", - :libvirt__network_name => "k3s-vagrant", - :ip => "10.10.10.30", - :libvirt__dhcp_enabled => false, - :libvirt__forward_mode => "veryisolated" - end - end -``` - - -master -```shell -export KUBECONFIG=~/.kube/config -mkdir ~/.kube 2> /dev/null -chmod 600 "$KUBECONFIG" -sudo k3s kubectl config view --raw > "$KUBECONFIG" -``` - -una vez instalado kubernetes, copiamos la configuración de kubernetes del plano de control a nuestro kubeconfig : - -```shell -export KUBECONFIG=~/.kube/config -mkdir ~/.kube 2> /dev/null -chmod 600 "$KUBECONFIG" -ssh -i .vagrant/machines/plano-control/virtualbox/private_key vagrant@192.168.56.10 'sudo k3s kubectl config view --raw' > ~/.kube/config -``` - -y en el fichero modificamos la ip de localhost por la de la máquina: -```shell -sed -i 's/127\.0\.0\.1/192\.168\.56\.10/g' $KUBECONFIG -``` - -Finalmente podemos usar kubectl. - -```shell -❯ kubectl get nodes -NAME STATUS ROLES AGE VERSION -nodo1 Ready 15m v1.30.5+k3s1 -nodo2 Ready 14m v1.30.5+k3s1 -plano-control Ready control-plane,master 15m v1.30.5+k3s1 -``` \ No newline at end of file diff --git a/src/content/posts/2024-10-24_k8s_ansible/index.md b/src/content/posts/2024-10-24_k8s_ansible/index.md new file mode 100644 index 0000000..5021e45 --- /dev/null +++ b/src/content/posts/2024-10-24_k8s_ansible/index.md @@ -0,0 +1,57 @@ +--- +title: Instalación de k8s utilizando Ansible +published: 2024-10-30 +description: '' +image: '' +tags: [] +category: '' +draft: true +lang: '' +--- +## Preparación del escenario + +Se van a crear 3 máquinas virtuales, 1 actuará de plano de control, y las otras 2 serán nodos. Para crear el escenario se va a usar **Vagrant** con **virtualbox** como proveedor, utilizando el siguiente `Vagrantfile`: +```ruby +Vagrant.configure("2") do |config| + config.vm.box = "debian/bookworm64" + config.vm.box_check_update = false + config.vm.synced_folder '.', '/vagrant', disabled: true + config.vm.provider "virtualbox" do |v| + v.memory = 1024 + v.cpus = 2 + end + config.vm.define "plano-control" do |pcontrol| + pcontrol.vm.hostname = "plano-control" + pcontrol.vm.network "private_network", + ip: "192.168.56.10" + end + config.vm.define "nodo1" do |nodo1| + nodo1.vm.hostname = "nodo1" + nodo1.vm.network "private_network", + ip: "192.168.56.20" + end + config.vm.define "nodo2" do |nodo2| + nodo2.vm.hostname = "nodo2" + nodo2.vm.network "private_network", + ip: "192.168.56.30" + end + end +``` + +una vez instalado kubernetes, copiamos la configuración de kubernetes del plano de control a nuestro kubeconfig : + +```shell +export KUBECONFIG=~/.kube/config +mkdir ~/.kube 2> /dev/null +chmod 600 "$KUBECONFIG" +ssh -i .vagrant/machines/plano-control/virtualbox/private_key vagrant@192.168.56.10 'sudo k3s kubectl config view --raw' > ~/.kube/config +``` + +y en el fichero modificamos la ip de localhost por la de la máquina: +```shell +sed -i 's/127\.0\.0\.1/192\.168\.56\.10/g' $KUBECONFIG +``` + +Finalmente podemos usar kubectl. + +## Instalación k3s \ No newline at end of file