Skip to content

Enable OpenShift cluster deployment via Pulumi on GCP and local environments - #1591

Merged
shaina-patel-23 merged 16 commits into
mainfrom
CONTINT-4727/Shaina/Openshift-infra-type
Jul 17, 2025
Merged

Enable OpenShift cluster deployment via Pulumi on GCP and local environments#1591
shaina-patel-23 merged 16 commits into
mainfrom
CONTINT-4727/Shaina/Openshift-infra-type

Conversation

@shaina-patel-23

@shaina-patel-23 shaina-patel-23 commented Jun 20, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR introduces support for provisioning an OpenShift cluster via Pulumi. More specifically, it adds:

  • A new component NewOpenShiftCluster in components/kubernetes/openshift.go to provision an Openshift cluster on a remote VM.
  • A local version NewLocalCRCCLuster for testing CRC clusters locally
  • A new scenario gcp/openshiftvm that provisions a GCP VM with nested virtualization and deploys an OpenShift cluster on it
  • Enhancements to GCP VM provisioning in resources/gcp/compute/vm.go to support:
    • Nested virtualization
    • Larger disk size needed by CRC
  • Helper options in scenations/gcp/compute/vmargs.go for setting custom OS descriptors

Which scenarios this will impact?

  • Introduces a new GCP scenario: gcp\openshiftvm, available in the ScenarioRegistry

Motivation

  • Lays the groundwork for e2e testing of the Agent on an OpenShift cluster
  • Aligns OpenShift testing with the patterns already in place for EKS, GKE, etc.

Usage

  • Download and export you pull secret:
  • Use invoke commands
    • Run invoke setup and set the pull secret path using it. Then run invoke gcp.create-openshift and invoke gcp.destroy-openshift
    • Or just run invoke gcp.create-openshift -p <pull_secret_path> and invoke gcp.destroy-openshift

Additional Notes

  • Manual verification steps for the cluster are:

    • SSH into the VM on GCP after pulumi up command completes successfully
    • Enable OC: eval $(crc oc-env)
    • Login as kubeadmin: oc login -u kubeadmin https://api.crc.testing:6443 (password retrieved from cat ~/.crc/machines/crc/kubeadmin-password)
    • Verify cluster: oc get nodes
  • The instance type n2-standard-8 was chosen because CRC requires at least 4 vCPUs and 9 GiB of RAM to function, and n2-standard-8 provides 8 vCPUs and 32 GiB of memory; additionally, it supports nested virtualization, which is needed for running CRC inside a VM on GCP

@shaina-patel-23 shaina-patel-23 changed the title Contint 4727/shaina/openshift infra type Enable OpenShift cluster deployment via Pulumi on GCP and local environments Jun 26, 2025
@shaina-patel-23
shaina-patel-23 marked this pull request as ready for review July 2, 2025 19:40
@shaina-patel-23
shaina-patel-23 requested a review from a team as a code owner July 2, 2025 19:40
Comment thread components/kubernetes/openshift.go Outdated
Comment thread components/kubernetes/openshift.go Outdated
Comment thread components/kubernetes/openshift.go Outdated
Comment thread components/kubernetes/openshift.go Outdated
Comment thread components/kubernetes/openshift.go Outdated
shaina-patel-23 and others added 2 commits July 3, 2025 12:47
Co-authored-by: Lénaïc Huard <L3n41c@users.noreply.github.com>
…t open: Permission denied errors I recieved when testing locally
Comment thread components/kubernetes/openshift.go Outdated
OSCommand: command.NewUnixOSCommand(),
})

pullSecretPath := os.Getenv("PULL_SECRET_PATH")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need it to be passed as an environment variable? Can we make it a params of the function instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the setup too use function params instead of env variables by reading the pull secret path from Pulumi config in openshift.go, adding support for invoke gcp.create-openshift.go in tasks/gcp/openshift.py, and updating setup.py to optionally prompt for the path in invoke setup

