Skip to content

Commit

Permalink
fix(vagrant): vm to macos
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeptossss committed Dec 18, 2023
1 parent 636dd5c commit 8639333
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 33 deletions.
9 changes: 5 additions & 4 deletions deploy/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Variables
# Image à utiliser
IMAGE_NAME = "perk/ubuntu-20.04-arm64"
IMAGE_NAME = "bento/ubuntu-20.04-arm64"
# RAM
MEM = 2048
# Nombre de CPU
Expand All @@ -14,11 +14,12 @@ MASTER_IP = "#{NODE_NETWORK_BASE}.10"

Vagrant.configure("2") do |config|
config.ssh.insert_key = false
config.vm.network "public_network", dev: "en0", bridge: "en0", mode: "bridge"

# Configuration de la RAM et du CPU
config.vm.provider "qemu" do |qe|
qe.memory = MEM
qe.smp = CPU
config.vm.provider "parallels" do |prl|
prl.memory = MEM
prl.cpus = CPU
end

# Configuration du Master
Expand Down
16 changes: 8 additions & 8 deletions deploy/roles/cni/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

- name: Create Kubernetes addon directory
file:
path: "{{ network_dir }}"
path: "/etc/kubernetes/network"
state: directory

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

- name: "Check {{ network }} daemonset is working"
shell: kubectl --kubeconfig={{ kubeadmin_config }} get ds --all-namespaces | grep {{ network }}
- name: "Check calico daemonset is working"
shell: kubectl --kubeconfig=/etc/kubernetes/admin.conf wait --for=condition=ready pod -l k8s-app=calico-node --all-namespaces --timeout=300s
delegate_to: "{{ groups['master'][0] }}"
run_once: true
register: check_net
ignore_errors: true
changed_when: false

