50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
- name: Setup an exsiting k8s cluster to become an admiralty worker for Argo Workflows
|
|
hosts: all:!localhost
|
|
user: "{{ user_prompt }}"
|
|
vars:
|
|
- service_account_name: "{{ serviceaccount_prompt }}"
|
|
- namespace: "{{ namespace_source }}"
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Store kubeconfig value
|
|
ansible.builtin.set_fact:
|
|
kubeconfig: "{{ lookup('file','worker_kubeconfig/{{ target_ip }}_kubeconfig.json') | trim }}"
|
|
|
|
- name: Create the serviceAccount that will execute in the target
|
|
kubernetes.core.k8s:
|
|
state: present
|
|
definition:
|
|
apiVersion: v1
|
|
kind: ServiceAccount
|
|
metadata:
|
|
name: '{{ service_account_name }}'
|
|
namespace: '{{ namespace }}'
|
|
|
|
- name: Create the token to authentify source
|
|
kubernetes.core.k8s:
|
|
state: present
|
|
definition:
|
|
apiVersion: v1
|
|
kind: Secret
|
|
type: Opaque
|
|
metadata:
|
|
name: admiralty-secret-{{ target_name }}
|
|
namespace: "{{ namespace_source }}"
|
|
data:
|
|
config: "{{ kubeconfig | tojson | b64encode }}"
|
|
|
|
- name: Create the target ressource
|
|
kubernetes.core.k8s:
|
|
state: present
|
|
definition:
|
|
apiVersion: multicluster.admiralty.io/v1alpha1
|
|
kind: Target
|
|
metadata:
|
|
name: target-{{ target_name }}
|
|
namespace: '{{ namespace_source }}'
|
|
spec:
|
|
kubeconfigSecret:
|
|
name: admiralty-secret-{{ target_name }}
|