Skip to content

Commit

Permalink
23.1.0+1.27.5 (#44)
Browse files Browse the repository at this point in the history
* molecule/default/group_vars/all.yml: moved container-runtime-endpoint setting from k8s_worker_kubelet_settings (/etc/systemd/system/kubelet.service) to k8s_worker_kubelet_conf_yaml (kubelet-config.yaml)

* molecule/default/verify.yml: add validate_certs property

* add support for Ubuntu 22.04

* molecule/default/prepare.yml: fix typo in role name

* use Ubuntu 20.04 instead of 22.04 for test-assets for now because of certificate problems with Python urllib module

* update README

* update CHANGELOG
  • Loading branch information
githubixx committed Sep 6, 2023
1 parent c7c8649 commit 082e252
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 23.1.0+1.27.5

- add support for Ubuntu 22.04
- `molecule/default/group_vars/all.yml`: Removed `container-runtime-endpoint` setting from `k8s_worker_kubelet_settings` (/etc/systemd/system/kubelet.service). It was moved to `k8s_worker_kubelet_conf_yaml` (kubelet-config.yaml)

## 23.0.0+1.27.5

- **BREAKING**: `meta/main.yml`: change role_name from `kubernetes-worker` to `kubernetes_worker`. This is a requirement since quite some time for Ansible Galaxy. But the requirement was introduced after this role already existed for quite some time. So please update the name of the role in your playbook accordingly!
Expand Down
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ This playbook expects that you already have rolled out the Kubernetes controller

You also need [containerd](https://galaxy.ansible.com/githubixx/containerd) installed. To enable Kubernetes `Pods` to communicate between different hosts it makes sense to install [Cilium](https://galaxy.ansible.com/githubixx/cilium_kubernetes) later once the worker nodes are running e.g. Of course `Calico`, `WeaveNet`, `kube-router` or [flannel](https://galaxy.ansible.com/githubixx/flanneld) or other Kubernetes network solutions are valid options.

Supported OS
------------

- Ubuntu 20.04 (Focal Fossa)
- Ubuntu 22.04 (Jammy Jellyfish)

Changelog
---------

Expand Down Expand Up @@ -82,7 +88,6 @@ k8s_worker_kubelet_conf_dir: "/var/lib/kubelet"
k8s_worker_kubelet_settings:
"config": "{{ k8s_worker_kubelet_conf_dir }}/kubelet-config.yaml"
"node-ip": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}"
"container-runtime-endpoint": "unix:///run/containerd/containerd.sock"
"kubeconfig": "{{ k8s_worker_kubelet_conf_dir }}/kubeconfig"

# kubelet kubeconfig
Expand Down Expand Up @@ -111,6 +116,7 @@ k8s_worker_kubelet_conf_yaml: |
tlsPrivateKeyFile: "{{ k8s_conf_dir }}/cert-{{ inventory_hostname }}-key.pem"
cgroupDriver: "systemd"
registerNode: true
containerRuntimeEndpoint: "unix:///run/containerd/containerd.sock"
# Directory to store kube-proxy configuration
k8s_worker_kubeproxy_conf_dir: "/var/lib/kube-proxy"
Expand Down Expand Up @@ -151,6 +157,35 @@ Example Playbook
- githubixx.kubernetes_worker
```

Testing
-------

This role has a small test setup that is created using [Molecule](https://github.com/ansible-community/molecule), libvirt (vagrant-libvirt) and QEMU/KVM. Please see my blog post [Testing Ansible roles with Molecule, libvirt (vagrant-libvirt) and QEMU/KVM](https://www.tauceti.blog/posts/testing-ansible-roles-with-molecule-libvirt-vagrant-qemu-kvm/) how to setup. The test configuration is [here](https://github.com/githubixx/ansible-role-kubernetes-worker/tree/master/molecule/default).

Afterwards Molecule can be executed. This will setup a few virtual machines (VM) with supported Ubuntu OS and installs an Kubernetes cluster:

```bash
molecule converge
```

At this time the cluster isn't fully functional as a network plugin is missing e.g. So Pod to Pod communication between two different nodes isn't possible yet. To fix this the following command can be used to install [Cilium](https://github.com/githubixx/ansible-role-cilium-kubernetes) for all Kubernetes networking needs and [CoreDNS](https://github.com/githubixx/ansible-kubernetes-playbooks/tree/master/coredns) for Kubernetes DNS stuff:

```bash
molecule converge -- --extra-vars k8s_worker_setup_networking=install
```

A small verification step is also included:

```bash
molecule verify
```

To clean up run

```bash
molecule destroy
```

License
-------

Expand Down
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ galaxy_info:
- name: Ubuntu
versions:
- "focal"
- "jammy"
galaxy_tags:
- kubernetes
- worker
1 change: 0 additions & 1 deletion molecule/default/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ k8s_apiserver_settings_user:
k8s_worker_kubelet_settings:
"config": "{{k8s_worker_kubelet_conf_dir}}/kubelet-config.yaml"
"node-ip": "{{hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address}}"
"container-runtime-endpoint": "unix:///run/containerd/containerd.sock"
"kubeconfig": "{{k8s_worker_kubelet_conf_dir}}/kubeconfig"
"seccomp-default": ""

Expand Down
8 changes: 4 additions & 4 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ driver:
platforms:
- name: test-assets
box: generic/ubuntu2004
memory: 1024
memory: 2048
cpus: 2
groups:
- vpn
Expand All @@ -28,7 +28,7 @@ platforms:
type: static
ip: 192.168.10.5
- name: test-controller1
box: generic/ubuntu2004
box: generic/ubuntu2204
memory: 2048
cpus: 2
groups:
Expand All @@ -43,7 +43,7 @@ platforms:
type: static
ip: 192.168.10.10
- name: test-controller2
box: generic/ubuntu2004
box: generic/ubuntu2204
memory: 2048
cpus: 2
groups:
Expand Down Expand Up @@ -73,7 +73,7 @@ platforms:
type: static
ip: 192.168.10.30
- name: test-worker1
box: generic/ubuntu2004
box: generic/ubuntu2204
memory: 2048
cpus: 2
groups:
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
tasks:
- name: Include kubernetes_controller role
ansible.builtin.include_role:
name: githubixx.kuberneter_controller
name: githubixx.kubernetes_controller

- name: Setup containerd
hosts: k8s_worker
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
vars:
query: "length(resources)"

- name: There should be four namespaces
- name: There should be four namespaces at least
ansible.builtin.assert:
that:
- k8s__namespaces_count|int >= 4

0 comments on commit 082e252

Please sign in to comment.