Comment thread components/kubernetes/openshift.go Outdated
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func NewLocalOpenShiftCluster(env config.Env, name string, opts ...pulumi.ResourceOption) (*Cluster, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the condition to be able to run that locally? Is it working on MacOS laptops?

@shaina-patel-23 shaina-patel-23 Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a commit where I ran the function and confirmed it worked on macOS. I modeled this after the unused NewLocalKindCluster setup. In both situations the local setups aren't referenced anywhere, so I'm fine with removing it if you think that's appropriate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the NewLocalKindCluster setup is used in a provisioner on datadog-agent side: https://github.com/DataDog/datadog-agent/blob/main/test/new-e2e/pkg/provisioners/local/kubernetes/kind.go#L132
The goal is provide a local setup that allows you to iterate faster when creating a test for the first time

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. I’ve implemented functionality for passing the pull secret as a parameter for both the local cluster and cluster on GCP. However, I didn’t add an invoke command for the local cluster creation to keep consistency with other cluster types. For the datadog-agent integration, I anticipate needing to adapt the pull secret config approach. Currently, the GCP OpenShift cluster receives the pull secret through the invoke setup process, but the datadog-agent environment may require a different configuration pattern. I’d appreciate any guidance for how to handle that…

Comment thread resources/gcp/compute/vm.go Outdated
Comment on lines +29 to +30
AllowStoppingForUpdate: pulumi.Bool(true),
AdvancedMachineFeatures: &compute.InstanceAdvancedMachineFeaturesArgs{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these ones supported for all the machine types? I know that on AWS you can only enable nested virtualization on specific machines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On GCP, nested virtualization is only supported on specific machine types like N1, N2, etc., and not on E2 or shared-core instances. I chose n2-standard-8 to meet vCPU and memory needs for CRC. Also, it also supports nested virtualization, which is needed to run CRC inside a VM on GCP.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case what happens if we set instanceType to a type that does not support nested virtualization? Your change enforce the NestedVirtualization to be enabled all the time, so I am afraid it will break when some instance type are used. Maybe we should make it configurable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve addressed the nested virt concern by making the feature configurable. EnableNestedVirtualization now defaults to false for all GCP VM instances, with the OpenShift scenario setting it to true. I also removed the AllowStoppingForUpdate setting as I had added it only for testing. Also dropped the new WithInstanceType function I introduced in vmargs.go after realizing I could leverage the existing ddinfra:gcp/defaultInstanceType configuration.

Comment thread scenarios/gcp/openshiftvm/run.go Outdated
package openshiftvm

import (
localKubernetes "github.com/DataDog/test-infra-definitions/components/kubernetes"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not alias it localKubernetes here, because it actually create the openshift cluster in a remote VM on GCP

Comment thread tasks/gcp/openshift.py Outdated
"scenario": scenario_name,
"ddinfra:env": f"gcp/{cfg.get_gcp().account}",
"ddinfra:gcp/defaultPublicKeyPath": cfg.get_gcp().publicKeyPath,
"ddinfra:openShiftPullSecretPath": pull_secret_path,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call the parameter ddinfra:gcp/openshift/pullSecretPath since it is related to GCP and openshift only.
with that you will need to add that parameter here: https://github.com/DataDog/test-infra-definitions/blob/main/resources/gcp/environment.go#L28
And create the corresponding helper funcition to retrieve that parameter from the Pulumi config map, for example: https://github.com/DataDog/test-infra-definitions/blob/main/resources/gcp/environment.go#L159C1-L162C2.
You should then be able to use that helper in openshiftvm/run.go to retrieve the image pull secret parameters, and pass it to NewOpenShiftCluster function that creates the openshift cluster component

@CelianR CelianR left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, verified that all comments are addressed. This one is remaining but is not a blocker and could be part of a future PR if necessary

@shaina-patel-23
shaina-patel-23 merged commit 9b3b4e3 into main Jul 17, 2025
8 checks passed
@shaina-patel-23
shaina-patel-23 deleted the CONTINT-4727/Shaina/Openshift-infra-type branch July 17, 2025 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants