Skip to content

Commit

Permalink
fix: additional fixes testing uncovered
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Marcy <homelab@glenn4u.com>
  • Loading branch information
gmarcy committed Jul 29, 2024
1 parent a640fd0 commit cf65a31
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 137 deletions.
Empty file modified docs/src/roles/role-kubeinit_dnsmasq.rst
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion kubeinit/roles/kubeinit_k8s/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ kubeinit_k8s_debug: "{{ (ansible_verbosity | int) >= 2 | bool }}"
kubeinit_k8s_hide_sensitive_logs: true

kubeinit_k8s_kubernetes_version: "1.30"
kubeinit_k8s_kubernetes_version_full: "1.30.2"

# This is the default container runtime that
# will be deployed when the Vanila k8s cluster
Expand Down
194 changes: 159 additions & 35 deletions kubeinit/roles/kubeinit_k8s/tasks/prepare_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,166 @@
kubeinit_deployment_delegate: "{{ hostvars[kubeinit_provision_service_node].target }}"
kubeinit_deployment_os: "{{ hostvars[kubeinit_provision_service_node].os }}"

- name: Configure the service node
- name: Configure the provision service node
block:

- name: Remove repo before adding it
ansible.builtin.file:
path: /etc/yum.repos.d/kubernetes.repo
state: absent

- name: Creating a repository file for Kubernetes
ansible.builtin.file:
path: /etc/yum.repos.d/kubernetes.repo
state: touch
mode: '0644'

- name: Adding repository details in Kubernetes repo file.
ansible.builtin.blockinfile:
path: /etc/yum.repos.d/kubernetes.repo
block: |
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v{{ kubeinit_k8s_kubernetes_version }}/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v{{ kubeinit_k8s_kubernetes_version }}/rpm/repodata/repomd.xml.key
# exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
- name: Install requirements
ansible.builtin.command: dnf install -y kubectl-{{ kubeinit_k8s_kubernetes_version }}.* --disableexcludes=kubernetes
register: _result
changed_when: "_result.rc == 0"

- name: Install common requirements
ansible.builtin.package:
name: "{{ kubeinit_k8s_common_dependencies }}"
state: present
use: dnf
when: kubeinit_k8s_common_dependencies is defined
- when: hostvars[kubeinit_provision_service_node].os == 'centos'
block:

- name: Remove repo before adding it
ansible.builtin.file:
path: /etc/yum.repos.d/kubernetes.repo
state: absent

- name: Creating a repository file for Kubernetes
ansible.builtin.file:
path: /etc/yum.repos.d/kubernetes.repo
state: touch
mode: '0644'

- name: Adding repository details in Kubernetes repo file.
ansible.builtin.blockinfile:
block: |
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v{{ kubeinit_k8s_kubernetes_version }}/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v{{ kubeinit_k8s_kubernetes_version }}/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
path: /etc/yum.repos.d/kubernetes.repo

- name: Install requirements
ansible.builtin.command: dnf install -y kubectl-{{ kubeinit_k8s_kubernetes_version }}.* --disableexcludes=kubernetes
register: _result
changed_when: "_result.rc == 0"

#### Debian-based distributions
###
#### These instructions are for Kubernetes v1.30.
###
#### Update the apt package index and install packages needed to use the Kubernetes apt repository:
###
### sudo apt-get update
### # apt-transport-https may be a dummy package; if so, you can skip that package
### sudo apt-get install -y apt-transport-https ca-certificates curl gpg
###
#### Download the public signing key for the Kubernetes package repositories. The same signing key is used for all repositories so you can disregard the version in the URL:
###
### # If the directory `/etc/apt/keyrings` does not exist, it should be created before the curl command, read the note below.
### # sudo mkdir -p -m 755 /etc/apt/keyrings
### curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
###
#### Note:
#### In releases older than Debian 12 and Ubuntu 22.04, directory /etc/apt/keyrings does not exist by default, and it should be created before the curl command.
###
#### Add the appropriate Kubernetes apt repository. Please note that this repository have packages only for Kubernetes 1.30; for other Kubernetes minor versions, you need to change the Kubernetes minor version in the URL to match your desired minor version (you should also check that you are reading the documentation for the version of Kubernetes that you plan to install).
###
### # This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list
### echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
###
#### Update the apt package index, install kubelet, kubeadm and kubectl, and pin their version:
###
### sudo apt-get update
### sudo apt-get install -y kubelet kubeadm kubectl
### sudo apt-mark hold kubelet kubeadm kubectl
###
#### (Optional) Enable the kubelet service before running kubeadm:
###
### sudo systemctl enable --now kubelet
###
####
#### END
####
#### Distributions using deb packages
###
#### Install the dependencies for adding repositories
### apt-get update
### apt-get install -y software-properties-common curl
###
#### Add the Kubernetes repository
### curl -fsSL https://pkgs.k8s.io/core:/stable:/$KUBERNETES_VERSION/deb/Release.key |
### gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
###
### echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/$KUBERNETES_VERSION/deb/ /" |
### tee /etc/apt/sources.list.d/kubernetes.list
###
#### Add the CRI-O repository
### curl -fsSL https://pkgs.k8s.io/addons:/cri-o:/stable:/$CRIO_VERSION/deb/Release.key |
### gpg --dearmor -o /etc/apt/keyrings/cri-o-apt-keyring.gpg
###
### echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://pkgs.k8s.io/addons:/cri-o:/stable:/$CRIO_VERSION/deb/ /" |
### tee /etc/apt/sources.list.d/cri-o.list
###
#### Install the packages
### apt-get update
### apt-get install -y cri-o kubelet kubeadm kubectl
###
#### Start CRI-O
### systemctl start crio.service
###
#### Bootstrap a cluster
### swapoff -a
### modprobe br_netfilter
### sysctl -w net.ipv4.ip_forward=1
###
### kubeadm init
####
#### END
####
- when: hostvars[kubeinit_provision_service_node].os != 'centos'
block:

