Skip to content

Commit

Permalink
Add helm support for custom_cni deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
kukacz committed Nov 14, 2023
1 parent eb015c0 commit f392b36
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 23 deletions.
8 changes: 8 additions & 0 deletions roles/network_plugin/custom_cni/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---

custom_cni_manifests: []

custom_cni_chart_namespace: kube-system
custom_cni_chart_release_name: ""
custom_cni_chart_repository_name: ""
custom_cni_chart_repository_url: ""
custom_cni_chart_ref: "{{ custom_cni_chart_repository_name }}/"
custom_cni_chart_version: ""
custom_cni_chart_values: ""
19 changes: 19 additions & 0 deletions roles/network_plugin/custom_cni/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
dependencies:
- role: helm-apps
when:
- inventory_hostname == groups['kube_control_plane'][0]
- custom_cni_chart_release_name | length > 0
environment:
http_proxy: "{{ http_proxy | default('') }}"
https_proxy: "{{ https_proxy | default('') }}"
release_common_opts: {}
releases:
- name: "{{ custom_cni_chart_release_name }}"
namespace: "{{ custom_cni_chart_namespace }}"
chart_ref: "{{ custom_cni_chart_ref }}"
chart_version: "{{ custom_cni_chart_version }}"
wait: true
values: "{{ custom_cni_chart_values }}"
repositories:
- name: "{{ custom_cni_chart_repository_name }}"
url: "{{ custom_cni_chart_repository_url }}"
49 changes: 26 additions & 23 deletions roles/network_plugin/custom_cni/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
---
- name: Custom CNI | Check Custom CNI Manifests
assert:
that:
- "custom_cni_manifests | length > 0"
msg: "custom_cni_manifests should not be empty"
- name: Custom CNI | Manifest deployment
block:
- name: Custom CNI | Check Custom CNI Manifests
assert:
that:
- "custom_cni_manifests | length > 0"
msg: "custom_cni_manifests should not be empty"

- name: Custom CNI | Copy Custom manifests
template:
src: "{{ item }}"
dest: "{{ kube_config_dir }}/{{ item | basename | replace('.j2', '') }}"
mode: 0644
loop: "{{ custom_cni_manifests }}"
delegate_to: "{{ groups['kube_control_plane'] | first }}"
run_once: true
- name: Custom CNI | Copy Custom manifests
template:
src: "{{ item }}"
dest: "{{ kube_config_dir }}/{{ item | basename | replace('.j2', '') }}"
mode: 0644
loop: "{{ custom_cni_manifests }}"
delegate_to: "{{ groups['kube_control_plane'] | first }}"
run_once: true

- name: Custom CNI | Start Resources
kube:
namespace: "kube-system"
kubectl: "{{ bin_dir }}/kubectl"
filename: "{{ kube_config_dir }}/{{ item | basename | replace('.j2', '') }}"
state: "latest"
wait: true
loop: "{{ custom_cni_manifests }}"
delegate_to: "{{ groups['kube_control_plane'] | first }}"
run_once: true
- name: Custom CNI | Start Resources
kube:
namespace: "kube-system"
kubectl: "{{ bin_dir }}/kubectl"
filename: "{{ kube_config_dir }}/{{ item | basename | replace('.j2', '') }}"
state: "latest"
wait: true
loop: "{{ custom_cni_manifests }}"
delegate_to: "{{ groups['kube_control_plane'] | first }}"
run_once: true
when: not custom_cni_chart_release_name | length > 0

0 comments on commit f392b36

Please sign in to comment.