Skip to content

[WIP] SPLAT-2297: Added new cmd flag to launch of vSphere CCM #394

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/golangci/golangci-lint v1.62.2
github.com/onsi/ginkgo/v2 v2.22.2
github.com/onsi/gomega v1.36.2
github.com/openshift/api v0.0.0-20250128061932-d2791f98ff08
github.com/openshift/api v0.0.0-20250620092249-a8cbc218cd2c
github.com/openshift/client-go v0.0.0-20250125113824-8e1f0b8fa9a7
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20250122171707-86066d47a264
github.com/openshift/library-go v0.0.0-20250127111945-0f76e23726cd
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ github.com/onsi/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU
github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cTyztHwsk=
github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY=
github.com/openshift/api v0.0.0-20250128061932-d2791f98ff08 h1:GtCVszgqW3rmgyO8eWX/0UbfTirBNRTK9jFfZ/3Y9hQ=
github.com/openshift/api v0.0.0-20250128061932-d2791f98ff08/go.mod h1:yk60tHAmHhtVpJQo3TwVYq2zpuP70iJIFDCmeKMIzPw=
github.com/openshift/api v0.0.0-20250620092249-a8cbc218cd2c h1:0Np840IRyzpvHLWxcE1AZ8sttVZe+a3Y6QBS3Ge+umA=
github.com/openshift/api v0.0.0-20250620092249-a8cbc218cd2c/go.mod h1:yk60tHAmHhtVpJQo3TwVYq2zpuP70iJIFDCmeKMIzPw=
github.com/openshift/client-go v0.0.0-20250125113824-8e1f0b8fa9a7 h1:4iliLcvr1P9EUMZgIaSNEKNQQzBn+L6PSequlFOuB6Q=
github.com/openshift/client-go v0.0.0-20250125113824-8e1f0b8fa9a7/go.mod h1:2tcufBE4Cu6RNgDCxcUJepa530kGo5GFVfR9BSnndhI=
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20250122171707-86066d47a264 h1:KoJiId8Ynajf/ZFodvmayFkDODIL7Vow3LmgR5+oVRg=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ spec:
value: {{ .globalCredsSecretName }}
- name: ENABLE_ALPHA_DUAL_STACK
value: "true"
- name: ADDITIONAL_NODE_LABELS
value: {{ .additionalLabels }}
resources:
requests:
cpu: 200m
Expand Down Expand Up @@ -99,7 +101,8 @@ spec:
--leader-elect-retry-period=26s \
--leader-elect-resource-namespace=openshift-cloud-controller-manager \
--feature-gates={{ .featureGates }} \
--use-service-account-credentials=true
--use-service-account-credentials=true \
--node-labels=$(ADDITIONAL_NODE_LABELS)
terminationMessagePolicy: FallbackToLogsOnError
volumeMounts:
- name: host-etc-kube
Expand Down
11 changes: 11 additions & 0 deletions pkg/cloud/vsphere/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/asaskevich/govalidator"
"github.com/openshift/api/features"
appsv1 "k8s.io/api/apps/v1"
rbacv1 "k8s.io/api/rbac/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -18,6 +19,8 @@ const (

// see manifests/0000_26_cloud-controller-manager-operator_16_credentialsrequest-vsphere.yaml
globalCredsSecretName = "vsphere-cloud-credentials"

vSpherePlatformTypeLabel = "node.openshift.io/platform-type=vsphere"
)

var (
Expand Down Expand Up @@ -45,6 +48,7 @@ var templateValuesValidationMap = map[string]interface{}{
"globalCredsSecretName": "required,type(string)",
"cloudproviderName": "required,type(string)",
"featureGates": "type(string)",
"additionalLabels": "type(string)",
}

type vsphereAssets struct {
Expand All @@ -57,13 +61,20 @@ func (assets *vsphereAssets) GetRenderedResources() []client.Object {
}

func getTemplateValues(images *imagesReference, operatorConfig config.OperatorConfig) (common.TemplateValues, error) {
additionalLabels := ""

// We are only going to set the new platform-type node labels if the featuregate is enabled.
if operatorConfig.OCPFeatureGates.Enabled(features.FeatureGateVSphereMixedNodeEnv) {
additionalLabels = vSpherePlatformTypeLabel
}
values := common.TemplateValues{
"images": images,
"infrastructureName": operatorConfig.InfrastructureName,
"globalCredsSecretNamespace": operatorConfig.ManagedNamespace,
"globalCredsSecretName": globalCredsSecretName,
"cloudproviderName": operatorConfig.GetPlatformNameString(),
"featureGates": operatorConfig.FeatureGates,
"additionalLabels": additionalLabels,
}
_, err := govalidator.ValidateMap(values, templateValuesValidationMap)
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions pkg/cloud/vsphere/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ func TestResourcesRenderingSmoke(t *testing.T) {
PlatformStatus: &configv1.PlatformStatus{Type: configv1.VSpherePlatformType},
InfrastructureName: "infra",
},
}, {
name: "FeatureGate FeatureGateVSphereMixedNodeEnv=true results in node-labels generated without error",
config: config.OperatorConfig{
ManagedNamespace: "my-cool-namespace",
ImagesReference: config.ImagesReference{
CloudControllerManagerVSphere: "CloudControllerManagerVsphere",
},
PlatformStatus: &configv1.PlatformStatus{Type: configv1.VSpherePlatformType},
InfrastructureName: "infra",
FeatureGates: "FeatureGateVSphereMixedNodeEnv=true",
},
},
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type OperatorConfig struct {
PlatformStatus *configv1.PlatformStatus
ClusterProxy *configv1.Proxy
FeatureGates string
OCPFeatureGates featuregates.FeatureGate
}

func (cfg *OperatorConfig) GetPlatformNameString() string {
Expand Down Expand Up @@ -97,11 +98,14 @@ func ComposeConfig(infrastructure *configv1.Infrastructure, clusterProxy *config
klog.Errorf("Unable to get upstream feature gates: %s", err)
return OperatorConfig{}, fmt.Errorf("unable to get upstream feature gates: %w", err)
}

var features featuregates.FeatureGate
if featureGateAccessor != nil {
features, _ := featureGateAccessor.CurrentFeatureGates()
features, _ = featureGateAccessor.CurrentFeatureGates()
enabled, _ := util.GetEnabledDisabledFeatures(features, upstreamGates)
featureGatesString = util.BuildFeatureGateString(enabled, nil)
}
fmt.Printf("Generated feature gates string: %s\n", featureGatesString)

config := OperatorConfig{
PlatformStatus: infrastructure.Status.PlatformStatus.DeepCopy(),
Expand All @@ -111,6 +115,7 @@ func ComposeConfig(infrastructure *configv1.Infrastructure, clusterProxy *config
InfrastructureName: infrastructure.Status.InfrastructureName,
IsSingleReplica: infrastructure.Status.ControlPlaneTopology == configv1.SingleReplicaTopologyMode,
FeatureGates: featureGatesString,
OCPFeatureGates: features,
}

return config, nil
Expand Down
8 changes: 5 additions & 3 deletions vendor/github.com/openshift/api/.golangci.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/openshift/api/Dockerfile.ocp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion vendor/github.com/openshift/api/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions vendor/github.com/openshift/api/OWNERS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/openshift/api/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion vendor/github.com/openshift/api/cloudnetwork/v1/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/github.com/openshift/api/config/install.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion vendor/github.com/openshift/api/config/v1/types_apiserver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading