mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-07 13:32:37 +00:00
helm - add support for in-memory kubeconfig (#497)
helm - add support for in-memory kubeconfig SUMMARY closes #492 ISSUE TYPE Feature Pull Request Reviewed-by: Mike Graves <mgraves@redhat.com> Reviewed-by: Bikouo Aubin <None>
This commit is contained in:
@@ -26,3 +26,4 @@ test_namespace:
|
||||
- "helm-local-path-002"
|
||||
- "helm-local-path-003"
|
||||
- "helm-dep"
|
||||
- "helm-kubeconfig"
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
- name: Test Skip CRDS feature in helm chart install
|
||||
include_tasks: test_crds.yml
|
||||
|
||||
- name: Test in-memory kubeconfig
|
||||
include_tasks: tests_in_memory_kubeconfig.yml
|
||||
|
||||
- name: Clean helm install
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
---
|
||||
- set_fact:
|
||||
custom_kubeconfig_path: "~/.kube/customconfig"
|
||||
default_kubeconfig_path: "~/.kube/config"
|
||||
helm_in_mem_kubeconf_ns: "{{ test_namespace[11] }}"
|
||||
|
||||
- block:
|
||||
- name: Copy default kubeconfig
|
||||
copy:
|
||||
remote_src: true
|
||||
src: "{{ default_kubeconfig_path }}"
|
||||
dest: "{{ custom_kubeconfig_path }}"
|
||||
|
||||
- name: Delete default kubeconfig
|
||||
file:
|
||||
path: "{{ default_kubeconfig_path }}"
|
||||
state: absent
|
||||
|
||||
- set_fact:
|
||||
custom_kubeconfig: "{{ lookup('file', custom_kubeconfig_path) | from_yaml }}"
|
||||
no_log: true
|
||||
|
||||
# helm_plugin and helm_plugin_info
|
||||
- name: Install subenv plugin
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
kubeconfig: "{{ custom_kubeconfig }}"
|
||||
state: present
|
||||
plugin_path: https://github.com/hydeenoble/helm-subenv
|
||||
register: plugin
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- plugin is changed
|
||||
|
||||
- name: Gather info about all plugin
|
||||
helm_plugin_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
kubeconfig: "{{ custom_kubeconfig }}"
|
||||
register: plugin_info
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- '"plugin_list" in plugin_info'
|
||||
- plugin_info.plugin_list != []
|
||||
|
||||
# helm_repository, helm, helm_info
|
||||
- name: Add test_bitnami chart repository
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_bitnami
|
||||
kubeconfig: "{{ custom_kubeconfig }}"
|
||||
repo_url: https://charts.bitnami.com/bitnami
|
||||
register: repository
|
||||
|
||||
- name: Assert that repository was added
|
||||
assert:
|
||||
that:
|
||||
- repository is changed
|
||||
|
||||
- name: Install chart from repository added before
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: rabbitmq
|
||||
chart_ref: test_bitnami/rabbitmq
|
||||
namespace: "{{ helm_in_mem_kubeconf_ns }}"
|
||||
update_repo_cache: true
|
||||
kubeconfig: "{{ custom_kubeconfig }}"
|
||||
create_namespace: true
|
||||
register: deploy
|
||||
|
||||
- name: Assert chart was successfully deployed
|
||||
assert:
|
||||
that:
|
||||
- deploy is changed
|
||||
|
||||
- name: Get chart content
|
||||
helm_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
kubeconfig: "{{ custom_kubeconfig }}"
|
||||
name: "rabbitmq"
|
||||
namespace: "{{ helm_in_mem_kubeconf_ns }}"
|
||||
register: chart_info
|
||||
|
||||
- name: Assert chart was successfully deployed
|
||||
assert:
|
||||
that:
|
||||
- '"status" in chart_info'
|
||||
- chart_info.status.status is defined
|
||||
- chart_info.status.status == "deployed"
|
||||
|
||||
- name: Remove chart
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: rabbitmq
|
||||
namespace: "{{ helm_in_mem_kubeconf_ns }}"
|
||||
kubeconfig: "{{ custom_kubeconfig }}"
|
||||
state: absent
|
||||
register: remove_chart
|
||||
|
||||
- name: Assert chart was successfully removed
|
||||
assert:
|
||||
that:
|
||||
- remove_chart is changed
|
||||
|
||||
- name: Get chart content
|
||||
helm_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
kubeconfig: "{{ custom_kubeconfig }}"
|
||||
name: "rabbitmq"
|
||||
namespace: "{{ helm_in_mem_kubeconf_ns }}"
|
||||
register: chart_info
|
||||
|
||||
- name: Assert chart was successfully deployed
|
||||
assert:
|
||||
that:
|
||||
- '"status" not in chart_info'
|
||||
|
||||
- name: Remove chart repository
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_bitnami
|
||||
kubeconfig: "{{ custom_kubeconfig }}"
|
||||
state: absent
|
||||
register: remove
|
||||
|
||||
- name: Assert that repository was removed
|
||||
assert:
|
||||
that:
|
||||
- remove is changed
|
||||
|
||||
always:
|
||||
- name: Return kubeconfig
|
||||
copy:
|
||||
remote_src: true
|
||||
src: "{{ custom_kubeconfig_path }}"
|
||||
dest: "{{ default_kubeconfig_path }}"
|
||||
ignore_errors: true
|
||||
|
||||
- name: Delete custom config
|
||||
file:
|
||||
path: "{{ custom_kubeconfig_path }}"
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
|
||||
- name: Remove subenv plugin
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
plugin_name: subenv
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
|
||||
- name: Delete namespace
|
||||
k8s:
|
||||
kind: Namespace
|
||||
name: "{{ helm_in_mem_kubeconf_ns }}"
|
||||
ignore_errors: true
|
||||
|
||||
- name: Delete helm repository
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_bitnami
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
Reference in New Issue
Block a user