From 9aae239f76862f4840c24e8383aa655e79ef45ae Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Wed, 20 Mar 2024 08:55:58 +0100 Subject: [PATCH 1/2] Remove unsupported version --- tasks/Debian.yaml | 50 +++++++++------------------------- tasks/RedHat.yaml | 68 +++++++++++++++++------------------------------ 2 files changed, 37 insertions(+), 81 deletions(-) diff --git a/tasks/Debian.yaml b/tasks/Debian.yaml index 2d1bc531..03986068 100644 --- a/tasks/Debian.yaml +++ b/tasks/Debian.yaml @@ -1,43 +1,19 @@ -- 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 +- fail: + msg: "Kubernetes version {{ kube_version }} is not supported" + when: "kube_version is version('1.24', '<')" - - 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: Set kube_minor_version + set_fact: + kube_minor_version: "{{ kube_version.split('.')[0] }}.{{ kube_version.split('.')[1] }}" - - name: Add kubernetes repo - apt_repository: repo='deb http://apt.kubernetes.io/ kubernetes-xenial main' state=present update_cache=yes +- 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' - when: "kube_version is version('1.24', '<')" +- 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: 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 be116ae9..aa5f5eb8 100644 --- a/tasks/RedHat.yaml +++ b/tasks/RedHat.yaml @@ -1,50 +1,30 @@ --- -- 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://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/ - enabled=1 - gpgcheck=0 - repo_gpgcheck=0 - 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 +- fail: + msg: "Kubernetes version {{ kube_version }} is not supported" + when: "kube_version is version('1.24', '<')" - - name: import gpg key - rpm_key: - key: https://packages.cloud.google.com/yum/doc/yum-key.gpg - state: present +- 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://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/ + enabled=1 + gpgcheck=0 + repo_gpgcheck=0 + 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', '<')" - name: Install kubernetes packages package: name=psmisc,kubelet-{{kube_version}},kubeadm-{{kube_version}},kubectl-{{kube_version}},yum-plugin-versionlock state=present update_cache=yes From 66f44445486727868070f24e8c08f351022fe961 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Wed, 20 Mar 2024 08:57:00 +0100 Subject: [PATCH 2/2] Remove unsupported version --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6cfdf6ff..1a3ea3ef 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ Role Variables The variables that can be passed to this role and a brief description about them are as follows. - # Version to install or latest - kube_version: 1.11.4 + # Version to install or latest (1.24 or higher) + kube_version: 1.24.17 # Type of node front or wn kube_type_of_node: front # IP address or name of the Kube front node