feat: add option to create kubernetes setup resources
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Robert Kaussow 2022-11-16 22:17:08 +01:00
parent 1c20e20dec
commit c0e0f17f51
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
3 changed files with 38 additions and 2 deletions

View File

@ -47,4 +47,5 @@ k3s_server_admission_configuration:
qps: 10
burst: 50
k3s_server_resource_creations: []
k3s_server_resource_patches: []

View File

@ -7,13 +7,26 @@
- 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_network_policy_enabled: False
k3s_server_cloud_controller_enabled: True
k3s_server_manifests_templates:
- "calico-installation.yaml.j2"
k3s_server_manifests_urls:
- url: https://docs.projectcalico.org/archive/v3.24/manifests/tigera-operator.yaml
dest: tigera-operator.yaml
# - url: https://github.com/hetznercloud/hcloud-cloud-controller-manager/releases/latest/download/ccm.yaml
# dest: hcloud-ccm.yaml
k3s_init_log_enabled: True
k3s_selinux_enabled: True
# k3s_server_resource_creations:
# - kind: Secret
# name: hcloud
# definition:
# metadata:
# namespace: kube-system
# apiVersion: v1
# type: Opaque
# data:
# token: "{{ hcloud_token | b64encode }}"
pre_tasks:
- name: Override host variables
ansible.builtin.set_fact:

View File

@ -19,6 +19,16 @@
enabled: True
state: started
- name: Wait for Kubernetes API
command: >-
{{ __k3s_binary }} kubectl get --raw='/readyz'
register: __k3s_api_readyz
until: __k3s_api_readyz.rc == 0 and __k3s_api_readyz.stdout == "ok"
retries: 30
delay: 10
changed_when: False
when: k3s_server | bool
- name: Set server address
command: >-
{{ __k3s_binary }} kubectl config set-cluster default
@ -26,6 +36,18 @@
--kubeconfig {{ __k3s_config_dir }}/k3s.yaml
changed_when: False
- name: Create setup resources
k8s:
kind: "{{ item.kind }}"
name: "{{ item.name }}"
kubeconfig: "{{ __k3s_config_dir }}/k3s.yaml"
state: present
definition: "{{ item.definition }}"
loop: "{{ k3s_server_resource_creations }}"
loop_control:
label: "{{ item.kind | lower }}/{{ item.name | lower }}"
when: k3s_server | bool
- name: Wait for initial setup
command: >-
{{ __k3s_binary }} kubectl get deployment coredns
@ -34,7 +56,7 @@
register: __k3s_init_setup
until: __k3s_init_setup.rc == 0 and __k3s_init_setup.stdout == "1"
retries: 30
delay: 8
delay: 10
changed_when: False
when: k3s_server | bool
@ -58,7 +80,7 @@
definition: "{{ item.definition }}"
loop: "{{ k3s_server_resource_patches }}"
loop_control:
label: "{{ item.kind }}/{{ item.name }}"
label: "{{ item.kind | lower }}/{{ item.name | lower }}"
when: k3s_server | bool
- name: Remove auto-deploying manifests