diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4092e96b..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 @@ -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 kubectl buildah podman -y - name: Stop containerd run: sudo systemctl stop containerd; sudo rm -f /var/run/containerd/containerd.sock @@ -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 diff --git a/tasks/Debian.yaml b/tasks/Debian.yaml index 58675ea1..2d1bc531 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 +- block: + + - 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:/v{{ kube_minor_version }}/deb/Release.key" + dest: /etc/apt/trusted.gpg.d/kubernetes.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 + + when: "kube_version is version('1.24', '>=')" + +- block: + + - 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 + + - name: Add kubernetes repo + apt_repository: repo='deb http://apt.kubernetes.io/ kubernetes-xenial main' state=present update_cache=yes -# 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 + when: "kube_version is version('1.24', '<')" - 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..be116ae9 100644 --- a/tasks/RedHat.yaml +++ b/tasks/RedHat.yaml @@ -1,19 +1,50 @@ --- -- copy: - dest: /etc/yum.repos.d/kubernetes.repo - content: | +- block: + + - name: Set kube_minor_version + set_fact: + kube_minor_version: "{{ kube_version.split('.')[0] }}.{{ kube_version.split('.')[1] }}" + + - name: Set repo file + 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 + + when: "kube_version is version('1.24', '>=')" + +- block: + + - name: Set repo file + 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 + 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 @@ -24,7 +55,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 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: