Skip to content

Commit

Permalink
fix remote kube cluster access
Browse files Browse the repository at this point in the history
  • Loading branch information
kmlTE committed Mar 11, 2021
1 parent 050841e commit 7e7dc8c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions kubernetes/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ node_types:
type: string
default: ~/.kube/config
description: Path to kubeconfig file
username:
type: string
default: centos
required: false
description: User for remote cluster access

sodalite.nodes.Kubernetes.Definition:
derived_from: tosca.nodes.SoftwareComponent
Expand Down Expand Up @@ -74,6 +79,7 @@ node_types:
operations:
create:
inputs:
ansible_user: { type: string, default: { get_property: [ SELF, host, username ] } }
kubeconfig: { type: string, default: { get_property: [ SELF, host, kubeconfig ] } }
helm_name: { type: string, default: { get_property: [ SELF, name ] } }
helm_namespace: { type: string, default: { get_property: [ SELF, namespace ] } }
Expand All @@ -87,6 +93,7 @@ node_types:
primary: playbooks/create_from_helm.yaml
delete:
inputs:
ansible_user: { type: string, default: { get_property: [ SELF, host, username ] } }
kubeconfig: { type: string, default: { get_property: [ SELF, host, kubeconfig ] } }
helm_name: { type: string, default: { get_property: [ SELF, name ] } }
helm_namespace: { type: string, default: { get_property: [ SELF, namespace ] } }
Expand Down
6 changes: 4 additions & 2 deletions kubernetes/playbooks/create_from_helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
chart_from_git: "{{ helm_repo_url[-4:] == '.git' }}"
defined_helm_repo: "{{ helm_repo_url != '' and helm_repo_name != '' }}"
actual_helm_chart: "{{ tmp_helm_repo + '/' + helm_chart if chart_from_git else helm_chart }}"
ansible_python_interpreter: "/usr/bin/env python3"
tasks:

- name: Check if helm is installed
Expand Down Expand Up @@ -37,10 +38,11 @@
- name: Install chart
community.kubernetes.helm:
state: present
kubeconfig: "{{ kubeconfig }}"
name: "{{ helm_name }}"
namespace: "{{ helm_namespace }}"
chart_ref: "{{ actual_helm_chart }}"
chart_version: "{{ helm_chart_version if helm_chart_version is defined and helm_chart_version != 'latest' }}"
values_files: "{{ helm_values_files }}"
values: "{{ helm_values }}"
values: "{{ helm_values }}"
environment:
K8S_AUTH_KUBECONFIG: "{{ kubeconfig }}"
5 changes: 4 additions & 1 deletion kubernetes/playbooks/delete_from_helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
chart_from_git: "{{ helm_repo_url[-4:] == '.git' }}"
defined_helm_repo: "{{ helm_repo_url != '' and helm_repo_name != '' }}"
actual_helm_chart: "{{ tmp_helm_repo + '/' + helm_chart if chart_from_git else helm_chart }}"
ansible_python_interpreter: "/usr/bin/env python3"
tasks:

- name: Check if helm is installed
Expand All @@ -21,11 +22,13 @@
msg: Helm must be installed
when: not helm_exists

- name: Remove stable/mysql chart
- name: Remove chart
community.kubernetes.helm:
state: absent
name: "{{ helm_name }}"
namespace: "{{ helm_namespace }}"
environment:
K8S_AUTH_KUBECONFIG: "{{ kubeconfig }}"

- name: Remove repo
block:
Expand Down

0 comments on commit 7e7dc8c

Please sign in to comment.