-
Notifications
You must be signed in to change notification settings - Fork 13
HYPERFLEET-610: Add OCI/OKE deployment targets #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vkareh
wants to merge
5
commits into
main
Choose a base branch
from
platform-oci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d8ed508
HYPERFLEET-610: Add OCI/OKE deployment targets
vkareh 0e32be7
Add adapter-hypershift for remote HostedCluster creation
vkareh 38b6f25
Add adapter-hypershift-nodepool chart and fix adapter-hypershift for OCI
vkareh 06c0fe0
Fix precondition guards and use dynamic nodepool spec values
vkareh 30b51ef
Guard clusterAvailable conditions and fix YAML quoting in nodepool ad…
vkareh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| apiVersion: v2 | ||
| name: adapter-hypershift-nodepool | ||
| description: HyperShift NodePool adapter - creates NodePool resources on a remote management cluster | ||
| type: application | ||
| version: 0.1.0 | ||
| appVersion: "0.0.0-dev" | ||
|
|
||
| dependencies: | ||
| - name: hyperfleet-adapter | ||
| version: "2.0.0" | ||
| repository: "git+https://github.com/openshift-hyperfleet/hyperfleet-adapter@charts?ref=main" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # HyperShift NodePool adapter deployment configuration | ||
| # Creates NodePool resources on a remote HyperShift management cluster | ||
| adapter: | ||
| name: adapter-hypershift-nodepool | ||
| version: "0.2.0" | ||
|
|
||
| debug_config: true | ||
| log: | ||
| level: debug | ||
|
|
||
| clients: | ||
| hyperfleet_api: | ||
| base_url: http://hyperfleet-api:8000 | ||
| version: v1 | ||
| timeout: 10s | ||
| retry_attempts: 3 | ||
| retry_backoff: exponential | ||
|
|
||
| broker: | ||
| subscription_id: "adapter-hypershift-nodepool" | ||
| topic: "hyperfleet-nodepools" | ||
|
|
||
| kubernetes: | ||
| api_version: "v1" | ||
| # Use the mounted kubeconfig to target the remote HyperShift management cluster | ||
| kube_config_path: /etc/hypershift/kubeconfig |
214 changes: 214 additions & 0 deletions
214
helm/adapter-hypershift-nodepool/adapter-task-config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| # HyperShift NodePool adapter task configuration | ||
| # Creates a NodePool resource on the remote management cluster | ||
| params: | ||
|
|
||
| - name: "nodepoolId" | ||
| source: "event.id" | ||
| type: "string" | ||
| required: true | ||
|
|
||
| - name: "clusterId" | ||
| source: "event.owner_references.id" | ||
| type: "string" | ||
| required: true | ||
|
|
||
| - name: "generation" | ||
| source: "event.generation" | ||
| type: "int" | ||
| required: true | ||
|
|
||
| - name: "namespace" | ||
| source: "env.CLUSTERS_NAMESPACE" | ||
| type: "string" | ||
|
|
||
| - name: "ociAD" | ||
| source: "env.OCI_AD" | ||
| type: "string" | ||
|
|
||
| - name: "ociSubnetId" | ||
| source: "env.OCI_SUBNET_ID" | ||
| type: "string" | ||
|
|
||
| - name: "ociShape" | ||
| source: "env.OCI_SHAPE" | ||
| type: "string" | ||
|
|
||
| - name: "ociOcpus" | ||
| source: "env.OCI_OCPUS" | ||
| type: "string" | ||
|
|
||
| - name: "ociMemoryGBs" | ||
| source: "env.OCI_MEMORY_GBS" | ||
| type: "string" | ||
|
|
||
| - name: "ociBootVolumeGB" | ||
| source: "env.OCI_BOOT_VOLUME_GB" | ||
| type: "string" | ||
|
|
||
| # Preconditions: look up nodepool and parent cluster from the API | ||
| preconditions: | ||
|
|
||
| # Fetch nodepool details (name, spec, status) | ||
| - name: "nodepoolDetails" | ||
| api_call: | ||
| method: "GET" | ||
| url: "/clusters/{{ .clusterId }}/nodepools/{{ .nodepoolId }}" | ||
| timeout: 10s | ||
| retry_attempts: 3 | ||
| retry_backoff: "exponential" | ||
| capture: | ||
| - name: "nodepoolName" | ||
| field: "name" | ||
| - name: "generation" | ||
| field: "generation" | ||
| - name: "nodepoolSpec" | ||
| field: "spec" | ||
| - name: "nodepoolNotReady" | ||
| expression: | | ||
| !has(status) || !has(status.conditions) | ||
| ? true | ||
| : (status.conditions.filter(c, c.type == "Ready").size() > 0 | ||
| ? status.conditions.filter(c, c.type == "Ready")[0].status != "True" | ||
| : true) | ||
|
|
||
| # Fetch parent cluster details (need the cluster name for clusterName ref) | ||
| - name: "clusterDetails" | ||
| api_call: | ||
| method: "GET" | ||
| url: "/clusters/{{ .clusterId }}" | ||
| timeout: 10s | ||
| retry_attempts: 3 | ||
| retry_backoff: "exponential" | ||
| capture: | ||
| - name: "clusterName" | ||
| field: "name" | ||
|
|
||
| # Check if HostedCluster is Available via adapter-hypershift status | ||
| - name: "clusterAdapterStatus" | ||
| api_call: | ||
| method: "GET" | ||
| url: "/clusters/{{ .clusterId }}/statuses" | ||
| timeout: 10s | ||
| retry_attempts: 3 | ||
| retry_backoff: "exponential" | ||
| capture: | ||
| - name: "clusterAvailable" | ||
| expression: | | ||
| items.filter(s, s.adapter == "adapter-hypershift").size() > 0 | ||
| ? (has(items.filter(s, s.adapter == "adapter-hypershift")[0].conditions) | ||
| ? (items.filter(s, s.adapter == "adapter-hypershift")[0].conditions.filter(c, c.type == "Available").size() > 0 | ||
| ? items.filter(s, s.adapter == "adapter-hypershift")[0].conditions.filter(c, c.type == "Available")[0].status == "True" | ||
| : false) | ||
| : false) | ||
| : false | ||
|
|
||
| - name: "validationCheck" | ||
| # Only proceed if nodepool is NOT Ready AND HostedCluster adapter reports Available | ||
| expression: | | ||
| nodepoolNotReady && clusterAvailable | ||
|
vkareh marked this conversation as resolved.
|
||
|
|
||
| # Resources: NodePool on the remote management cluster | ||
| resources: | ||
|
|
||
| - name: "nodePool" | ||
| transport: | ||
| client: "kubernetes" | ||
| manifest: | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| metadata: | ||
| name: "{{ .clusterName }}-{{ .nodepoolName }}" | ||
| namespace: "{{ .namespace }}" | ||
| labels: | ||
| hyperfleet.io/cluster-id: "{{ .clusterId }}" | ||
| hyperfleet.io/cluster-name: "{{ .clusterName }}" | ||
| hyperfleet.io/nodepool-id: "{{ .nodepoolId }}" | ||
| hyperfleet.io/nodepool-name: "{{ .nodepoolName }}" | ||
| spec: | ||
| clusterName: "{{ .clusterName }}" | ||
| replicas: {{ index .nodepoolSpec "replicas" | default 2 }} | ||
| management: | ||
| autoRepair: true | ||
| upgradeType: Replace | ||
| platform: | ||
| type: OCI | ||
| oci: | ||
| instanceShape: '{{ index .nodepoolSpec "instanceShape" | default .ociShape }}' | ||
| instanceShapeConfig: | ||
| ocpus: {{ index .nodepoolSpec "ocpus" | default .ociOcpus }} | ||
| memoryInGBs: {{ index .nodepoolSpec "memoryInGBs" | default .ociMemoryGBs }} | ||
| availabilityDomain: '{{ index .nodepoolSpec "availabilityDomain" | default .ociAD }}' | ||
| subnetId: '{{ index .nodepoolSpec "subnetId" | default .ociSubnetId }}' | ||
| bootVolumeSize: {{ index .nodepoolSpec "bootVolumeSize" | default .ociBootVolumeGB }} | ||
| release: | ||
| image: '{{ index .nodepoolSpec "releaseImage" | default "quay.io/openshift-release-dev/ocp-release:4.20.2-x86_64" }}' | ||
| discovery: | ||
| namespace: "{{ .namespace }}" | ||
| by_selectors: | ||
| label_selector: | ||
| hyperfleet.io/nodepool-id: "{{ .nodepoolId }}" | ||
|
|
||
| # Post-processing: report NodePool status back to API | ||
| post: | ||
| payloads: | ||
| - name: "statusPayload" | ||
| build: | ||
| adapter: "{{ .adapter.name }}" | ||
| conditions: | ||
| - type: "Applied" | ||
| status: | ||
| expression: | | ||
| has(resources.nodePool.metadata.creationTimestamp) ? "True" : "False" | ||
| reason: | ||
| expression: | | ||
| has(resources.nodePool.metadata.creationTimestamp) ? "NodePoolCreated" : "NodePoolPending" | ||
| message: | ||
| expression: | | ||
| has(resources.nodePool.metadata.creationTimestamp) | ||
| ? "NodePool has been created on the management cluster" | ||
| : "NodePool is pending creation" | ||
| - type: "Available" | ||
| status: | ||
| expression: | | ||
| has(resources.nodePool.status) && has(resources.nodePool.status.conditions) | ||
| ? (resources.nodePool.status.conditions.filter(c, c.type == "Ready").size() > 0 | ||
| ? resources.nodePool.status.conditions.filter(c, c.type == "Ready")[0].status | ||
| : "False") | ||
| : "False" | ||
| reason: | ||
| expression: | | ||
| has(resources.nodePool.status) && has(resources.nodePool.status.conditions) | ||
| ? (resources.nodePool.status.conditions.filter(c, c.type == "Ready").size() > 0 | ||
| ? resources.nodePool.status.conditions.filter(c, c.type == "Ready")[0].reason | ||
| : "WaitingForNodes") | ||
| : "WaitingForNodes" | ||
| message: | ||
| expression: | | ||
| has(resources.nodePool.status) && has(resources.nodePool.status.conditions) | ||
| ? (resources.nodePool.status.conditions.filter(c, c.type == "Ready").size() > 0 | ||
| ? resources.nodePool.status.conditions.filter(c, c.type == "Ready")[0].message | ||
| : "Waiting for worker nodes to be provisioned") | ||
| : "Waiting for worker nodes to be provisioned" | ||
| - type: "Health" | ||
| status: | ||
| expression: | | ||
| adapter.?executionStatus.orValue("") == "success" ? "True" : (adapter.?executionStatus.orValue("") == "failed" ? "False" : "Unknown") | ||
| reason: | ||
| expression: | | ||
| adapter.?errorReason.orValue("") != "" ? adapter.?errorReason.orValue("") : "Healthy" | ||
| message: | ||
| expression: | | ||
| adapter.?errorMessage.orValue("") != "" ? adapter.?errorMessage.orValue("") : "Adapter executed successfully" | ||
| observed_generation: | ||
| expression: "generation" | ||
| observed_time: "{{ now | date \"2006-01-02T15:04:05Z07:00\" }}" | ||
|
|
||
| post_actions: | ||
| - name: "reportNodepoolStatus" | ||
| api_call: | ||
| method: "POST" | ||
| url: "/clusters/{{ .clusterId }}/nodepools/{{ .nodepoolId }}/statuses" | ||
| headers: | ||
| - name: "Content-Type" | ||
| value: "application/json" | ||
| body: "{{ .statusPayload }}" | ||
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| metadata: | ||
| name: "{{ .clusterName }}-{{ .nodepoolName }}" | ||
| namespace: "{{ .namespace }}" | ||
| labels: | ||
| hyperfleet.io/cluster-id: "{{ .clusterId }}" | ||
| hyperfleet.io/cluster-name: "{{ .clusterName }}" | ||
| hyperfleet.io/nodepool-id: "{{ .nodepoolId }}" | ||
| hyperfleet.io/nodepool-name: "{{ .nodepoolName }}" | ||
| spec: | ||
| clusterName: "{{ .clusterName }}" | ||
| replicas: {{ index .nodepoolSpec "replicas" | default 2 }} | ||
| management: | ||
| autoRepair: true | ||
| upgradeType: Replace | ||
| platform: | ||
| type: OCI | ||
| oci: | ||
| instanceShape: "{{ index .nodepoolSpec "instanceShape" | default .ociShape }}" | ||
| instanceShapeConfig: | ||
| ocpus: {{ index .nodepoolSpec "ocpus" | default .ociOcpus }} | ||
| memoryInGBs: {{ index .nodepoolSpec "memoryInGBs" | default .ociMemoryGBs }} | ||
| availabilityDomain: "{{ index .nodepoolSpec "availabilityDomain" | default .ociAD }}" | ||
| subnetId: "{{ index .nodepoolSpec "subnetId" | default .ociSubnetId }}" | ||
| bootVolumeSize: {{ index .nodepoolSpec "bootVolumeSize" | default .ociBootVolumeGB }} | ||
| release: | ||
| image: "{{ index .nodepoolSpec "releaseImage" | default "quay.io/openshift-release-dev/ocp-release:4.20.2-x86_64" }}" | ||
|
vkareh marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.