|
| 1 | +# HyperShift adapter task configuration |
| 2 | +# Creates a HostedCluster + required secrets on the remote management cluster |
| 3 | +params: |
| 4 | + |
| 5 | + - name: "clusterId" |
| 6 | + source: "event.id" |
| 7 | + type: "string" |
| 8 | + required: true |
| 9 | + |
| 10 | + - name: "generation" |
| 11 | + source: "event.generation" |
| 12 | + type: "int" |
| 13 | + required: true |
| 14 | + |
| 15 | + - name: "namespace" |
| 16 | + source: "env.CLUSTERS_NAMESPACE" |
| 17 | + type: "string" |
| 18 | + |
| 19 | + - name: "ociRegion" |
| 20 | + source: "env.OCI_REGION" |
| 21 | + type: "string" |
| 22 | + |
| 23 | + - name: "ociCompartmentId" |
| 24 | + source: "env.OCI_COMPARTMENT_ID" |
| 25 | + type: "string" |
| 26 | + |
| 27 | + - name: "releaseImage" |
| 28 | + source: "env.OPENSHIFT_RELEASE_IMAGE" |
| 29 | + type: "string" |
| 30 | + |
| 31 | + - name: "baseDomain" |
| 32 | + source: "env.BASE_DOMAIN" |
| 33 | + type: "string" |
| 34 | + |
| 35 | + - name: "cpoImage" |
| 36 | + source: "env.CPO_IMAGE" |
| 37 | + type: "string" |
| 38 | + |
| 39 | + - name: "workerNodeIP" |
| 40 | + source: "env.WORKER_NODE_IP" |
| 41 | + type: "string" |
| 42 | + |
| 43 | +# Preconditions: check cluster details from API |
| 44 | +preconditions: |
| 45 | + - name: "clusterStatus" |
| 46 | + api_call: |
| 47 | + method: "GET" |
| 48 | + url: "/clusters/{{ .clusterId }}" |
| 49 | + timeout: 10s |
| 50 | + retry_attempts: 3 |
| 51 | + retry_backoff: "exponential" |
| 52 | + capture: |
| 53 | + - name: "clusterName" |
| 54 | + field: "name" |
| 55 | + - name: "generation" |
| 56 | + field: "generation" |
| 57 | + - name: "clusterNotReady" |
| 58 | + expression: | |
| 59 | + status.conditions.filter(c, c.type == "Ready").size() > 0 |
| 60 | + ? status.conditions.filter(c, c.type == "Ready")[0].status != "True" |
| 61 | + : true |
| 62 | +
|
| 63 | + - name: "validationCheck" |
| 64 | + expression: | |
| 65 | + clusterNotReady |
| 66 | +
|
| 67 | +# Resources: Namespace + HostedCluster on the remote management cluster |
| 68 | +resources: |
| 69 | + |
| 70 | + # Ensure the clusters namespace exists on the management cluster |
| 71 | + - name: "clustersNamespace" |
| 72 | + transport: |
| 73 | + client: "kubernetes" |
| 74 | + manifest: |
| 75 | + apiVersion: v1 |
| 76 | + kind: Namespace |
| 77 | + metadata: |
| 78 | + name: "{{ .namespace }}" |
| 79 | + discovery: |
| 80 | + by_name: "{{ .namespace }}" |
| 81 | + |
| 82 | + # Create the HostedCluster resource |
| 83 | + - name: "hostedCluster" |
| 84 | + transport: |
| 85 | + client: "kubernetes" |
| 86 | + manifest: |
| 87 | + apiVersion: hypershift.openshift.io/v1beta1 |
| 88 | + kind: HostedCluster |
| 89 | + metadata: |
| 90 | + name: "{{ .clusterName }}" |
| 91 | + namespace: "{{ .namespace }}" |
| 92 | + annotations: |
| 93 | + hypershift.openshift.io/pod-security-admission-label-override: "privileged" |
| 94 | + hypershift.openshift.io/control-plane-operator-image: "{{ .cpoImage }}" |
| 95 | + hypershift.openshift.io/disable-monitoring-services: "true" |
| 96 | + labels: |
| 97 | + hyperfleet.io/cluster-id: "{{ .clusterId }}" |
| 98 | + hyperfleet.io/cluster-name: "{{ .clusterName }}" |
| 99 | + spec: |
| 100 | + platform: |
| 101 | + type: OCI |
| 102 | + oci: |
| 103 | + identityRef: |
| 104 | + name: oci-credentials |
| 105 | + region: "{{ .ociRegion }}" |
| 106 | + compartmentId: "{{ .ociCompartmentId }}" |
| 107 | + controllerAvailabilityPolicy: SingleReplica |
| 108 | + pullSecret: |
| 109 | + name: pull-secret |
| 110 | + sshKey: |
| 111 | + name: ssh-key |
| 112 | + networking: |
| 113 | + clusterNetwork: |
| 114 | + - cidr: 10.132.0.0/14 |
| 115 | + serviceNetwork: |
| 116 | + - cidr: 172.31.0.0/16 |
| 117 | + networkType: OVNKubernetes |
| 118 | + services: |
| 119 | + - service: Ignition |
| 120 | + servicePublishingStrategy: |
| 121 | + type: NodePort |
| 122 | + nodePort: |
| 123 | + address: "{{ .workerNodeIP }}" |
| 124 | + - service: OAuthServer |
| 125 | + servicePublishingStrategy: |
| 126 | + type: NodePort |
| 127 | + nodePort: |
| 128 | + address: "{{ .workerNodeIP }}" |
| 129 | + - service: APIServer |
| 130 | + servicePublishingStrategy: |
| 131 | + type: LoadBalancer |
| 132 | + - service: Konnectivity |
| 133 | + servicePublishingStrategy: |
| 134 | + type: LoadBalancer |
| 135 | + release: |
| 136 | + image: "{{ .releaseImage }}" |
| 137 | + dns: |
| 138 | + baseDomain: "{{ .baseDomain }}" |
| 139 | + discovery: |
| 140 | + namespace: "{{ .namespace }}" |
| 141 | + by_selectors: |
| 142 | + label_selector: |
| 143 | + hyperfleet.io/cluster-id: "{{ .clusterId }}" |
| 144 | + |
| 145 | +# Post-processing: report HostedCluster status back to API |
| 146 | +post: |
| 147 | + payloads: |
| 148 | + - name: "statusPayload" |
| 149 | + build: |
| 150 | + adapter: "{{ .adapter.name }}" |
| 151 | + conditions: |
| 152 | + - type: "Applied" |
| 153 | + status: |
| 154 | + expression: | |
| 155 | + has(resources.hostedCluster.metadata.creationTimestamp) ? "True" : "False" |
| 156 | + reason: |
| 157 | + expression: | |
| 158 | + has(resources.hostedCluster.metadata.creationTimestamp) ? "HostedClusterCreated" : "HostedClusterPending" |
| 159 | + message: |
| 160 | + expression: | |
| 161 | + has(resources.hostedCluster.metadata.creationTimestamp) |
| 162 | + ? "HostedCluster has been created on the management cluster" |
| 163 | + : "HostedCluster is pending creation" |
| 164 | + - type: "Available" |
| 165 | + status: |
| 166 | + expression: | |
| 167 | + has(resources.hostedCluster.status) && has(resources.hostedCluster.status.conditions) |
| 168 | + ? (resources.hostedCluster.status.conditions.filter(c, c.type == "Available").size() > 0 |
| 169 | + ? resources.hostedCluster.status.conditions.filter(c, c.type == "Available")[0].status |
| 170 | + : "False") |
| 171 | + : "False" |
| 172 | + reason: |
| 173 | + expression: | |
| 174 | + has(resources.hostedCluster.status) && has(resources.hostedCluster.status.conditions) |
| 175 | + ? (resources.hostedCluster.status.conditions.filter(c, c.type == "Available").size() > 0 |
| 176 | + ? resources.hostedCluster.status.conditions.filter(c, c.type == "Available")[0].reason |
| 177 | + : "WaitingForControlPlane") |
| 178 | + : "WaitingForControlPlane" |
| 179 | + message: |
| 180 | + expression: | |
| 181 | + has(resources.hostedCluster.status) && has(resources.hostedCluster.status.conditions) |
| 182 | + ? (resources.hostedCluster.status.conditions.filter(c, c.type == "Available").size() > 0 |
| 183 | + ? resources.hostedCluster.status.conditions.filter(c, c.type == "Available")[0].message |
| 184 | + : "Waiting for hosted control plane to become available") |
| 185 | + : "Waiting for hosted control plane to become available" |
| 186 | + - type: "Health" |
| 187 | + status: |
| 188 | + expression: | |
| 189 | + adapter.?executionStatus.orValue("") == "success" ? "True" : (adapter.?executionStatus.orValue("") == "failed" ? "False" : "Unknown") |
| 190 | + reason: |
| 191 | + expression: | |
| 192 | + adapter.?errorReason.orValue("") != "" ? adapter.?errorReason.orValue("") : "Healthy" |
| 193 | + message: |
| 194 | + expression: | |
| 195 | + adapter.?errorMessage.orValue("") != "" ? adapter.?errorMessage.orValue("") : "Adapter executed successfully" |
| 196 | + observed_generation: |
| 197 | + expression: "generation" |
| 198 | + observed_time: "{{ now | date \"2006-01-02T15:04:05Z07:00\" }}" |
| 199 | + |
| 200 | + post_actions: |
| 201 | + - name: "reportClusterStatus" |
| 202 | + api_call: |
| 203 | + method: "POST" |
| 204 | + url: "/clusters/{{ .clusterId }}/statuses" |
| 205 | + headers: |
| 206 | + - name: "Content-Type" |
| 207 | + value: "application/json" |
| 208 | + body: "{{ .statusPayload }}" |
0 commit comments