2018-02-04 12:32:33 +08:00
|
|
|
---
|
2021-12-15 16:18:19 +08:00
|
|
|
- name: Registry | check registry_service_type value
|
|
|
|
fail:
|
|
|
|
msg: "registry_service_type can only be 'ClusterIP', 'LoadBalancer' or 'NodePort'"
|
|
|
|
when: registry_service_type not in ['ClusterIP', 'LoadBalancer', 'NodePort']
|
|
|
|
|
|
|
|
- name: Registry | Stop if registry_service_cluster_ip is defined when registry_service_type is not 'ClusterIP'
|
|
|
|
fail:
|
|
|
|
msg: "registry_service_cluster_ip support only compatible with ClusterIP."
|
|
|
|
when:
|
2023-07-05 11:36:54 +08:00
|
|
|
- registry_service_cluster_ip is defined and registry_service_cluster_ip | length > 0
|
2021-12-15 16:18:19 +08:00
|
|
|
- registry_service_type != "ClusterIP"
|
|
|
|
|
|
|
|
- name: Registry | Stop if registry_service_loadbalancer_ip is defined when registry_service_type is not 'LoadBalancer'
|
|
|
|
fail:
|
|
|
|
msg: "registry_service_loadbalancer_ip support only compatible with LoadBalancer."
|
|
|
|
when:
|
2023-07-05 11:36:54 +08:00
|
|
|
- registry_service_loadbalancer_ip is defined and registry_service_loadbalancer_ip | length > 0
|
2021-12-15 16:18:19 +08:00
|
|
|
- registry_service_type != "LoadBalancer"
|
|
|
|
|
|
|
|
- name: Registry | Stop if registry_service_nodeport is defined when registry_service_type is not 'NodePort'
|
|
|
|
fail:
|
|
|
|
msg: "registry_service_nodeport support only compatible with NodePort."
|
|
|
|
when:
|
2023-07-05 11:36:54 +08:00
|
|
|
- registry_service_nodeport is defined and registry_service_nodeport | length > 0
|
2021-12-15 16:18:19 +08:00
|
|
|
- registry_service_type != "NodePort"
|
2018-02-04 12:32:33 +08:00
|
|
|
|
|
|
|
- name: Registry | Create addon dir
|
|
|
|
file:
|
|
|
|
path: "{{ kube_config_dir }}/addons/registry"
|
2018-02-09 15:47:57 +08:00
|
|
|
state: directory
|
2018-02-04 12:32:33 +08:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
|
2018-08-23 00:16:13 +08:00
|
|
|
- name: Registry | Templates list
|
|
|
|
set_fact:
|
|
|
|
registry_templates:
|
|
|
|
- { name: registry-ns, file: registry-ns.yml, type: ns }
|
|
|
|
- { name: registry-sa, file: registry-sa.yml, type: sa }
|
|
|
|
- { name: registry-svc, file: registry-svc.yml, type: svc }
|
2021-12-08 00:32:00 +08:00
|
|
|
- { name: registry-secrets, file: registry-secrets.yml, type: secrets }
|
|
|
|
- { name: registry-cm, file: registry-cm.yml, type: cm }
|
2018-08-23 00:16:13 +08:00
|
|
|
- { name: registry-rs, file: registry-rs.yml, type: rs }
|
|
|
|
|
2021-12-22 02:20:46 +08:00
|
|
|
- name: Registry | Append nginx ingress templates to Registry Templates list when ingress enabled
|
|
|
|
set_fact:
|
|
|
|
registry_templates: "{{ registry_templates + [item] }}"
|
|
|
|
with_items:
|
|
|
|
- [{ name: registry-ing, file: registry-ing.yml, type: ing }]
|
2022-01-11 16:45:16 +08:00
|
|
|
when: ingress_nginx_enabled or ingress_alb_enabled
|
2021-12-22 02:20:46 +08:00
|
|
|
|
2018-02-04 12:32:33 +08:00
|
|
|
- name: Registry | Create manifests
|
|
|
|
template:
|
|
|
|
src: "{{ item.file }}.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/addons/registry/{{ item.file }}"
|
2022-01-09 17:51:12 +08:00
|
|
|
mode: 0644
|
2018-08-23 00:16:13 +08:00
|
|
|
with_items: "{{ registry_templates }}"
|
2018-02-04 12:32:33 +08:00
|
|
|
register: registry_manifests
|
2021-03-24 08:26:05 +08:00
|
|
|
when: inventory_hostname == groups['kube_control_plane'][0]
|
2018-02-04 12:32:33 +08:00
|
|
|
|
|
|
|
- name: Registry | Apply manifests
|
|
|
|
kube:
|
2019-04-24 01:37:23 +08:00
|
|
|
name: "{{ item.item.name }}"
|
2018-02-09 15:47:57 +08:00
|
|
|
namespace: "{{ registry_namespace }}"
|
2018-02-04 12:32:33 +08:00
|
|
|
kubectl: "{{ bin_dir }}/kubectl"
|
2019-04-24 01:37:23 +08:00
|
|
|
resource: "{{ item.item.type }}"
|
|
|
|
filename: "{{ kube_config_dir }}/addons/registry/{{ item.item.file }}"
|
2018-02-04 12:32:33 +08:00
|
|
|
state: "latest"
|
2019-04-24 01:37:23 +08:00
|
|
|
with_items: "{{ registry_manifests.results }}"
|
2021-03-24 08:26:05 +08:00
|
|
|
when: inventory_hostname == groups['kube_control_plane'][0]
|
2018-02-09 15:47:57 +08:00
|
|
|
|
|
|
|
- name: Registry | Create PVC manifests
|
|
|
|
template:
|
|
|
|
src: "{{ item.file }}.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/addons/registry/{{ item.file }}"
|
2022-01-09 17:51:12 +08:00
|
|
|
mode: 0644
|
2018-02-09 15:47:57 +08:00
|
|
|
with_items:
|
|
|
|
- { name: registry-pvc, file: registry-pvc.yml, type: pvc }
|
|
|
|
register: registry_manifests
|
|
|
|
when:
|
2019-04-29 14:00:20 +08:00
|
|
|
- registry_storage_class != none and registry_storage_class
|
|
|
|
- registry_disk_size != none and registry_disk_size
|
2021-03-24 08:26:05 +08:00
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
2018-02-09 15:47:57 +08:00
|
|
|
|
|
|
|
- name: Registry | Apply PVC manifests
|
|
|
|
kube:
|
2019-04-24 01:37:23 +08:00
|
|
|
name: "{{ item.item.name }}"
|
2018-02-09 15:47:57 +08:00
|
|
|
namespace: "{{ registry_namespace }}"
|
|
|
|
kubectl: "{{ bin_dir }}/kubectl"
|
2019-04-24 01:37:23 +08:00
|
|
|
resource: "{{ item.item.type }}"
|
|
|
|
filename: "{{ kube_config_dir }}/addons/registry/{{ item.item.file }}"
|
2018-02-09 15:47:57 +08:00
|
|
|
state: "latest"
|
2019-04-24 01:37:23 +08:00
|
|
|
with_items: "{{ registry_manifests.results }}"
|
2018-02-09 15:47:57 +08:00
|
|
|
when:
|
2019-04-29 14:00:20 +08:00
|
|
|
- registry_storage_class != none and registry_storage_class
|
|
|
|
- registry_disk_size != none and registry_disk_size
|
2021-03-24 08:26:05 +08:00
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|