From b44622fa8a0a00c360a5e7f8a7de2a8365cca7bf Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 27 Feb 2024 12:43:16 +0100 Subject: [PATCH 1/6] Change default version --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 4b441f2a..87e68ee4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,5 @@ # Version to install or latest -kube_version: 1.23.7 +kube_version: 1.24.17 # Type of node front or wn kube_type_of_node: front # How to install K8s: kubeadm or k3s From 5bb20b7437a953572b2e5fbffc1a8ac243518c4e Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 29 Feb 2024 09:28:59 +0100 Subject: [PATCH 2/6] Fix tabs --- tasks/front.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tasks/front.yaml b/tasks/front.yaml index 1f00c769..3fcd03e4 100644 --- a/tasks/front.yaml +++ b/tasks/front.yaml @@ -59,10 +59,14 @@ when: add_kube_api_server_options is changed - name: wait Kube to start on "{{kube_wait_api_server_ip}}" - wait_for: - port: 6443 - host: "{{kube_wait_api_server_ip}}" - delay: 5 + uri: + url: "https://{{kube_wait_api_server_ip}}:6443/livez" + status_code: 200 + validate_certs: false + register: result + until: result.status == 200 + retries: 60 + delay: 1 - set_fact: KUBECONFIG: /etc/kubernetes/admin.conf From 0c468583dc92c57fe0289050208a4c9045a8a33c Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 29 Feb 2024 09:34:17 +0100 Subject: [PATCH 3/6] change delay --- tasks/front.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/front.yaml b/tasks/front.yaml index 3fcd03e4..3a329a13 100644 --- a/tasks/front.yaml +++ b/tasks/front.yaml @@ -65,8 +65,8 @@ validate_certs: false register: result until: result.status == 200 - retries: 60 - delay: 1 + retries: 30 + delay: 2 - set_fact: KUBECONFIG: /etc/kubernetes/admin.conf From ea557b8edf3ce9c86ac1656cfecf8039e206aac3 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 29 Feb 2024 09:40:09 +0100 Subject: [PATCH 4/6] Fix test --- tests/test-crio.yml | 2 +- tests/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-crio.yml b/tests/test-crio.yml index 7b554703..ce263eaa 100644 --- a/tests/test-crio.yml +++ b/tests/test-crio.yml @@ -3,7 +3,7 @@ roles: - role: ansible-role-kubernetes kube_install_metrics: true - kube_cert_manager: true + kube_cert_manager: false kube_install_kubeapps: false kube_install_kyverno: false kube_deploy_dashboard: true diff --git a/tests/test.yml b/tests/test.yml index 84a45d20..60d584bb 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -3,7 +3,7 @@ roles: - role: ansible-role-kubernetes kube_install_metrics: true - kube_cert_manager: true + kube_cert_manager: false kube_install_kubeapps: false kube_install_kyverno: false kube_deploy_dashboard: true From 5fe9d0b08ac53ad2240a47a2335cf75883021d50 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 29 Feb 2024 09:56:49 +0100 Subject: [PATCH 5/6] Fix test --- tests/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test.yml b/tests/test.yml index 60d584bb..61793feb 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -2,15 +2,15 @@ - hosts: localhost roles: - role: ansible-role-kubernetes - kube_install_metrics: true + kube_install_metrics: false kube_cert_manager: false kube_install_kubeapps: false kube_install_kyverno: false - kube_deploy_dashboard: true - kube_install_ingress: true + kube_deploy_dashboard: false + kube_install_ingress: false kube_public_dns_name: test.domain.com kube_version: 1.27.3 kube_cri_runtime: containerd - kube_install_docker_pip: true + kube_install_docker_pip: false kubelet_extra_args_dict: node-labels: somelabel From 7c931979d4cc70ae73e0415b915e736d0fd10755 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Thu, 29 Feb 2024 10:20:57 +0100 Subject: [PATCH 6/6] Add tasks names --- tasks/front.yaml | 35 +++++++++++++++++++++-------------- tasks/kube_nets.yaml | 27 ++++++++++++++++++--------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/tasks/front.yaml b/tasks/front.yaml index 3a329a13..94b76399 100644 --- a/tasks/front.yaml +++ b/tasks/front.yaml @@ -15,9 +15,6 @@ kube_wait_api_server_ip: "{{kube_api_server}}" when: kube_api_server != "0.0.0.0" - - name: wait Kube to start on "{{kube_wait_api_server_ip}}" - wait_for: port=6443 host="{{kube_wait_api_server_ip}}" - - set_fact: node_port_exists: false @@ -26,7 +23,7 @@ when: " '{{item.option}}' == '--service-node-port-range'" loop: "{{ kube_apiserver_options }}" - - name: Add Kube API server --service-node-port-rang option + - name: Add Kube API server --service-node-port-range option set_fact: kube_apiserver_options: "{{ [{'option': '--service-node-port-range', 'value': '80-35000'}] + kube_apiserver_options }}" when: kube_install_ingress | bool and not node_port_exists | bool @@ -124,15 +121,19 @@ - include_tasks: cert-manager.yaml - block: - - copy: src=kubernetes-dashboard.yaml dest=/tmp/kubernetes-dashboard.yaml - - command: kubectl apply -f /tmp/kubernetes-dashboard.yaml + - name: Create kubernetes-dashboard.yaml + copy: src=kubernetes-dashboard.yaml dest=/tmp/kubernetes-dashboard.yaml + - name: Apply kubernetes-dashboard.yaml + command: kubectl apply -f /tmp/kubernetes-dashboard.yaml environment: KUBECONFIG: "{{KUBECONFIG}}" when: kube_deploy_dashboard | bool - block: - - copy: src=metrics-server.yaml dest=/tmp/metrics-server.yaml - - command: kubectl apply -f /tmp/metrics-server.yaml + - name: Create metrics-server.yaml + copy: src=metrics-server.yaml dest=/tmp/metrics-server.yaml + - name: Apply metrics-server.yaml + command: kubectl apply -f /tmp/metrics-server.yaml environment: KUBECONFIG: "{{KUBECONFIG}}" when: kube_install_metrics | bool @@ -163,8 +164,10 @@ with_items: "{{ kube_apply_repos }}" - block: - - template: src=nfs-client.j2 dest=/tmp/nfs-client.yaml - - command: kubectl apply -f /tmp/nfs-client.yaml + - name: Create nfs-client.yaml + template: src=nfs-client.j2 dest=/tmp/nfs-client.yaml + - name: Apply nfs-client.yaml + command: kubectl apply -f /tmp/nfs-client.yaml environment: KUBECONFIG: "{{KUBECONFIG}}" when: kube_install_nfs_client | bool @@ -173,15 +176,19 @@ when: kube_install_ingress | bool - block: - - template: src=nvidia-device-plugin.j2 dest=/tmp/nvidia-device-plugin.yml - - command: kubectl apply -f /tmp/nvidia-device-plugin.yml + - name: Create nvidia-device-plugin.yaml + template: src=nvidia-device-plugin.j2 dest=/tmp/nvidia-device-plugin.yml + - name: Apply nvidia-device-plugin.yaml + command: kubectl apply -f /tmp/nvidia-device-plugin.yml environment: KUBECONFIG: "{{KUBECONFIG}}" when: kube_nvidia_support | bool - block: - - template: src=kubernetes-dashboard-ingress.j2 dest=/tmp/kubernetes-dashboard-ingress.yaml - - command: kubectl apply -f /tmp/kubernetes-dashboard-ingress.yaml + - name: Create kubernetes-dashboard-ingress.yaml + template: src=kubernetes-dashboard-ingress.j2 dest=/tmp/kubernetes-dashboard-ingress.yaml + - name: Apply kubernetes-dashboard-ingress.yaml + command: kubectl apply -f /tmp/kubernetes-dashboard-ingress.yaml environment: KUBECONFIG: "{{KUBECONFIG}}" when: kube_install_ingress | bool and kube_deploy_dashboard | bool diff --git a/tasks/kube_nets.yaml b/tasks/kube_nets.yaml index 3b518a7a..9c4eb620 100644 --- a/tasks/kube_nets.yaml +++ b/tasks/kube_nets.yaml @@ -1,5 +1,6 @@ --- -- lineinfile: +- name: Set net.bridge.bridge-nf-call-iptables to 1 + lineinfile: dest: /etc/sysctl.d/k8s.conf regexp: '^net.bridge.bridge-nf-call-iptables' line: 'net.bridge.bridge-nf-call-iptables = 1' @@ -8,29 +9,37 @@ when: kube_network == 'flannel' or kube_network == 'kube-router' - block: - - template: src=flannel-net.j2 dest=/tmp/flannel-net.yml - - command: kubectl apply -f /tmp/flannel-net.yml creates=/etc/cni/net.d/10-flannel.conflist + - name: Create flannel-net.yaml + template: src=flannel-net.j2 dest=/tmp/flannel-net.yml + - name: Apply flannel-net.yaml + command: kubectl apply -f /tmp/flannel-net.yml creates=/etc/cni/net.d/10-flannel.conflist environment: KUBECONFIG: /etc/kubernetes/admin.conf when: kube_network == 'flannel' - block: - - copy: src=calico-net.yaml dest=/tmp/calico-net.yaml - - command: kubectl apply -f /tmp/calico-net.yaml creates=/var/etcd/calico-data + - name: Create calico-net.yaml + copy: src=calico-net.yaml dest=/tmp/calico-net.yaml + - name: Apply calico-net.yaml + command: kubectl apply -f /tmp/calico-net.yaml creates=/var/etcd/calico-data environment: KUBECONFIG: /etc/kubernetes/admin.conf when: kube_network == 'calico' - block: - - copy: src=kuberouter-net.yaml dest=/tmp/kuberouter-net.yaml - - command: kubectl apply -f /tmp/kuberouter-net.yaml creates=/etc/cni/net.d/10-kuberouter.conf + - name: Create kuberouter-net.yaml + copy: src=kuberouter-net.yaml dest=/tmp/kuberouter-net.yaml + - name: Apply kuberouter-net.yaml + command: kubectl apply -f /tmp/kuberouter-net.yaml creates=/etc/cni/net.d/10-kuberouter.conf environment: KUBECONFIG: /etc/kubernetes/admin.conf when: kube_network == 'kube-router' - block: - - copy: src=weave-net.yaml dest=/tmp/weave-net.yaml - - command: kubectl apply -f /tmp/weave-net.yaml creates=/etc/cni/net.d/10-weave.conf + - name: Create weave-net.yaml + copy: src=weave-net.yaml dest=/tmp/weave-net.yaml + - name: Apply weave-net.yaml + command: kubectl apply -f /tmp/weave-net.yaml creates=/etc/cni/net.d/10-weave.conf environment: KUBECONFIG: /etc/kubernetes/admin.conf when: kube_network == 'weave'