Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,42 @@
until: r_service is success
retries: "{{ openshift_cnv_retries }}"
delay: "{{ openshift_cnv_delay }}"

- name: Gather NodePort allocation
when: service.type | default('ClusterIP') == "NodePort"
kubernetes.core.k8s_info:
api_version: v1
kind: Service
name: "{{ service.name }}"
namespace: "{{ openshift_cnv_namespace }}"
register: svc_np

- name: If exist set the nodePorts for the instance
when: service.type | default("ClusterIP") == "NodePort"
ansible.builtin.set_fact:
_instance_node_ports: "{{ svc_np.resources[0].spec.ports | map(attribute='nodePort') | join(',') }}"

- name: Add NodePort annotation for service {{ service.name }} to the instance
when: service.type | default("ClusterIP") == "NodePort"
kubernetes.core.k8s:
state: patched
api_version: v1
kind: VirtualMachine
name: "{{ _instance_name }}"
definition: |
apiVersion: v1
kind: VirtualMachine
metadata:
name: "{{ _instance_name }}"
namespace: "{{ openshift_cnv_namespace }}"
annotations:
NodePort-{{ service.name }}: "{{ _instance_node_ports }}"
vars:
_instance_name: "{{ _instance.name }}{{ _index+1 if _instance.count|d(1)|int > 1 }}"
loop: "{{ range(1, _instance.count|default(1)|int+1) | list }}"
loop_control:
index_var: _index
register: r_service
until: r_service is success
retries: "{{ openshift_cnv_retries }}"
delay: "{{ openshift_cnv_delay }}"
Loading