Skip to content

Commit bfe7336

Browse files
authored
Add option to install operators (#45)
* Add option to install operators * update docs * more * typo * fix indent * fix defaults * use custom var to avoid issue * update loop * update names
1 parent 046fbaf commit bfe7336

File tree

6 files changed

+56
-22
lines changed

6 files changed

+56
-22
lines changed

common/roles/install_operator/tasks/main.yaml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- name: Create Namespace
1+
- name: "Create Namespace for {{ operator_name }}"
22
when: operator_namespace != "openshift-operators"
33
kubernetes.core.k8s:
44
template: Namespace.yaml.j2
@@ -7,7 +7,7 @@
77
register: k8s_result
88
until: k8s_result is not failed
99

10-
- name: Create OperatorGroup
10+
- name: "Create OperatorGroup for {{ operator_name }}"
1111
when: operator_namespace != "openshift-operators"
1212
kubernetes.core.k8s:
1313
template: OperatorGroup.yaml.j2
@@ -16,19 +16,9 @@
1616
register: k8s_result
1717
until: k8s_result is not failed
1818

19-
- name: Create Subscription
19+
- name: "Create Subscription for {{ operator_name }}"
2020
kubernetes.core.k8s:
21-
definition:
22-
apiVersion: operators.coreos.com/v1alpha1
23-
kind: Subscription
24-
metadata:
25-
name: "{{ operator_name }}"
26-
namespace: "{{ operator_namespace }}"
27-
spec:
28-
installPlanApproval: Automatic
29-
name: "{{ operator_name }}"
30-
source: "{{ catalog_source | default('redhat-operators') }}"
31-
sourceNamespace: openshift-marketplace
21+
template: Subscription.yaml.j2
3222
apply: true
3323
state: present
3424
register: create_sub
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: operators.coreos.com/v1alpha1
2+
kind: Subscription
3+
metadata:
4+
name: "{{ operator_name }}"
5+
namespace: "{{ operator_namespace }}"
6+
spec:
7+
installPlanApproval: "{{ install_plan_approval | default('Automatic') }}"
8+
name: "{{ operator_name }}"
9+
source: "{{ catalog_source | default('redhat-operators') }}"
10+
sourceNamespace: openshift-marketplace
11+
{% if channel is defined %}
12+
channel: "{{ channel }}"
13+
{% endif %}

edge/install-config-sno-example.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ edgeCluster:
1414
mode: "tpmv2"
1515
relocatable: # Optional, see docs/RELOCATABLE.md
1616
interface: <external_interface>
17-
ipv4_subnet: "192.168.7.0/24" # Optional, defaults to 192.168.7.0/24
18-
ipv6_subnet: "fd04::/64" # Optional, defaults to fd04::/64, only used for dual stack or IPv6 deployments
17+
ipv4Subnet: "192.168.7.0/24" # Optional, defaults to 192.168.7.0/24
18+
ipv6Subnet: "fd04::/64" # Optional, defaults to fd04::/64, only used for dual stack or IPv6 deployments
1919
clearRegistryConfig: false # Optional, deletes ImageContentSourcePolicys and registry pull-secret at the end of the installation. Also disables the crio-wipe service.
2020
routingViaHost: false # Optional, see https://docs.openshift.com/container-platform/latest/rest_api/operator_apis/network-operator-openshift-io-v1.html#spec-defaultnetwork-ovnkubernetesconfig-gatewayconfig
2121
odfStorage: # Optional
@@ -25,6 +25,14 @@ edgeCluster:
2525
catalogSource: redhat-operators # Optional, defaults to redhat-operators
2626
noobaa: false # Install NooBaa (S3 compatible storage), defaults to false
2727
reservedCpuSet: <reserved_set> # Optional, example: "0-1,32-33" there should be no spaces. See https://docs.openshift.com/container-platform/latest/scalability_and_performance/sno-du-enabling-workload-partitioning-on-single-node-openshift.html
28+
operators: # Optional, a list of operators to install
29+
- name: my-operator
30+
namespace: my-namespace
31+
allNamespaces: false # Defaults to false
32+
clusterMonitoring: false # Defaults to false
33+
channel: stable # Can be omitted, will default to the default channel for the operator
34+
catalogSource: redhat-operators # Defaults to redhat-operators
35+
installPlanApproval: Automatic # Defaults to Automatic
2836

2937
baseDomain: <cluster_domain>
3038
compute:

edge/install-config-standard-example.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ edgeCluster:
1414
mode: "tpmv2"
1515
relocatable: # Optional, see docs/RELOCATABLE.md
1616
interface: <external_interface>
17-
ipv4_subnet: "192.168.7.0/24" # Optional, defaults to 192.168.7.0/24
18-
ipv6_subnet: "fd04::/64" # Optional, defaults to fd04::/64, only used for dual stack or IPv6 deployments
17+
ipv4Subnet: "192.168.7.0/24" # Optional, defaults to 192.168.7.0/24
18+
ipv6Subnet: "fd04::/64" # Optional, defaults to fd04::/64, only used for dual stack or IPv6 deployments
1919
clearRegistryConfig: false # Optional, deletes ImageContentSourcePolicys and registry pull-secret at the end of the installation. Also disables the crio-wipe service.
2020
routingViaHost: false # Optional, see https://docs.openshift.com/container-platform/latest/rest_api/operator_apis/network-operator-openshift-io-v1.html#spec-defaultnetwork-ovnkubernetesconfig-gatewayconfig
2121
odfStorage: # Optional
@@ -24,6 +24,14 @@ edgeCluster:
2424
enabled: true
2525
catalogSource: redhat-operators # Optional, defaults to redhat-operators
2626
reservedCpuSet: <reserved_set> # Optional, example: "0-1,32-33" there should be no spaces. See https://docs.openshift.com/container-platform/latest/scalability_and_performance/sno-du-enabling-workload-partitioning-on-single-node-openshift.html
27+
operators: # Optional, a list of operators to install
28+
- name: my-operator
29+
namespace: my-namespace
30+
allNamespaces: false # Defaults to false
31+
clusterMonitoring: false # Defaults to false
32+
channel: stable # Can be omitted, will default to the default channel for the operator
33+
catalogSource: redhat-operators # Defaults to redhat-operators
34+
installPlanApproval: Automatic # Defaults to Automatic
2735

2836
baseDomain: <cluster_domain>
2937
compute:

edge/roles/edge_install/tasks/install.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@
4949
when:
5050
- cluster_ipv4 is defined
5151
- edgeCluster.relocatable is defined
52-
- edgeCluster.relocatable.ipv4_subnet is defined
52+
- edgeCluster.relocatable.ipv4Subnet is defined
5353
ansible.builtin.set_fact:
54-
relocatable_ipv4_subnet: "{{ edgeCluster.relocatable.ipv4_subnet }}"
54+
relocatable_ipv4_subnet: "{{ edgeCluster.relocatable.ipv4Subnet }}"
5555

5656
- name: Set relocatable IPv6 subnet
5757
when:
5858
- cluster_ipv6 is defined
5959
- edgeCluster.relocatable is defined
60-
- edgeCluster.relocatable.ipv6_subnet is defined
60+
- edgeCluster.relocatable.ipv6Subnet is defined
6161
ansible.builtin.set_fact:
62-
relocatable_ipv6_subnet: "{{ edgeCluster.relocatable.ipv6_subnet }}"
62+
relocatable_ipv6_subnet: "{{ edgeCluster.relocatable.ipv6Subnet }}"
6363

6464
# on a multi-node cluster this is determined based on the API and Ingress VIPs
6565
- name: Setup relocatable machine network

edge/roles/edge_post_install/tasks/main.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,21 @@
9898
vars:
9999
catalog_source: "{{ edgeCluster.odfStorage.catalogSource | default('redhat-operators') }}"
100100

101+
- name: Install operator # noqa role-name[path]
102+
loop: "{{ edgeCluster.operators | default([]) }}"
103+
loop_control:
104+
loop_var: operator
105+
ansible.builtin.include_role:
106+
name: "{{ playbook_dir }}/../common/roles/install_operator"
107+
vars:
108+
operator_name: "{{ operator.name }}"
109+
operator_namespace: "{{ operator.namespace }}"
110+
all_namespaces: "{{ operator.allNamespaces | default(false) }}"
111+
cluster_monitoring: "{{ operator.clusterMonitoring | default(false) }}"
112+
catalog_source: "{{ operator.catalogSource | default('redhat-operators') }}"
113+
channel: "{{ operator.channel | default(omit) }}"
114+
install_plan_approval: "{{ operator.installPlanApproval | default('Automatic') }}"
115+
101116
- name: Auto approve CSRs
102117
when:
103118
- edgeCluster.autoApproveCSRs is defined

0 commit comments

Comments
 (0)