- fail: msg=stopping

- name: Add kubernetes repo for latest kubectl (Debian)
ansible.builtin.shell: |
set -eo pipefail
apt-get update
apt-get install -y software-properties-common curl
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key |
gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /" |
tee /etc/apt/sources.list.d/kubernetes.list
curl -fsSL https://pkgs.k8s.io/addons:/cri-o:/prerelease:/main/deb/Release.key |
gpg --dearmor -o /etc/apt/keyrings/cri-o-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://pkgs.k8s.io/addons:/cri-o:/prerelease:/main/deb/ /" |
tee /etc/apt/sources.list.d/cri-o.list
apt-get update
apt-get install -y cri-o kubelet kubeadm kubectl
systemctl start crio.service
args:
executable: /bin/bash
register: _result
changed_when: "_result.rc == 0"

###
# The Project's prerelease:/main prefix at the CRI-O's package path, can be replaced with stable:/v1.28, stable:/v1.29, prerelease:/v1.28 or prerelease:/v1.29 if another stream package is used.
###

- name: Add kubernetes repo for latest kubectl (Ubuntu)
ansible.builtin.shell: |
set -eo pipefail
apt-get install -y apt-transport-https ca-certificates curl gnupg
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg # allow unprivileged APT programs to read this keyring
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list
chmod 644 /etc/apt/sources.list.d/kubernetes.list # helps tools such as command-not-found to work correctly
apt-get update --allow-insecure-repositories
args:
executable: /bin/bash
register: _result
changed_when: "_result.rc == 0"

- name: Install services requirements
ansible.builtin.package:
name:
- kubectl
state: present
use: apt

delegate_to: "{{ kubeinit_provision_service_node }}"
32 changes: 7 additions & 25 deletions kubeinit/roles/kubeinit_libvirt/tasks/deploy_centos_guest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,7 @@
- name: Install official package dependencies
ansible.builtin.package:
name:
- conntrack
- container-selinux
- ebtables
- ethtool
- iptables
- socat
state: present
use: dnf

Expand All @@ -214,18 +209,18 @@
block: |
[cri-o]
name=CRI-O
baseurl=https://pkgs.k8s.io/addons:/cri-o:/prerelease:/main/rpm/
baseurl=https://pkgs.k8s.io/addons:/cri-o:/stable:/v{{ kubeinit_k8s_kubernetes_version }}/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/addons:/cri-o:/prerelease:/main/rpm/repodata/repomd.xml.key
gpgkey=https://pkgs.k8s.io/addons:/cri-o:/stable:/v{{ kubeinit_k8s_kubernetes_version }}/rpm/repodata/repomd.xml.key
#
# cri-o config
#

- name: Install the latest version of cri-o
- name: Install the matching version of cri-o
ansible.builtin.package:
name: cri-o
name: "{{ 'cri-o-' + kubeinit_k8s_kubernetes_version + '.*' }}"
state: present
use: dnf

Expand Down Expand Up @@ -310,7 +305,7 @@
when: kubeinit_k8s_container_runtime == "containerd"

#
# kubernetes repos
# kubernetes repo
#

- name: Remove repo before adding it
Expand All @@ -326,7 +321,6 @@

