Skip to content

Commit

Permalink
Move helm/kind setup to github actions (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyphreak authored Jan 4, 2023
1 parent 1caf21b commit bd8b03e
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 9 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,21 @@ jobs:
with:
python-version: '3.x'

- name: install poetry
run: pip3 install poetry

- name: install helm
uses: azure/setup-helm@v3
with:
version: 'latest'
token: ${{ secrets.GITHUB_TOKEN }}
id: helm

- name: install poetry
run: pip3 install poetry
- name: install kind
uses: engineerd/[email protected]
with:
version: "v0.17.0"
skipClusterCreation: true

- name: install pips
run: poetry install
Expand All @@ -91,3 +98,4 @@ jobs:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
K8S_RELEASE: ${{ matrix.image }}
HELM_BIN: ${{ steps.helm.outputs.helm-path }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ __pycache__/
Gemfile.lock
**/.ropeproject
playbook.retry
.tool-versions
77 changes: 77 additions & 0 deletions molecule/common/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
- name: prepare

hosts: localhost

gather_facts: false

tasks:

- name: check local helm binary
ansible.builtin.shell: "which {{ lookup('env', 'HELM_BIN', default='helm') }}"
register: helm_bin_query
changed_when: false

- name: copy helm binary
ansible.builtin.copy:
src: "{{ helm_bin_query.stdout }}"
dest: "{{ k8s_helm_bin }}"
mode: '0755'
when: helm_bin_query is succeeded

- name: download helm binary
when: helm_bin_query is not succeeded
block:

- name: query helm releases
ansible.builtin.uri:
url: https://api.github.com/repos/helm/helm/releases/latest
register: helm_release_query

- name: set kind release target
ansible.builtin.set_fact:
helm_release: "{{ helm_release_query.json.tag_name }}"

- name: create temporary directory
ansible.builtin.tempfile:
state: directory
prefix: kind
register: _tmpdir
changed_when: false

- name: install helm binary
block:

- name: download helm release package
ansible.builtin.unarchive:
src: "https://get.helm.sh/helm-{{ helm_release }}-linux-amd64.tar.gz"
dest: "{{ _tmpdir.path }}"
remote_src: true
register: helm_dl_op
retries: 3
delay: 10
until: helm_dl_op is success
changed_when: false

- name: find helm executable
ansible.builtin.find:
paths: "{{ _tmpdir.path }}"
file_type: file
recurse: true
use_regex: true
patterns:
- '^helm$'
register: helm_bin

- name: copy helm copy helm binary
ansible.builtin.copy:
src: "{{ helm_bin.files[0].path }}"
dest: "{{ k8s_helm_bin }}"
mode: '0755'

always:

- name: cleanup temp files
ansible.builtin.file:
state: absent
path: "{{ _tmpdir.path }}"
2 changes: 1 addition & 1 deletion tasks/deploy/argocd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
wait_timeout: "{{ k8s_argocd_wait_timeout }}s"
values: "{{ k8s_argocd_chart_values }}"
kubeconfig: "{{ k8s_kubeconfig | default(omit) }}"
binary_path: "{{ k8s_helm_bin | default(omit) }}"
binary_path: "{{ lookup('env', 'HELM_BIN', default=k8s_helm_bin) }}"

- name: query argocd-repo-server definition
ansible.builtin.set_fact:
Expand Down
2 changes: 1 addition & 1 deletion tasks/deploy/certmanager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
wait: true
wait_timeout: "{{ k8s_certmanager_wait_timeout }}s"
kubeconfig: "{{ k8s_kubeconfig | default(omit) }}"
binary_path: "{{ k8s_helm_bin | default(omit) }}"
binary_path: "{{ lookup('env', 'HELM_BIN', default=k8s_helm_bin) }}"
values:
installCRDs: true
podDnsConfig:
Expand Down
2 changes: 1 addition & 1 deletion tasks/deploy/longhorn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
wait: true
wait_timeout: "{{ k8s_longhorn_wait_timeout }}s"
kubeconfig: "{{ k8s_kubeconfig | default(omit) }}"
binary_path: "{{ k8s_helm_bin | default(omit) }}"
binary_path: "{{ lookup('env', 'HELM_BIN', default=k8s_helm_bin) }}"
values: "{{ k8s_longhorn_chart_values }}"
2 changes: 1 addition & 1 deletion tasks/deploy/metallb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
speaker:
secretValue: "{{ k8s_metallb_speaker_secret }}"
kubeconfig: "{{ k8s_kubeconfig | default(omit) }}"
binary_path: "{{ k8s_helm_bin | default(omit) }}"
binary_path: "{{ lookup('env', 'HELM_BIN', default=k8s_helm_bin) }}"

- name: create metallb pools
kubernetes.core.k8s:
Expand Down
2 changes: 1 addition & 1 deletion tasks/deploy/nginx/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
wait_timeout: "{{ k8s_nginx_wait_timeout }}"
create_namespace: true
kubeconfig: "{{ k8s_kubeconfig | default(omit) }}"
binary_path: "{{ k8s_helm_bin | default(omit) }}"
binary_path: "{{ lookup('env', 'HELM_BIN', default=k8s_helm_bin) }}"
values:
controller:
ingressClassResource:
Expand Down
2 changes: 1 addition & 1 deletion tasks/deploy/nginx/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
wait_timeout: "{{ k8s_nginx_wait_timeout }}s"
create_namespace: true
kubeconfig: "{{ k8s_kubeconfig | default(omit) }}"
binary_path: "{{ k8s_helm_bin | default(omit) }}"
binary_path: "{{ lookup('env', 'HELM_BIN', default=k8s_helm_bin) }}"
values:
controller:
ingressClassResource:
Expand Down
2 changes: 1 addition & 1 deletion tasks/deploy/zalando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
wait: true
wait_timeout: "{{ k8s_zalando_wait_timeout }}s"
kubeconfig: "{{ k8s_kubeconfig | default(omit) }}"
binary_path: "{{ k8s_helm_bin | default(omit) }}"
binary_path: "{{ lookup('env', 'HELM_BIN', default=k8s_helm_bin) }}"
values:
configKubernetes:
secret_name_template: "{{ k8s_zalando_secret_template }}"
Expand Down

0 comments on commit bd8b03e

Please sign in to comment.