Skip to content

Commit

Permalink
update kube repo
Browse files Browse the repository at this point in the history
  • Loading branch information
jarpat committed Jan 4, 2024
1 parent db126c2 commit 48625dc
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 27 deletions.
10 changes: 10 additions & 0 deletions roles/kubernetes/toolbox/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright © 2022-2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

---
# Allows users to overwrite deb revisions of the kube toolbox packages
# kubelet, kubeadm, & kubectl which will be installed on all the
# ansible "k8s" hosts.
# It's not recommended you change this value unless for debugging purposes.
# leaving it as am empty string will result in the latest deb rev for the packages
kube_deb_rev: ""
65 changes: 38 additions & 27 deletions roles/kubernetes/toolbox/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,52 @@
# Installing Kubernetes tooling
#

# Apply Google Cloud public signing key
- name: Apply Google Cloud public signing key
ansible.builtin.get_url:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
dest: /usr/share/keyrings/kubernetes-archive-keyring.gpg
when: ansible_distribution == "Ubuntu" and (ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04")
tags:
- install
- update

# Add Kubernetes apt repository
- name: Add Kubernetes apt repository
ansible.builtin.copy:
dest: /etc/apt/sources.list.d/kubernetes.list
content: |
deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg trusted=yes] https://apt.kubernetes.io/ kubernetes-xenial main
when: ansible_distribution == "Ubuntu" and (ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04")
# Only applicable for releases older than Ubuntu 22.04
- name: Create /etc/apt/keyrings directory
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: "0755"
owner: root
group: root
when: ansible_distribution == "Ubuntu" and (ansible_distribution_version == "20.04")
tags:
- install
- update

- name: Set kubernetes version facts for crictl
- name: Set kubernetes version facts for toolbox installation
set_fact:
k8s_version_semantic_parts: "{{ kubernetes_version.split('.') }}"
when: kubernetes_cri|lower != 'docker'
tags:
- install
- update

- name: Set kubernetes version part facts for crictl
- name: Set kubernetes version part facts for toolbox installation
set_fact:
k8s_major_version: "{% if k8s_version_semantic_parts|length > 0 %}{{ k8s_version_semantic_parts.0 }}{% endif %}"
k8s_minor_version: "{% if k8s_version_semantic_parts|length > 1 %}{{ k8s_version_semantic_parts.1 }}{% endif %}"
k8s_patch_version: "{% if k8s_version_semantic_parts|length > 2 %}{{ k8s_version_semantic_parts.2 }}{% else %}0{% endif %}"
when: kubernetes_cri|lower != 'docker'
tags:
- install
- update

# Apply Kubernetes public signing key
- name: Apply Kubernetes public signing key
ansible.builtin.get_url:
url: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_major_version }}.{{ k8s_minor_version }}/deb/Release.key"
dest: /etc/apt/keyrings/kubernetes-apt-keyring.asc
when: ansible_distribution == "Ubuntu" and (ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04")
tags:
- install
- update

# Add Kubernetes apt repository
- name: add Kubernetes apt repository

Check failure on line 49 in roles/kubernetes/toolbox/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / ansible-lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.asc] https://pkgs.k8s.io/core:/stable:/v{{ k8s_major_version }}.{{ k8s_minor_version }}/deb/ /"
state: present
update_cache: yes

Check failure on line 53 in roles/kubernetes/toolbox/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[truthy]

Truthy value should be one of \[false, true]
when: ansible_distribution == "Ubuntu" and (ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04")
tags:
- install
- update
Expand Down Expand Up @@ -108,9 +119,9 @@
- name: Update apt package index and install kubelet, kubeadm, kubectl
ansible.builtin.apt:
pkg:

Check warning on line 121 in roles/kubernetes/toolbox/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / ansible-lint

jinja[spacing]

Jinja2 spacing could be improved: kubeadm={{ kubernetes_version }}-{{kube_deb_rev}} -> kubeadm={{ kubernetes_version }}-{{ kube_deb_rev }}

Check warning on line 121 in roles/kubernetes/toolbox/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / ansible-lint

jinja[spacing]

Jinja2 spacing could be improved: kubectl={{ kubernetes_version }}-{{kube_deb_rev}} -> kubectl={{ kubernetes_version }}-{{ kube_deb_rev }}

Check warning on line 121 in roles/kubernetes/toolbox/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / ansible-lint

jinja[spacing]

Jinja2 spacing could be improved: kubelet={{ kubernetes_version }}-{{kube_deb_rev}} -> kubelet={{ kubernetes_version }}-{{ kube_deb_rev }}
- kubelet={{ kubernetes_version }}-00
- kubeadm={{ kubernetes_version }}-00
- kubectl={{ kubernetes_version }}-00
- kubelet={{ kubernetes_version }}-{{kube_deb_rev}}
- kubeadm={{ kubernetes_version }}-{{kube_deb_rev}}
- kubectl={{ kubernetes_version }}-{{kube_deb_rev}}
state: present
update_cache: true
when: ansible_distribution == "Ubuntu" and (ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04")
Expand Down Expand Up @@ -145,9 +156,9 @@
- name: Update apt package index and remove kubelet, kubeadm, kubectl
ansible.builtin.apt:
pkg:

Check warning on line 158 in roles/kubernetes/toolbox/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / ansible-lint

jinja[spacing]

Jinja2 spacing could be improved: kubeadm={{ kubernetes_version }}-{{kube_deb_rev}} -> kubeadm={{ kubernetes_version }}-{{ kube_deb_rev }}

Check warning on line 158 in roles/kubernetes/toolbox/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / ansible-lint

jinja[spacing]

Jinja2 spacing could be improved: kubectl={{ kubernetes_version }}-{{kube_deb_rev}} -> kubectl={{ kubernetes_version }}-{{ kube_deb_rev }}

Check warning on line 158 in roles/kubernetes/toolbox/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / ansible-lint

jinja[spacing]

Jinja2 spacing could be improved: kubelet={{ kubernetes_version }}-{{kube_deb_rev}} -> kubelet={{ kubernetes_version }}-{{ kube_deb_rev }}
- kubelet={{ kubernetes_version }}-00
- kubeadm={{ kubernetes_version }}-00
- kubectl={{ kubernetes_version }}-00
- kubelet={{ kubernetes_version }}-{{kube_deb_rev}}
- kubeadm={{ kubernetes_version }}-{{kube_deb_rev}}
- kubectl={{ kubernetes_version }}-{{kube_deb_rev}}
state: absent
update_cache: true
when: ansible_distribution == "Ubuntu" and (ansible_distribution_version == "20.04" or ansible_distribution_version == "22.04")
Expand Down

0 comments on commit 48625dc

Please sign in to comment.