Refactor cluster registration
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3f9fc4b7aa
commit
89cf69adc7
@ -58,7 +58,7 @@
|
||||
name: argocd-applicationset-metacluster
|
||||
namespace: argo-cd
|
||||
cluster:
|
||||
name: https://kubernetes.default.svc
|
||||
url: https://kubernetes.default.svc
|
||||
repository:
|
||||
url: https://git.{{ vapp['metacluster.fqdn'] }}/mc/GitOps.Config.git
|
||||
notify:
|
||||
|
@ -28,19 +28,26 @@
|
||||
|
||||
- block:
|
||||
|
||||
- name: Generate service account in workload cluster
|
||||
kubernetes.core.k8s:
|
||||
template: serviceaccount.j2
|
||||
state: present
|
||||
# - name: Generate service account in workload-cluster
|
||||
# kubernetes.core.k8s:
|
||||
# template: serviceaccount.j2
|
||||
# state: present
|
||||
|
||||
- name: Retrieve service account bearer token
|
||||
# - name: Retrieve service account bearer token
|
||||
# kubernetes.core.k8s_info:
|
||||
# kind: Secret
|
||||
# name: "{{ _template.account.name }}-secret"
|
||||
# namespace: "{{ _template.account.namespace }}"
|
||||
# register: workloadcluster_bearertoken
|
||||
|
||||
- name: Retrieve workload-cluster kubeconfig
|
||||
kubernetes.core.k8s_info:
|
||||
kind: Secret
|
||||
name: "{{ _template.account.name }}-secret"
|
||||
namespace: "{{ _template.account.namespace }}"
|
||||
register: workloadcluster_bearertoken
|
||||
name: "{{ vapp['workloadcluster.name'] }}-kubeconfig"
|
||||
namespace: default
|
||||
register: secret_workloadcluster_kubeconfig
|
||||
|
||||
- name: Register workload cluster in argo-cd
|
||||
- name: Register workload-cluster in argo-cd
|
||||
kubernetes.core.k8s:
|
||||
template: cluster.j2
|
||||
state: present
|
||||
@ -51,7 +58,10 @@
|
||||
name: "{{ vapp['workloadcluster.name'] | lower }}"
|
||||
secret: argocd-cluster-{{ vapp['workloadcluster.name'] | lower }}
|
||||
url: https://{{ vapp['workloadcluster.vip'] }}:6443
|
||||
token: "{{ workloadcluster_bearertoken.resources | json_query('[].data.token') }}"
|
||||
kubeconfig:
|
||||
ca: (secret_workloadcluster_kubeconfig.resources[0].data.value | b64decode | from_yaml).clusters[0].cluster['certificate-authority-data'] | b64encode
|
||||
certificate: (secret_workloadcluster_kubeconfig.resources[0].data.value | b64decode | from_yaml).users[0].user['client-certificate-data'] | b64encode
|
||||
key: (secret_workloadcluster_kubeconfig.resources[0].data.value | b64decode | from_yaml).users[0].user['client-key-data'] | b64encode
|
||||
|
||||
- name: Configure workload-cluster GitOps repository
|
||||
ansible.builtin.template:
|
||||
@ -81,7 +91,7 @@
|
||||
name: argocd-applicationset-workloadcluster
|
||||
namespace: argo-cd
|
||||
cluster:
|
||||
name: "{{ vapp['workloadcluster.name'] | lower }}"
|
||||
url: https://{{ vapp['workloadcluster.vip'] }}:6443
|
||||
repository:
|
||||
url: https://git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git
|
||||
|
||||
@ -91,13 +101,13 @@
|
||||
- name: Trigger handlers
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
vars:
|
||||
_template:
|
||||
account:
|
||||
name: argocd-sa
|
||||
namespace: default
|
||||
clusterrolebinding:
|
||||
name: argocd-crb
|
||||
# vars:
|
||||
# _template:
|
||||
# account:
|
||||
# name: argocd-sa
|
||||
# namespace: default
|
||||
# clusterrolebinding:
|
||||
# name: argocd-crb
|
||||
module_defaults:
|
||||
group/k8s:
|
||||
kubeconfig: "{{ capi_kubeconfig.path }}"
|
||||
|
@ -24,5 +24,5 @@ spec:
|
||||
targetRevision: HEAD
|
||||
path: {% raw %}'{{ path }}'{% endraw +%}
|
||||
destination:
|
||||
server: {{ _template.cluster.name }}
|
||||
server: {{ _template.cluster.url }}
|
||||
namespace: default
|
||||
|
@ -11,8 +11,10 @@ stringData:
|
||||
server: {{ _template.cluster.url }}
|
||||
config: |
|
||||
{
|
||||
"bearerToken": "{{ _template.cluster.token }}",
|
||||
"tlsClientConfig": {
|
||||
"insecure": true
|
||||
"insecure": false,
|
||||
"caData": "{{ _template.kubeconfig.ca }}",
|
||||
"certData": "{{ _template.kubeconfig.certificate }}",
|
||||
"keyData": "{{ _template.kubeconfig.key }}"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user