feat: add option to patch kubernetes resources (#1)
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Robert Kaussow 2022-10-25 09:58:53 +02:00
parent 2a5e12dcad
commit 33e58dcb83
4 changed files with 19 additions and 4 deletions

View File

@ -1,10 +1,13 @@
--- ---
k3s_version: v1.25.0+k3s1 k3s_version: v1.25.0+k3s1
k3s_packages_extra: k3s_packages:
- python3-kubernetes
- container-selinux - container-selinux
- selinux-policy-base - selinux-policy-base
k3s_packages_extra: []
k3s_reset: False k3s_reset: False
k3s_token: "secure-token" k3s_token: "secure-token"
k3s_node_ip: "{{ ansible_default_ipv4.address }}" k3s_node_ip: "{{ ansible_default_ipv4.address }}"
@ -40,3 +43,5 @@ k3s_server_admission_configuration:
- type: User - type: User
qps: 10 qps: 10
burst: 50 burst: 50
k3s_server_resource_patches: []

View File

@ -4,8 +4,6 @@
vars: vars:
k3s_reset: False k3s_reset: False
k3s_packages_extra: k3s_packages_extra:
- container-selinux
- selinux-policy-base
- https://github.com/k3s-io/k3s-selinux/releases/download/v1.2.stable.2/k3s-selinux-1.2-2.el8.noarch.rpm - https://github.com/k3s-io/k3s-selinux/releases/download/v1.2.stable.2/k3s-selinux-1.2-2.el8.noarch.rpm
k3s_server_flannel_backend_enabled: False k3s_server_flannel_backend_enabled: False
k3s_server_network_policy_enabled: False k3s_server_network_policy_enabled: False

View File

@ -9,7 +9,7 @@
package: package:
name: "{{ item }}" name: "{{ item }}"
state: present state: present
loop: "{{ k3s_packages_extra }}" loop: "{{ k3s_packages + k3s_packages_extra }}"
- name: Check if cluster is installed - name: Check if cluster is installed
stat: stat:

View File

@ -38,6 +38,18 @@
changed_when: False changed_when: False
when: k3s_server | bool when: k3s_server | bool
- name: Patch existing resources
k8s:
kind: "{{ item.kind }}"
name: "{{ item.name }}"
kubeconfig: "{{ __k3s_config_dir }}/k3s.yaml"
state: patched
definition: "{{ item.definition }}"
loop: "{{ k3s_server_resource_patches }}"
loop_control:
label: "{{ item.kind }}/{{ item.name }}"
when: k3s_server | bool
- name: Remove auto-deploying manifests - name: Remove auto-deploying manifests
file: file:
path: "{{ __k3s_manifests_dir }}/{{ item.dest | default(item.url) | default(item) | basename | replace('.j2', '') }}" path: "{{ __k3s_manifests_dir }}/{{ item.dest | default(item.url) | default(item) | basename | replace('.j2', '') }}"