From fd72dd88d0e4ca833582c581a94e53aafc12cb1b Mon Sep 17 00:00:00 2001 From: Neeptossss Date: Sat, 2 Dec 2023 18:11:18 +0100 Subject: [PATCH] ci(vagrant): init --- deploy/Vagrantfile | 50 +++++++++++++++++++++++++++++++++ deploy/ansible.cfg | 11 ++++++++ deploy/site.yml | 24 ++++++++++++++++ scripts/installation/jenkins.sh | 2 +- 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 deploy/Vagrantfile create mode 100644 deploy/ansible.cfg create mode 100644 deploy/site.yml diff --git a/deploy/Vagrantfile b/deploy/Vagrantfile new file mode 100644 index 0000000..fd199a9 --- /dev/null +++ b/deploy/Vagrantfile @@ -0,0 +1,50 @@ +# Variables +# Image à utiliser +IMAGE_NAME = "bento/ubuntu-20.04" +# RAM +MEM = 2048 +# Nombre de CPU +CPU = 2 +# Nombre de noeuds +WORKER_NB = 1 +# Prefix pour la plage d'adresses IP à utiliser +NODE_NETWORK_BASE = "10.0.0" +# Master IP +MASTER_IP = "#{NODE_NETWORK_BASE}.10" + +Vagrant.configure("2") do |config| + config.ssh.insert_key = true + + # Configuration de la RAM et du CPU + config.vm.provider "virtualbox" do |v| + v.gui = false + v.memory = MEM + v.cpus = CPU + end + + # Configuration du Master + config.vm.define "k8s-master" do |master| + master.vm.box = IMAGE_NAME + master.vm.network "private_network", ip: MASTER_IP + master.vm.hostname = "k8s-master" + end + + # Configuration du/des Worker(s) + (1..WORKER_NB).each do |i| + config.vm.define "k8s-worker#{i}" do |worker| + worker.vm.box = IMAGE_NAME + worker.vm.network "private_network", ip: "#{NODE_NETWORK_BASE}.#{i + 10}" + worker.vm.hostname = "k8s-worker#{i}" + end + end + + config.vm.provision "ansible" do |ansible| + ansible.playbook = "site.yml" + ansible.groups = { + "master" => ["k8s-master"], + "worker" => ["k8s-worker[1:#{WORKER_NB}]"], + "kube_cluster:children" => ["master", "worker"], + "kube_cluster:vars" => { "master_ip" => MASTER_IP } + } + end +end \ No newline at end of file diff --git a/deploy/ansible.cfg b/deploy/ansible.cfg new file mode 100644 index 0000000..f37a0b1 --- /dev/null +++ b/deploy/ansible.cfg @@ -0,0 +1,11 @@ +[defaults] +roles_path = ./roles +inventory = ./hosts.ini + +remote_tmp = $HOME/.ansible/tmp +local_tmp = $HOME/.ansible/tmp +pipelining = True +become = True +host_key_checking = False +deprecation_warnings = False +callback_whitelist = profile_tasks \ No newline at end of file diff --git a/deploy/site.yml b/deploy/site.yml new file mode 100644 index 0000000..3692b69 --- /dev/null +++ b/deploy/site.yml @@ -0,0 +1,24 @@ +--- +- hosts: kube_cluster + gather_facts: yes + become: yes + roles: + - { role: commons/os-checker, tags: commons } + - { role: commons/package-update, tags: commons } + - { role: ntp, tags: ntp } + - { role: locale, tags: locale } + - { role: containerd, tags: containerd } + - { role: commons/pre-install, tags: commons } + +- hosts: master + gather_facts: yes + become: yes + roles: + - { role: kubernetes/master, tags: master } + - { role: cni, tags: cni } + +- hosts: worker + gather_facts: yes + become: yes + roles: + - { role: kubernetes/node, tags: node } \ No newline at end of file diff --git a/scripts/installation/jenkins.sh b/scripts/installation/jenkins.sh index 05463b9..47194ea 100644 --- a/scripts/installation/jenkins.sh +++ b/scripts/installation/jenkins.sh @@ -1,4 +1,4 @@ #!/bin/bash printf "Installing jenkins" -helm install whanos /whanos/kube/helm/whanos --create-namespace --namespace whanos +helm install whanos kube/helm/whanos --create-namespace --namespace whanos printf "Installed jenkins ✅"