From a43420a3d3a999371ed8190ee484df3924670802 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 27 Feb 2024 11:48:38 +0100 Subject: [PATCH 01/11] Update K8s package installation --- tasks/Debian.yaml | 66 +++++++++++++++++++++++++++-------------------- tasks/RedHat.yaml | 47 ++++++++++++++++++++++++++------- 2 files changed, 75 insertions(+), 38 deletions(-) diff --git a/tasks/Debian.yaml b/tasks/Debian.yaml index 58675ea1..d02aec4b 100644 --- a/tasks/Debian.yaml +++ b/tasks/Debian.yaml @@ -1,33 +1,43 @@ --- -- name: Add repo key - get_url: - url: "https://packages.cloud.google.com/apt/doc/apt-key.gpg" - dest: /etc/apt/trusted.gpg.d/google.gpg - mode: '0644' - force: true - register: add_key - ignore_errors: yes +- name: Add repo for new Kubernetes versions + block: + when: kube_version is version('1.24', '>=') + + - set_fact: + kube_minor_version: "{{ kube_version.split('.')[0] }}"."{{ kube_version.split('.')[1] }}" + + get_url: + url: "https://pkgs.k8s.io/core:/stable:/v1.{{ kube_minor_version }}/deb/Release.key" + dest: /etc/apt/keyrings/kubernetes-apt-keyring.asc + mode: '0644' + + - name: Add kubernetes repo + apt_repository: repo='deb https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/deb/ /' state=present update_cache=yes + + +- name: Add repo for old Kubernetes versions + block: + when: kube_version is version('1.24', '<') + + - name: Add repo key + get_url: + url: "https://packages.cloud.google.com/apt/doc/apt-key.gpg" + dest: /etc/apt/trusted.gpg.d/google.gpg + mode: '0644' + force: true + register: add_key + ignore_errors: yes + + - name: Add repo key copy with asc extension to workarond issues + copy: + src: /etc/apt/trusted.gpg.d/google.gpg + dest: /etc/apt/trusted.gpg.d/google.asc + mode: '0644' + remote_src: yes + when: add_key is changed -# Sometimes google key fails with error 500 -# https://github.com/kubernetes/release/issues/100 -# So we copied it at GRyCAP and use it in case of error -- name: Add repo key backup - get_url: - url: "http://ftpgrycap.i3m.upv.es/ubuntu/google-apt-key.gpg" - dest: /etc/apt/trusted.gpg.d/google.asc - mode: '0644' - when: add_key is failed - -- name: Add repo key copy with asc extension to workarond issues - copy: - src: /etc/apt/trusted.gpg.d/google.gpg - dest: /etc/apt/trusted.gpg.d/google.asc - mode: '0644' - remote_src: yes - when: add_key is changed - -- name: Add kubernetes repo - apt_repository: repo='deb http://apt.kubernetes.io/ kubernetes-xenial main' state=present update_cache=yes + - name: Add kubernetes repo + apt_repository: repo='deb http://apt.kubernetes.io/ kubernetes-xenial main' state=present update_cache=yes - name: Install kubernetes packages apt: name=kubelet={{ kube_version }}*,kubeadm={{ kube_version }}*,kubectl={{ kube_version }}* diff --git a/tasks/RedHat.yaml b/tasks/RedHat.yaml index d5d1a955..a70f8f4b 100644 --- a/tasks/RedHat.yaml +++ b/tasks/RedHat.yaml @@ -1,19 +1,46 @@ --- -- copy: - dest: /etc/yum.repos.d/kubernetes.repo - content: | +- name: Add repo for new Kubernetes versions + block: + when: kube_version is version('1.24', '>=') + + - set_fact: + kube_minor_version: "{{ kube_version.split('.')[0] }}"."{{ kube_version.split('.')[1] }}" + + - copy: + dest: /etc/yum.repos.d/kubernetes.repo + content: | [kubernetes] name=Kubernetes - baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 + baseurl=https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/ enabled=1 gpgcheck=0 repo_gpgcheck=0 - gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg + gpgkey=https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/repodata/repomd.xml.key + exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni + + - name: import gpg key + rpm_key: + key: https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/repodata/repomd.xml.key + state: present + +- name: Add repo for old Kubernetes versions + block: + when: kube_version is version('1.24', '<') + - copy: + dest: /etc/yum.repos.d/kubernetes.repo + content: | + [kubernetes] + name=Kubernetes + baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 + enabled=1 + gpgcheck=0 + repo_gpgcheck=0 + gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg -- name: import gpg key - rpm_key: - key: https://packages.cloud.google.com/yum/doc/yum-key.gpg - state: present + - name: import gpg key + rpm_key: + key: https://packages.cloud.google.com/yum/doc/yum-key.gpg + state: present - name: Install kubernetes packages package: name=psmisc,kubelet-{{kube_version}},kubeadm-{{kube_version}},kubectl-{{kube_version}},yum-plugin-versionlock state=present update_cache=yes @@ -24,7 +51,7 @@ when: kube_version == "latest" - name: Version lock kubernetes packages - command: yum versionlock add kubelet kubeadm kubectl + command: yum versionlock add kubelet kubeadm kubectl cri-tools kubernetes-cni register: yum_versionlock changed_when: "'versionlock added: 1' in yum_versionlock.stdout_lines" ignore_errors: yes From 081ee22074fac7e70afc9c7bd24526534f641e9f Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 27 Feb 2024 11:49:25 +0100 Subject: [PATCH 02/11] Update K8s package installation --- tests/test-crio.yml | 2 +- tests/test-docker.yml | 2 +- tests/test.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test-crio.yml b/tests/test-crio.yml index 2169949b..7b554703 100644 --- a/tests/test-crio.yml +++ b/tests/test-crio.yml @@ -9,7 +9,7 @@ kube_deploy_dashboard: true kube_install_ingress: true kube_public_dns_name: test.domain.com - kube_version: 1.25.3 + kube_version: 1.28.3 kube_cri_runtime: crio kubelet_extra_args_dict: node-labels: somelabel diff --git a/tests/test-docker.yml b/tests/test-docker.yml index 77866b72..e1d52586 100644 --- a/tests/test-docker.yml +++ b/tests/test-docker.yml @@ -9,7 +9,7 @@ kube_deploy_dashboard: true kube_install_ingress: true kube_public_dns_name: test.domain.com - kube_version: 1.25.3 + kube_version: 1.26.3 kube_cri_runtime: docker kube_cri_runtime_install: false kube_install_docker_pip: true diff --git a/tests/test.yml b/tests/test.yml index 0459d3e1..84a45d20 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -9,7 +9,7 @@ kube_deploy_dashboard: true kube_install_ingress: true kube_public_dns_name: test.domain.com - kube_version: 1.25.3 + kube_version: 1.27.3 kube_cri_runtime: containerd kube_install_docker_pip: true kubelet_extra_args_dict: From 6352257cb2bf4ae5517b9d3245c55a3c4b0a9197 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 27 Feb 2024 11:56:36 +0100 Subject: [PATCH 03/11] Update K8s package installation --- tasks/Debian.yaml | 4 ++-- tasks/RedHat.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/Debian.yaml b/tasks/Debian.yaml index d02aec4b..0be2c550 100644 --- a/tasks/Debian.yaml +++ b/tasks/Debian.yaml @@ -1,7 +1,7 @@ --- - name: Add repo for new Kubernetes versions block: - when: kube_version is version('1.24', '>=') + when: "kube_version is version('1.24', '>=')" - set_fact: kube_minor_version: "{{ kube_version.split('.')[0] }}"."{{ kube_version.split('.')[1] }}" @@ -17,7 +17,7 @@ - name: Add repo for old Kubernetes versions block: - when: kube_version is version('1.24', '<') + when: "kube_version is version('1.24', '<')" - name: Add repo key get_url: diff --git a/tasks/RedHat.yaml b/tasks/RedHat.yaml index a70f8f4b..10c8334e 100644 --- a/tasks/RedHat.yaml +++ b/tasks/RedHat.yaml @@ -1,7 +1,7 @@ --- - name: Add repo for new Kubernetes versions block: - when: kube_version is version('1.24', '>=') + when: "kube_version is version('1.24', '>=')" - set_fact: kube_minor_version: "{{ kube_version.split('.')[0] }}"."{{ kube_version.split('.')[1] }}" @@ -25,7 +25,7 @@ - name: Add repo for old Kubernetes versions block: - when: kube_version is version('1.24', '<') + when: "kube_version is version('1.24', '<')" - copy: dest: /etc/yum.repos.d/kubernetes.repo content: | From 77737f6a9828923ac910eac8e9d26d5b092c5902 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 27 Feb 2024 12:00:12 +0100 Subject: [PATCH 04/11] Fix typo --- tasks/Debian.yaml | 6 ++++-- tasks/RedHat.yaml | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tasks/Debian.yaml b/tasks/Debian.yaml index 0be2c550..fd8ed78e 100644 --- a/tasks/Debian.yaml +++ b/tasks/Debian.yaml @@ -3,9 +3,11 @@ block: when: "kube_version is version('1.24', '>=')" - - set_fact: - kube_minor_version: "{{ kube_version.split('.')[0] }}"."{{ kube_version.split('.')[1] }}" + - name: Set kube_minor_version + set_fact: + kube_minor_version: "{{ kube_version.split('.')[0] }}"."{{ kube_version.split('.')[1] }}" + - name: Add repo key get_url: url: "https://pkgs.k8s.io/core:/stable:/v1.{{ kube_minor_version }}/deb/Release.key" dest: /etc/apt/keyrings/kubernetes-apt-keyring.asc diff --git a/tasks/RedHat.yaml b/tasks/RedHat.yaml index 10c8334e..9566e987 100644 --- a/tasks/RedHat.yaml +++ b/tasks/RedHat.yaml @@ -3,10 +3,12 @@ block: when: "kube_version is version('1.24', '>=')" - - set_fact: - kube_minor_version: "{{ kube_version.split('.')[0] }}"."{{ kube_version.split('.')[1] }}" + - name: Set kube_minor_version + set_fact: + kube_minor_version: "{{ kube_version.split('.')[0] }}"."{{ kube_version.split('.')[1] }}" - - copy: + - name: Set repo file + copy: dest: /etc/yum.repos.d/kubernetes.repo content: | [kubernetes] From 4ab8c2115c5204a6ffef47ae2ae4e7c9198862ec Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 27 Feb 2024 12:03:23 +0100 Subject: [PATCH 05/11] Fix typo --- tasks/Debian.yaml | 2 +- tasks/RedHat.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/Debian.yaml b/tasks/Debian.yaml index fd8ed78e..4e0f595e 100644 --- a/tasks/Debian.yaml +++ b/tasks/Debian.yaml @@ -5,7 +5,7 @@ - name: Set kube_minor_version set_fact: - kube_minor_version: "{{ kube_version.split('.')[0] }}"."{{ kube_version.split('.')[1] }}" + kube_minor_version: "{{ kube_version.split('.')[0] }}.{{ kube_version.split('.')[1] }}" - name: Add repo key get_url: diff --git a/tasks/RedHat.yaml b/tasks/RedHat.yaml index 9566e987..c5a13ee0 100644 --- a/tasks/RedHat.yaml +++ b/tasks/RedHat.yaml @@ -5,7 +5,7 @@ - name: Set kube_minor_version set_fact: - kube_minor_version: "{{ kube_version.split('.')[0] }}"."{{ kube_version.split('.')[1] }}" + kube_minor_version: "{{ kube_version.split('.')[0] }}.{{ kube_version.split('.')[1] }}" - name: Set repo file copy: From b6fafe93a42e6e2b0b2d55ba15f6d537c5b1fa17 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 27 Feb 2024 12:11:59 +0100 Subject: [PATCH 06/11] Fix typo --- tasks/Debian.yaml | 12 +++++------- tasks/RedHat.yaml | 16 +++++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tasks/Debian.yaml b/tasks/Debian.yaml index 4e0f595e..b169e1aa 100644 --- a/tasks/Debian.yaml +++ b/tasks/Debian.yaml @@ -1,7 +1,4 @@ ---- -- name: Add repo for new Kubernetes versions - block: - when: "kube_version is version('1.24', '>=')" +- block: - name: Set kube_minor_version set_fact: @@ -16,10 +13,9 @@ - name: Add kubernetes repo apt_repository: repo='deb https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/deb/ /' state=present update_cache=yes + when: "kube_version is version('1.24', '>=')" -- name: Add repo for old Kubernetes versions - block: - when: "kube_version is version('1.24', '<')" +- block: - name: Add repo key get_url: @@ -41,6 +37,8 @@ - name: Add kubernetes repo apt_repository: repo='deb http://apt.kubernetes.io/ kubernetes-xenial main' state=present update_cache=yes + when: "kube_version is version('1.24', '<')" + - name: Install kubernetes packages apt: name=kubelet={{ kube_version }}*,kubeadm={{ kube_version }}*,kubectl={{ kube_version }}* when: kube_version != "latest" and (kubeadm_output.stdout == '' or kubeadm_output.stdout is version(kube_version, '<=')) diff --git a/tasks/RedHat.yaml b/tasks/RedHat.yaml index c5a13ee0..be116ae9 100644 --- a/tasks/RedHat.yaml +++ b/tasks/RedHat.yaml @@ -1,7 +1,5 @@ --- -- name: Add repo for new Kubernetes versions - block: - when: "kube_version is version('1.24', '>=')" +- block: - name: Set kube_minor_version set_fact: @@ -25,10 +23,12 @@ key: https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/repodata/repomd.xml.key state: present -- name: Add repo for old Kubernetes versions - block: - when: "kube_version is version('1.24', '<')" - - copy: + when: "kube_version is version('1.24', '>=')" + +- block: + + - name: Set repo file + copy: dest: /etc/yum.repos.d/kubernetes.repo content: | [kubernetes] @@ -44,6 +44,8 @@ key: https://packages.cloud.google.com/yum/doc/yum-key.gpg state: present + when: "kube_version is version('1.24', '<')" + - name: Install kubernetes packages package: name=psmisc,kubelet-{{kube_version}},kubeadm-{{kube_version}},kubectl-{{kube_version}},yum-plugin-versionlock state=present update_cache=yes when: kube_version != "latest" and (kubeadm_output.stdout == '' or kubeadm_output.stdout is version(kube_version, '<=')) From 1e0d2a067d88f61d3874a01d0d03744fb8a1ffdd Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 27 Feb 2024 12:14:30 +0100 Subject: [PATCH 07/11] Fix typo --- tasks/Debian.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/Debian.yaml b/tasks/Debian.yaml index b169e1aa..bef4f475 100644 --- a/tasks/Debian.yaml +++ b/tasks/Debian.yaml @@ -6,7 +6,7 @@ - name: Add repo key get_url: - url: "https://pkgs.k8s.io/core:/stable:/v1.{{ kube_minor_version }}/deb/Release.key" + url: "https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/deb/Release.key" dest: /etc/apt/keyrings/kubernetes-apt-keyring.asc mode: '0644' From 541deba1326a5b1b733f50acc380185fc7ae62a9 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 27 Feb 2024 12:19:21 +0100 Subject: [PATCH 08/11] Fix typo --- tasks/Debian.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/Debian.yaml b/tasks/Debian.yaml index bef4f475..2d1bc531 100644 --- a/tasks/Debian.yaml +++ b/tasks/Debian.yaml @@ -7,7 +7,7 @@ - name: Add repo key get_url: url: "https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/deb/Release.key" - dest: /etc/apt/keyrings/kubernetes-apt-keyring.asc + dest: /etc/apt/trusted.gpg.d/kubernetes.asc mode: '0644' - name: Add kubernetes repo From 60af59daa9a21e64464954acf25cf4694569b973 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 19 Dec 2023 11:26:48 +0100 Subject: [PATCH 09/11] fix test --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4092e96b..48a79f67 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -94,7 +94,7 @@ jobs: run: sudo apt update && sudo apt install -y python3 python3-pip python3-setuptools - name: Remove pre-installed kubectl to avoid errors - run: sudo apt remove buildah podman -y + run: sudo apt remove kubeadm kubelet kubectl buildah podman -y - name: Stop containerd run: sudo systemctl stop containerd; sudo rm -f /var/run/containerd/containerd.sock From ffab0a5a2caa19c17b30148263b0e147fce2e1a1 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 19 Dec 2023 11:27:49 +0100 Subject: [PATCH 10/11] fix test --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 48a79f67..a6db96a6 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -94,7 +94,7 @@ jobs: run: sudo apt update && sudo apt install -y python3 python3-pip python3-setuptools - name: Remove pre-installed kubectl to avoid errors - run: sudo apt remove kubeadm kubelet kubectl buildah podman -y + run: sudo apt remove kubectl buildah podman -y - name: Stop containerd run: sudo systemctl stop containerd; sudo rm -f /var/run/containerd/containerd.sock From 879ae3b53173be419a589687dd33abb3c29866c3 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 19 Dec 2023 11:34:56 +0100 Subject: [PATCH 11/11] fix test --- .github/workflows/main.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a6db96a6..67bc0fcc 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -22,7 +22,7 @@ jobs: run: sudo apt update && sudo apt install -y python3 python3-pip python3-setuptools - name: Remove pre-installed kubectl to avoid errors - run: sudo apt remove buildah podman -y + run: sudo apt remove kubectl buildah podman -y - name: Install Ansible run: sudo pip3 install dnspython ansible==2.9.22 @@ -58,7 +58,7 @@ jobs: run: sudo apt update && sudo apt install -y python3 python3-pip python3-setuptools - name: Remove pre-installed kubectl to avoid errors - run: sudo apt remove buildah podman -y + run: sudo apt remove kubectl buildah podman -y - name: Install Ansible run: sudo pip3 install ansible==2.9.22 @@ -132,7 +132,7 @@ jobs: run: sudo apt update && sudo apt install -y python3 python3-pip python3-setuptools - name: Remove pre-installed kubectl to avoid errors - run: sudo apt remove buildah podman -y + run: sudo apt remove kubectl buildah podman -y - name: Install Ansible run: sudo pip3 install dnspython ansible==2.9.22