Skip to content

Commit

Permalink
feat(ansible): add playbooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeptossss committed Dec 17, 2023
1 parent 99e9d87 commit 636dd5c
Show file tree
Hide file tree
Showing 31 changed files with 5,683 additions and 6 deletions.
1 change: 1 addition & 0 deletions deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vagrant
11 changes: 5 additions & 6 deletions deploy/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Variables
# Image à utiliser
IMAGE_NAME = "bento/ubuntu-20.04"
IMAGE_NAME = "perk/ubuntu-20.04-arm64"
# RAM
MEM = 2048
# Nombre de CPU
Expand All @@ -13,13 +13,12 @@ NODE_NETWORK_BASE = "10.0.0"
MASTER_IP = "#{NODE_NETWORK_BASE}.10"

Vagrant.configure("2") do |config|
config.ssh.insert_key = true
config.ssh.insert_key = false

# Configuration de la RAM et du CPU
config.vm.provider "virtualbox" do |v|
v.gui = false
v.memory = MEM
v.cpus = CPU
config.vm.provider "qemu" do |qe|
qe.memory = MEM
qe.smp = CPU
end

# Configuration du Master
Expand Down
38 changes: 38 additions & 0 deletions deploy/group_var/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Kubernetes
kube_package_version: 1.20.11
kube_version: v{{ kube_package_version }}
token: b0f7b8.8d1767876297d85c

# 1.8.x feature: --feature-gates SelfHosting=true
init_opts: ""

# Any other additional opts you want to add..
kubeadm_opts: ""
# For example:
# kubeadm_opts: '--apiserver-cert-extra-sans "k8s.domain.com,kubernetes.domain.com"'

service_cidr: "10.96.0.0/12"
pod_network_cidr: "10.244.0.0/16"

# Network implementation('flannel', 'calico', 'canal')
network: calico

# Change this to an appropriate interface, preferably a private network.
# For example, on DigitalOcean, you would use eth1 as that is the default private network interface.
network_interface: ""

systemd_dir: /lib/systemd/system
system_env_dir: /etc/sysconfig
network_dir: /etc/kubernetes/network
kubeadmin_config: /etc/kubernetes/admin.conf
kube_addon_dir: /etc/kubernetes/addon

# temporary directory used by additional features
tmp_dir: /tmp/kubeadm-ansible-files

# Container runtimes ('containerd', 'crio')
container_runtime: containerd

# Timezone and language configuration
locale_lang: fr_FR.UTF-8
ntp_timezone: Europe/Paris
4 changes: 4 additions & 0 deletions deploy/roles/cni/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---

calico_cni_opts: "interface={{ network_interface }}"
flannel_cni_opts: "--iface={{ network_interface }}"
27 changes: 27 additions & 0 deletions deploy/roles/cni/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---

- name: Create Kubernetes addon directory
file:
path: "{{ network_dir }}"
state: directory

- name: "Copy {{ network }} YAML files"
template:
src: "{{ item }}"
dest: "{{ network_dir }}/{{ item | basename | regex_replace('\\.j2','') }}"
with_fileglob:
- ../templates/{{ network }}*.j2

- name: "Check {{ network }} daemonset is working"
shell: kubectl --kubeconfig={{ kubeadmin_config }} get ds --all-namespaces | grep {{ network }}
delegate_to: "{{ groups['master'][0] }}"
run_once: true
register: check_net
ignore_errors: true
changed_when: false

- name: "Create {{ network }} network daemonset"
when: check_net is failed
command: kubectl create --kubeconfig={{ kubeadmin_config }} -f {{ network_dir }}/
delegate_to: "{{ groups['master'][0] }}"
run_once: true
Loading

0 comments on commit 636dd5c

Please sign in to comment.