Skip to content

Commit 7cb9d6a

Browse files
Merge pull request #394 from vr4manta/SPLAT-2297
SPLAT-2297: Added new cmd flag to launch of vSphere CCM
2 parents 040e5a5 + b4030d9 commit 7cb9d6a

9 files changed

Lines changed: 1225 additions & 1 deletion

File tree

pkg/cloud/vsphere/assets/cloud-controller-manager-deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ spec:
6868
value: {{ .globalCredsSecretName }}
6969
- name: ENABLE_ALPHA_DUAL_STACK
7070
value: "true"
71+
- name: ADDITIONAL_NODE_LABELS
72+
value: {{ .additionalLabels }}
7173
resources:
7274
requests:
7375
cpu: 200m
@@ -100,6 +102,9 @@ spec:
100102
--leader-elect-resource-namespace=openshift-cloud-controller-manager \
101103
--feature-gates={{ .featureGates }} \
102104
--use-service-account-credentials=true \
105+
{{- if .additionalLabels }}
106+
--node-labels="$(ADDITIONAL_NODE_LABELS)" \
107+
{{- end}}
103108
--secure-port=0
104109
terminationMessagePolicy: FallbackToLogsOnError
105110
volumeMounts:

pkg/cloud/vsphere/vsphere.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66

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

1920
// see manifests/0000_26_cloud-controller-manager-operator_16_credentialsrequest-vsphere.yaml
2021
globalCredsSecretName = "vsphere-cloud-credentials"
22+
23+
vSpherePlatformTypeLabel = "node.openshift.io/platform-type=vsphere"
2124
)
2225

2326
var (
@@ -45,6 +48,7 @@ var templateValuesValidationMap = map[string]interface{}{
4548
"globalCredsSecretName": "required,type(string)",
4649
"cloudproviderName": "required,type(string)",
4750
"featureGates": "type(string)",
51+
"additionalLabels": "type(string)",
4852
}
4953

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

5963
func getTemplateValues(images *imagesReference, operatorConfig config.OperatorConfig) (common.TemplateValues, error) {
64+
additionalLabels := ""
65+
66+
// We are only going to set the new platform-type node labels if the featuregate is enabled.
67+
if operatorConfig.OCPFeatureGates != nil && operatorConfig.OCPFeatureGates.Enabled(features.FeatureGateVSphereMixedNodeEnv) {
68+
additionalLabels = vSpherePlatformTypeLabel
69+
}
6070
values := common.TemplateValues{
6171
"images": images,
6272
"infrastructureName": operatorConfig.InfrastructureName,
6373
"globalCredsSecretNamespace": operatorConfig.ManagedNamespace,
6474
"globalCredsSecretName": globalCredsSecretName,
6575
"cloudproviderName": operatorConfig.GetPlatformNameString(),
6676
"featureGates": operatorConfig.FeatureGates,
77+
"additionalLabels": additionalLabels,
6778
}
6879
_, err := govalidator.ValidateMap(values, templateValuesValidationMap)
6980
if err != nil {

pkg/cloud/vsphere/vsphere_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import (
44
"testing"
55

66
configv1 "github.com/openshift/api/config/v1"
7+
"github.com/openshift/api/features"
8+
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
79

810
"github.com/stretchr/testify/assert"
911

1012
"github.com/openshift/cluster-cloud-controller-manager-operator/pkg/config"
1113
)
1214

1315
func TestResourcesRenderingSmoke(t *testing.T) {
16+
customFeatureGates := featuregates.NewFeatureGate([]configv1.FeatureGateName{"SomeOtherFeatureGate", features.FeatureGateVSphereMixedNodeEnv}, nil)
1417

1518
tc := []struct {
1619
name string
@@ -41,6 +44,18 @@ func TestResourcesRenderingSmoke(t *testing.T) {
4144
PlatformStatus: &configv1.PlatformStatus{Type: configv1.VSpherePlatformType},
4245
InfrastructureName: "infra",
4346
},
47+
}, {
48+
name: "FeatureGate FeatureGateVSphereMixedNodeEnv=true results in node-labels generated without error",
49+
config: config.OperatorConfig{
50+
ManagedNamespace: "my-cool-namespace",
51+
ImagesReference: config.ImagesReference{
52+
CloudControllerManagerVSphere: "CloudControllerManagerVsphere",
53+
},
54+
PlatformStatus: &configv1.PlatformStatus{Type: configv1.VSpherePlatformType},
55+
InfrastructureName: "infra",
56+
FeatureGates: "FeatureGateVSphereMixedNodeEnv=true",
57+
OCPFeatureGates: customFeatureGates,
58+
},
4459
},
4560
}
4661

pkg/config/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type OperatorConfig struct {
4040
PlatformStatus *configv1.PlatformStatus
4141
ClusterProxy *configv1.Proxy
4242
FeatureGates string
43+
OCPFeatureGates featuregates.FeatureGate
4344
}
4445

4546
func (cfg *OperatorConfig) GetPlatformNameString() string {
@@ -97,8 +98,10 @@ func ComposeConfig(infrastructure *configv1.Infrastructure, clusterProxy *config
9798
klog.Errorf("Unable to get upstream feature gates: %s", err)
9899
return OperatorConfig{}, fmt.Errorf("unable to get upstream feature gates: %w", err)
99100
}
101+
102+
var features featuregates.FeatureGate
100103
if featureGateAccessor != nil {
101-
features, _ := featureGateAccessor.CurrentFeatureGates()
104+
features, _ = featureGateAccessor.CurrentFeatureGates()
102105
enabled, _ := util.GetEnabledDisabledFeatures(features, upstreamGates)
103106
featureGatesString = util.BuildFeatureGateString(enabled, nil)
104107
}
@@ -111,6 +114,7 @@ func ComposeConfig(infrastructure *configv1.Infrastructure, clusterProxy *config
111114
InfrastructureName: infrastructure.Status.InfrastructureName,
112115
IsSingleReplica: infrastructure.Status.ControlPlaneTopology == configv1.SingleReplicaTopologyMode,
113116
FeatureGates: featureGatesString,
117+
OCPFeatureGates: features,
114118
}
115119

116120
return config, nil

pkg/config/config_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ func TestComposeConfig(t *testing.T) {
235235
// longer appears in the features package linked above. You'll need to
236236
// choose something present in the vendored k8s version.
237237
FeatureGates: "CloudControllerManagerWebhook=true",
238+
OCPFeatureGates: featuregates.NewFeatureGate(
239+
[]configv1.FeatureGateName{"CloudControllerManagerWebhook", "ChocobombVanilla", "ChocobombStrawberry"},
240+
[]configv1.FeatureGateName{"ChocobombBlueberry", "ChocobombBanana"},
241+
),
238242
},
239243
}, {
240244
name: "Empty infrastructure should return error",

0 commit comments

Comments
 (0)