summaryrefslogtreecommitdiff
path: root/roles/kubernetes/addons
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-08-28 19:09:40 +0200
committerChristian Pointner <equinox@spreadspace.org>2022-08-28 19:09:40 +0200
commit0ceeb0fee8ad71ca58fbf4a52f3526f07b1f9bbe (patch)
treeec02f8ac2c158a49c1fb174ad4b5d974bab752e8 /roles/kubernetes/addons
parentkubernetes: add cluster add-on: cert-manager (diff)
kubernetes/addons: run role on all cluster nodes
Diffstat (limited to 'roles/kubernetes/addons')
-rw-r--r--roles/kubernetes/addons/cert-manager/tasks/main.yml38
-rw-r--r--roles/kubernetes/addons/metrics-server/defaults/main.yml2
-rw-r--r--roles/kubernetes/addons/metrics-server/tasks/main.yml38
-rw-r--r--roles/kubernetes/addons/openebs-zfs/tasks/main.yml72
4 files changed, 82 insertions, 68 deletions
diff --git a/roles/kubernetes/addons/cert-manager/tasks/main.yml b/roles/kubernetes/addons/cert-manager/tasks/main.yml
index f739a5b7..e34085e1 100644
--- a/roles/kubernetes/addons/cert-manager/tasks/main.yml
+++ b/roles/kubernetes/addons/cert-manager/tasks/main.yml
@@ -1,21 +1,25 @@
---
-- name: create base directory for cert-manager addon
- file:
- path: /etc/kubernetes/addons/cert-manager
- state: directory
+- name: deploy metrics-server addon
+ run_once: true
+ delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
+ block:
+ - name: create base directory for cert-manager addon
+ file:
+ path: /etc/kubernetes/addons/cert-manager
+ state: directory
-- name: copy config for cert-manager
- template:
- src: "config.{{ kubernetes_cert_manager_version }}.yml.j2"
- dest: /etc/kubernetes/addons/cert-manager/config.yml
+ - name: copy config for cert-manager
+ template:
+ src: "config.{{ kubernetes_cert_manager_version }}.yml.j2"
+ dest: /etc/kubernetes/addons/cert-manager/config.yml
-- name: check if cert-manager is already installed
- check_mode: no
- command: kubectl --kubeconfig /etc/kubernetes/admin.conf diff -f /etc/kubernetes/addons/cert-manager/config.yml
- failed_when: false
- changed_when: false
- register: kube_cert_manager_diff_result
+ - name: check if cert-manager is already installed
+ check_mode: no
+ command: kubectl --kubeconfig /etc/kubernetes/admin.conf diff -f /etc/kubernetes/addons/cert-manager/config.yml
+ failed_when: false
+ changed_when: false
+ register: kube_cert_manager_diff_result
-- name: install cert-manager onto the cluster
- when: kube_cert_manager_diff_result.rc != 0
- command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f /etc/kubernetes/addons/cert-manager/config.yml
+ - name: install cert-manager onto the cluster
+ when: kube_cert_manager_diff_result.rc != 0
+ command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f /etc/kubernetes/addons/cert-manager/config.yml
diff --git a/roles/kubernetes/addons/metrics-server/defaults/main.yml b/roles/kubernetes/addons/metrics-server/defaults/main.yml
new file mode 100644
index 00000000..2e7e78e2
--- /dev/null
+++ b/roles/kubernetes/addons/metrics-server/defaults/main.yml
@@ -0,0 +1,2 @@
+---
+# kubernetes_metrics_server_version: 0.6.1
diff --git a/roles/kubernetes/addons/metrics-server/tasks/main.yml b/roles/kubernetes/addons/metrics-server/tasks/main.yml
index 87c57346..79bf1cf1 100644
--- a/roles/kubernetes/addons/metrics-server/tasks/main.yml
+++ b/roles/kubernetes/addons/metrics-server/tasks/main.yml
@@ -1,21 +1,25 @@
---
-- name: create base directory for metrics-server addon
- file:
- path: /etc/kubernetes/addons/metrics-server
- state: directory
+- name: deploy metrics-server addon
+ run_once: true
+ delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
+ block:
+ - name: create base directory for metrics-server addon
+ file:
+ path: /etc/kubernetes/addons/metrics-server
+ state: directory
-- name: copy config for metrics-server
- template:
- src: "components.{{ kubernetes_metrics_server_version }}.yml.j2"
- dest: /etc/kubernetes/addons/metrics-server/config.yml
+ - name: copy config for metrics-server
+ template:
+ src: "components.{{ kubernetes_metrics_server_version }}.yml.j2"
+ dest: /etc/kubernetes/addons/metrics-server/config.yml
-- name: check if metrics-server is already installed
- check_mode: no
- command: kubectl --kubeconfig /etc/kubernetes/admin.conf diff -f /etc/kubernetes/addons/metrics-server/config.yml
- failed_when: false
- changed_when: false
- register: kube_metrics_server_diff_result
+ - name: check if metrics-server is already installed
+ check_mode: no
+ command: kubectl --kubeconfig /etc/kubernetes/admin.conf diff -f /etc/kubernetes/addons/metrics-server/config.yml
+ failed_when: false
+ changed_when: false
+ register: kube_metrics_server_diff_result
-- name: install metrics-server onto the cluster
- when: kube_metrics_server_diff_result.rc != 0
- command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f /etc/kubernetes/addons/metrics-server/config.yml
+ - name: install metrics-server onto the cluster
+ when: kube_metrics_server_diff_result.rc != 0
+ command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f /etc/kubernetes/addons/metrics-server/config.yml
diff --git a/roles/kubernetes/addons/openebs-zfs/tasks/main.yml b/roles/kubernetes/addons/openebs-zfs/tasks/main.yml
index 577eef6d..d1c47ef5 100644
--- a/roles/kubernetes/addons/openebs-zfs/tasks/main.yml
+++ b/roles/kubernetes/addons/openebs-zfs/tasks/main.yml
@@ -1,42 +1,46 @@
---
-- name: create base directory for openebs-zfs addon
- file:
- path: /etc/kubernetes/addons/openebs-zfs
- state: directory
+- name: deploy metrics-server addon
+ run_once: true
+ delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
+ block:
+ - name: create base directory for openebs-zfs addon
+ file:
+ path: /etc/kubernetes/addons/openebs-zfs
+ state: directory
-- name: copy config for openebs-zfs
- template:
- src: "zfs-operator.{{ kubernetes_openebs_zfs_version }}.yml.j2"
- dest: /etc/kubernetes/addons/openebs-zfs/config.yml
+ - name: copy config for openebs-zfs
+ template:
+ src: "zfs-operator.{{ kubernetes_openebs_zfs_version }}.yml.j2"
+ dest: /etc/kubernetes/addons/openebs-zfs/config.yml
-- name: check if openebs-zfs is already installed
- check_mode: no
- command: kubectl --kubeconfig /etc/kubernetes/admin.conf diff -f /etc/kubernetes/addons/openebs-zfs/config.yml
- failed_when: false
- changed_when: false
- register: kube_openebs_zfs_config_diff_result
+ - name: check if openebs-zfs is already installed
+ check_mode: no
+ command: kubectl --kubeconfig /etc/kubernetes/admin.conf diff -f /etc/kubernetes/addons/openebs-zfs/config.yml
+ failed_when: false
+ changed_when: false
+ register: kube_openebs_zfs_config_diff_result
-- name: install openebs-zfs onto the cluster
- when: kube_openebs_zfs_config_diff_result.rc != 0
- command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f /etc/kubernetes/addons/openebs-zfs/config.yml
+ - name: install openebs-zfs onto the cluster
+ when: kube_openebs_zfs_config_diff_result.rc != 0
+ command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f /etc/kubernetes/addons/openebs-zfs/config.yml
-- name: copy storageclasses config for openebs-zfs
- loop: "{{ kubernetes_openebs_zfs_storage_classes | dict2items }}"
- loop_control:
- label: "{{ item.key }}"
- template:
- src: "storageclass.yml.j2"
- dest: "/etc/kubernetes/addons/openebs-zfs/sc-{{ item.key }}.yml"
+ - name: copy storageclasses config for openebs-zfs
+ loop: "{{ kubernetes_openebs_zfs_storage_classes | dict2items }}"
+ loop_control:
+ label: "{{ item.key }}"
+ template:
+ src: "storageclass.yml.j2"
+ dest: "/etc/kubernetes/addons/openebs-zfs/sc-{{ item.key }}.yml"
-- name: check if openebs-zfs storageclass already exists
- loop: "{{ kubernetes_openebs_zfs_storage_classes | list }}"
- check_mode: no
- command: "kubectl --kubeconfig /etc/kubernetes/admin.conf diff -f /etc/kubernetes/addons/openebs-zfs/sc-{{ item }}.yml"
- failed_when: false
- changed_when: false
- register: kube_openebs_zfs_sc_diff
+ - name: check if openebs-zfs storageclass already exists
+ loop: "{{ kubernetes_openebs_zfs_storage_classes | list }}"
+ check_mode: no
+ command: "kubectl --kubeconfig /etc/kubernetes/admin.conf diff -f /etc/kubernetes/addons/openebs-zfs/sc-{{ item }}.yml"
+ failed_when: false
+ changed_when: false
+ register: kube_openebs_zfs_sc_diff
-- name: install/update storageclasses for openebs-zfs
- loop: "{{ kube_openebs_zfs_sc_diff.results | selectattr('rc', 'ne', 0) | map(attribute='item') }}"
- command: "kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f /etc/kubernetes/addons/openebs-zfs/sc-{{ item }}.yml"
+ - name: install/update storageclasses for openebs-zfs
+ loop: "{{ kube_openebs_zfs_sc_diff.results | selectattr('rc', 'ne', 0) | map(attribute='item') }}"
+ command: "kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f /etc/kubernetes/addons/openebs-zfs/sc-{{ item }}.yml"