- name: "Create {{ network }} network daemonset"
- name: "Create calico network daemonset"
when: check_net is failed
command: kubectl create --kubeconfig={{ kubeadmin_config }} -f {{ network_dir }}/
command: kubectl create --kubeconfig=/etc/kubernetes/admin.conf -f /etc/kubernetes/network/
delegate_to: "{{ groups['master'][0] }}"
run_once: true
2 changes: 1 addition & 1 deletion deploy/roles/cni/templates/calico.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3670,7 +3670,7 @@ spec:
# chosen from this range. Changing this value after installation will have
# no effect. This should fall within `--cluster-cidr`.
- name: CALICO_IPV4POOL_CIDR
value: "{{ pod_network_cidr }}"
value: "10.244.0.0/16"
# Disable file logging so `kubectl logs` works.
- name: CALICO_DISABLE_FILE_LOGGING
value: "true"
Expand Down
2 changes: 1 addition & 1 deletion deploy/roles/cni/templates/canal.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ data:
# Flannel network configuration. Mounted into the flannel container.
net-conf.json: |
{
"Network": "{{ pod_network_cidr }}",
"Network": "10.244.0.0/16",
"Backend": {
"Type": "vxlan"
}
Expand Down
2 changes: 1 addition & 1 deletion deploy/roles/cni/templates/flannel.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ data:
}
net-conf.json: |
{
"Network": "{{ pod_network_cidr }}",
"Network": "10.244.0.0/16",
"Backend": {
"Type": "vxlan"
}
Expand Down
1 change: 0 additions & 1 deletion deploy/roles/commons/pre-install/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
- name: Add Kubernetes APT GPG key
when: ansible_os_family == "Debian"
apt_key:
Expand Down
16 changes: 7 additions & 9 deletions deploy/roles/kubernetes/master/tasks/init.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
---

- name: Reset Kubernetes component
shell: "kubeadm reset --force --cri-socket=/var/run/{{ container_runtime }}/{{ container_runtime }}.sock"
shell: "kubeadm reset --force --cri-socket=/var/run/containerd/containerd.sock"
register: reset_cluster

- name: Init Kubernetes cluster
when: reset_cluster is succeeded
shell: |
kubeadm init --service-cidr {{ service_cidr }} \
--kubernetes-version {{ kube_version }} \
--pod-network-cidr {{ pod_network_cidr }} \
--token {{ token }} \
kubeadm init --service-cidr 10.96.0.0/12 \
--kubernetes-version 1.20.11 \
--pod-network-cidr 10.244.0.0/16 \
--token b0f7b8.8d1767876297d85c \
--apiserver-advertise-address {{ master_ip }} \
--cri-socket=/var/run/{{ container_runtime }}/{{ container_runtime }}.sock \
{{ kubeadm_opts }} \
{{ init_opts }}
--cri-socket=/var/run/containerd/containerd.sock
register: init_cluster
environment:
no_proxy: "$no_proxy,.svc,.svc.cluster.local"
Expand All @@ -27,7 +25,7 @@
- name: Copy admin.conf to Home directory
when: init_cluster is succeeded
copy:
src: "{{ kubeadmin_config }}"
src: "/etc/kubernetes/admin.conf"
dest: ".kube/config"
owner: "{{ ansible_user | default(ansible_user_id) }}"
group: "{{ ansible_user | default(ansible_user_id) }}"
Expand Down
4 changes: 4 additions & 0 deletions deploy/roles/kubernetes/master/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@
run_once: yes
ignore_errors: yes

- name: Install Whanos
include_tasks: whanos.yml
run_once: yes

13 changes: 13 additions & 0 deletions deploy/roles/kubernetes/master/tasks/whanos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

- name: Create Whanos directory
shell: "mkdir /Whanos"

- name: Git checkout Whanos from repository
shell: "git clone https://github.com/Tux-Inc/Whanos.git /Whanos"

- name: Changing perm for scripts
file: dest=/Whanos/scripts mode=u=rwX,g=rX,o=rX recurse=yes

- name: Master Whanos hydration
shell: "sh -c /Whanos/scripts/installation/all.sh"
2 changes: 1 addition & 1 deletion deploy/roles/kubernetes/node/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Recreate kube-dns
command: kubectl --kubeconfig={{ kubeadmin_config }} -n kube-system delete pods -l k8s-app=kube-dns
command: kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system delete pods -l k8s-app=kube-dns
delegate_to: "{{ groups['master'][0] }}"
run_once: true
ignore_errors: true
6 changes: 3 additions & 3 deletions deploy/roles/kubernetes/node/tasks/join.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---

- name: Reset Kubernetes component
shell: "kubeadm reset --force --cri-socket=/var/run/{{ container_runtime }}/{{ container_runtime }}.sock"
shell: "kubeadm reset --force --cri-socket=/var/run/containerd/containerd.sock"
register: reset_cluster

- name: Join to Kubernetes cluster
when: reset_cluster is succeeded
shell: |
kubeadm join --token {{ token }} \
kubeadm join --token b0f7b8.8d1767876297d85c \
--discovery-token-unsafe-skip-ca-verification \
--cri-socket=/var/run/{{ container_runtime }}/{{ container_runtime }}.sock \
--cri-socket=/var/run/containerd/containerd.sock \
{{ master_ip }}:6443
register: join_cluster
environment:
Expand Down
8 changes: 4 additions & 4 deletions scripts/installation/all.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/bin/bash
printf "🏗️ Installing kubetools\n"
./scripts/installation/kubetools.sh
/Whanos/scripts/installation/kubetools.sh
if [ $? -ne 0 ]; then
printf "❌ Installation of kubetools failed\n"
exit 1
fi
printf "\n\n\n✅ Installation of kubetools completed successfully\n\n\n"

printf "🏗️ Installing docker registry\n"
./scripts/installation/docker-registry.sh
/Whanos/scripts/installation/docker-registry.sh
if [ $? -ne 0 ]; then
printf "❌ Installation of docker registry failed\n"
exit 1
fi
printf "\n\n\n✅ Installation of docker registry completed successfully\n"

printf "🏗️ Installing jenkins\n"
./scripts/installation/jenkins.sh
/Whanos/scripts/installation/jenkins.sh
if [ $? -ne 0 ]; then
echo "❌ Installation of jenkins failed\n"
exit 1
Expand All @@ -27,7 +27,7 @@ printf "\n\n\nINSTALLATION COMPLETED SUCCESSFULLY\n"
printf "\n\n\n\n\n"

printf "========INSTALLATION SUMMARY========\n"
./scripts/installation/installation-summary.sh
/Whanos/scripts/installation/installation-summary.sh
if [ $? -ne 0 ]; then
echo "❌ Installation summary failed\n"
exit 1
Expand Down

0 comments on commit 8639333

Please sign in to comment.