Explorar el Código

shrink the crd list for removal, add op deployment role and invocation

Grega Bremec hace 7 meses
padre
commit
4f4091e36d
Se han modificado 3 ficheros con 125 adiciones y 17 borrados
  1. 0 17
      playbooks/inventory.yml
  2. 3 0
      playbooks/pre-flight.yml
  3. 122 0
      playbooks/roles/deploy-operator/tasks/main.yml

+ 0 - 17
playbooks/inventory.yml

@@ -45,20 +45,7 @@ all:
           - kind: tektontriggers
             apiv: operator.tekton.dev/v1alpha1
         add_cleanup:
-          - clusterinterceptors.triggers.tekton.dev
-          - clustertasks.tekton.dev
-          - clustertriggerbindings.triggers.tekton.dev
-          - customruns.tekton.dev
-          - eventlisteners.triggers.tekton.dev
-          - interceptors.triggers.tekton.dev
           - openshiftpipelinesascodes.operator.tekton.dev
-          - pipelineruns.tekton.dev
-          - pipelines.tekton.dev
-          - repositories.pipelinesascode.tekton.dev
-          - resolutionrequests.resolution.tekton.dev
-          - stepactions.tekton.dev
-          - taskruns.tekton.dev
-          - tasks.tekton.dev
           - tektonaddons.operator.tekton.dev
           - tektonchains.operator.tekton.dev
           - tektonconfigs.operator.tekton.dev
@@ -67,10 +54,6 @@ all:
           - tektonpipelines.operator.tekton.dev
           - tektonresults.operator.tekton.dev
           - tektontriggers.operator.tekton.dev
-          - triggerbindings.triggers.tekton.dev
-          - triggers.triggers.tekton.dev
-          - triggertemplates.triggers.tekton.dev
-          - verificationpolicies.tekton.dev
 
     # The list of OpenShift clusters check-env will try to connect to.
     clusters:

+ 3 - 0
playbooks/pre-flight.yml

@@ -16,4 +16,7 @@
       loop_control:
         loop_var: role
       tags: prep
+    - include_role:
+        name: deploy-operator
+      tags: prep
 ...

+ 122 - 0
playbooks/roles/deploy-operator/tasks/main.yml

@@ -0,0 +1,122 @@
+---
+# Ensures all the operator artifacts are created and waits for CSV to succeed.
+#
+# The following variables must exist:
+#
+#   desired_csv
+#   op_nsp
+#   op_cat
+#   op_pkg
+#   op_chn
+#
+# NOTE: Do NOT test by checking for presence of API resources - they do not always get cleaned up.
+#
+- name: Check if the CSV exists already
+  k8s_info:
+    kubeconfig: tmp/kubeconfig-ocp4
+    validate_certs: no
+    api_version: operators.coreos.com/v1alpha1
+    kind: clusterserviceversion
+  register: all_csv
+
+- name: Find the wanted CSV among all CSVs
+  set_fact:
+    found_csv: "{{ (all_csv | community.general.json_query(\"resources[?metadata.name == \" + desired_csv + \"]\")) }}"
+  when:
+    - all_csv.resources is defined
+    - (all_csv.resources | length) > 0
+
+- name: Get details about the CSV if found
+  set_fact:
+    csv_ns: "{{ found_csv[0] | community.general.json_query('metadata.namespace') }}"
+    csv_name: "{{ found_csv[0] | community.general.json_query('metadata.name') }}"
+  when:
+    - found_csv is defined
+    - (found_csv | length) > 0
+
+- name: Make sure the namespace is there
+  k8s:
+    kubeconfig: tmp/kubeconfig-ocp4
+    validate_certs: no
+    api_version: v1
+    kind: namespace
+    name: "{{ op_nsp }}"
+
+# TODO: Finish this at some point.
+#- name: Make sure it has a properly configured OperatorGroup
+#  k8s_info:
+#    kubeconfig: tmp/kubeconfig-ocp4
+#    validate_certs: no
+#    api_version: operators.coreos.com/v1
+#    kind: operatorgroup
+#    namespace: "{{ op_nsp }}"
+#  register: found_opgrp
+
+- name: Also make sure there is a subscription
+  k8s:
+    kubeconfig: tmp/kubeconfig-ocp4
+    validate_certs: no
+    api_version: operators.coreos.com/v1alpha1
+    kind: subscription
+    namespace: "{{ op_nsp }}"
+    name: "{{ op_pkg }}"
+    definition:
+      spec:
+        source: "{{ op_cat }}"
+        sourceNamespace: openshift-marketplace
+        name: "{{ op_pkg }}"
+        channel: "{{ op_chn }}"
+        installPlanApproval: Automatic
+
+# TODO: Finish this at some point.
+#- name: Wait for installPlan to show up
+#  k8s_info:
+#    kubeconfig: tmp/kubeconfig-ocp4
+#    validate_certs: no
+#    api_version: operators.coreos.com/v1alpha1
+#    kind: installplan
+#    namespace: "{{ op_nsp }}"
+#  register: installplan
+#  until:
+#    - installplan.resources is defined
+#    - (installplan.resources | length) > 0
+#    - installplan.resources[0].spec.approved
+#  retries: 12
+#  delay: 10
+
+- name: Wait for CSV to show up and complete
+  k8s_info:
+    kubeconfig: tmp/kubeconfig-ocp4
+    validate_certs: no
+    api_version: operators.coreos.com/v1alpha1
+    kind: clusterserviceversion
+    namespace: "{{ op_nsp }}"
+    name: "{{ desired_csv }}"
+  register: new_csv
+  until:
+    - new_csv.resources is defined
+    - (new_csv.resources | length) > 0
+    - new_csv.resources[0].status is defined
+    - new_csv.resources[0].status.phase == "Succeeded"
+  retries: 30
+  delay: 10
+
+# TODO: Finish this at some point.
+#- name: Finally, wait for the pod
+#  k8s_info:
+#    kubeconfig: tmp/kubeconfig-ocp4
+#    validate_certs: no
+#    api_version: v1
+#    kind: pod
+#    namespace: rhsso
+#    label_selectors:
+#      - name = rhsso-operator
+#  register: sso_pod
+#  until:
+#    - sso_pod.resources is defined
+#    - (sso_pod.resources | length) > 0
+#    - sso_pod.resources[0].status is defined
+#    - sso_pod.resources[0].status.phase == "Running"
+#  retries: 30
+#  delay: 10
+...