- name: Adding repository details in Kubernetes repo file.
ansible.builtin.blockinfile:
path: /etc/yum.repos.d/kubernetes.repo
block: |
[kubernetes]
name=Kubernetes
Expand All @@ -335,23 +329,11 @@
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v{{ kubeinit_k8s_kubernetes_version }}/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
#
# Kubernetes config
#

- name: Install requirements
ansible.builtin.package:
name:
- device-mapper-persistent-data
- lvm2
state: present
use: dnf
when: false
path: /etc/yum.repos.d/kubernetes.repo

- name: Install requirements
ansible.builtin.command: |
dnf install -y kubelet-{{ kubeinit_k8s_kubernetes_version_full }} kubeadm-{{ kubeinit_k8s_kubernetes_version_full }} kubectl-{{ kubeinit_k8s_kubernetes_version_full }} --disableexcludes=kubernetes
dnf install -y kubelet-{{ kubeinit_k8s_kubernetes_version }}.* kubeadm-{{ kubeinit_k8s_kubernetes_version }}.* kubectl-{{ kubeinit_k8s_kubernetes_version }}.* --disableexcludes=kubernetes
register: _result
changed_when: "_result.rc == 0"

Expand Down
75 changes: 0 additions & 75 deletions kubeinit/roles/kubeinit_prepare/tasks/prepare_podman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,81 +17,6 @@
- name: Install podman dependencies if requested
block:

- name: Setup kubeinit repo for Debian distribution
block:

- name: Create folder if missing
ansible.builtin.file:
path: '/etc/containers'
state: directory
mode: '0755'
become: true
become_user: root

- name: Set cgroup_manager for debian release
ansible.builtin.copy:
content: |
[engine]
cgroup_manager = "cgroupfs"
dest: '/etc/containers/containers.conf'
mode: '0644'
become: true
become_user: root

- name: Set version facts
ansible.builtin.set_fact:
_version: "{{ _param_hostvars.ansible_distribution_version.split('.')[0] }}"

- name: Set version facts
ansible.builtin.set_fact:
_stability: "{{ 'stable' if ((_version | int) is version('12', 'le')) else 'testing' }}"

- name: Set version facts
ansible.builtin.set_fact:
_path_element: "{{ _param_hostvars.ansible_distribution + '_' + (_version if (_stability == 'stable') else 'testing') }}"

when: _param_hostvars.ansible_distribution == 'Debian'

- name: Setup kubeinit repo for Ubuntu distribution
block:

- name: Set version facts
ansible.builtin.set_fact:
_version: "{{ _param_hostvars.ansible_distribution_version }}"
_stability: "{{ 'stable' if (_param_hostvars.ansible_distribution_version is version('22.04', 'le')) else 'testing' }}"

- name: Set version facts
ansible.builtin.set_fact:
_path_element: "{{ '/x' + _param_hostvars.ansible_distribution + '_' + _version }}"

when: _param_hostvars.ansible_distribution == 'Ubuntu'

- name: Setup kubeinit repo for Debian family
block:

- name: Make sure we have curl installed
ansible.builtin.package:
name: curl
state: present
use: apt
become: true
become_user: root

- name: Add the Podman kubeinit package repository to Apt
ansible.builtin.shell: |
set -eo pipefail
echo "deb https://download.opensuse.org/repositories/home:/kubeinit/{{ _path_element }}/ /" | tee /etc/apt/sources.list.d/kubeinit.list
curl -L "https://download.opensuse.org/repositories/home:/kubeinit/{{ _path_element }}/Release.key" | tee /etc/apt/trusted.gpg.d/kubeinit.asc
apt-get update
args:
executable: /bin/bash
become: true
become_user: root
register: _result
changed_when: "_result.rc == 0"

when: _param_hostvars.distribution_family == 'Debian'

- name: Install podman dependencies
ansible.builtin.package:
name: "{{ kubeinit_prepare_podman_dependencies }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,13 @@
state: started
register: _result_pod_info

- name: Set _pod_info_first_pod fact
ansible.builtin.set_fact:
_pod_info_first_pod: "{{ _result_pod_info.pod[0] | default(_result_pod_info.pod) }}"

- name: Gather info about the infra container of the services pod
containers.podman.podman_container_info:
name: "{{ _result_pod_info.pod.Containers[0].Name }}"
name: "{{ _pod_info_first_pod.Containers[0].Name }}"
register: _result_infra_container_info

delegate_to: "{{ kubeinit_deployment_delegate }}"
Expand Down

0 comments on commit cf65a31

Please sign in to comment.