Skip to content

Commit 32981f9

Browse files
Merge pull request #2567 from muraee/hcp-labels
OCPBUGS-44950: Propagate HCP pods labels to 2nd level operands
2 parents e750244 + a4543ea commit 32981f9

File tree

10 files changed

+33
-0
lines changed

10 files changed

+33
-0
lines changed

bindata/cloud-network-config-controller/managed/controller.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ spec:
3434
component: network
3535
type: infra
3636
openshift.io/component: network
37+
{{ if .HCPLabels }}
38+
{{ range $key, $value := .HCPLabels }}
39+
"{{$key}}": "{{$value}}"
40+
{{ end }}
41+
{{ end }}
3742
spec:
3843
automountServiceAccountToken: false
3944
affinity:

bindata/network/multus-admission-controller/admission-controller.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ spec:
4646
{{- if .HyperShiftEnabled}}
4747
hypershift.openshift.io/hosted-control-plane: {{.AdmissionControllerNamespace}}
4848
hypershift.openshift.io/control-plane: "true"
49+
{{ if .HCPLabels }}
50+
{{ range $key, $value := .HCPLabels }}
51+
"{{$key}}": "{{$value}}"
52+
{{ end }}
53+
{{ end }}
4954
{{- end }}
5055
component: network
5156
type: infra

bindata/network/node-identity/managed/node-identity.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ spec:
4040
hypershift.openshift.io/hosted-control-plane: {{.HostedClusterNamespace}}
4141
hypershift.openshift.io/control-plane: "true"
4242
kubernetes.io/os: "linux"
43+
{{ if .HCPLabels }}
44+
{{ range $key, $value := .HCPLabels }}
45+
"{{$key}}": "{{$value}}"
46+
{{ end }}
47+
{{ end }}
4348
spec:
4449
affinity:
4550
nodeAffinity:

bindata/network/ovn-kubernetes/managed/ovnkube-control-plane.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ spec:
4242
hypershift.openshift.io/control-plane: "true"
4343
hypershift.openshift.io/hosted-control-plane: {{.HostedClusterNamespace}}
4444
kubernetes.io/os: "linux"
45+
{{ if .HCPLabels }}
46+
{{ range $key, $value := .HCPLabels }}
47+
"{{$key}}": "{{$value}}"
48+
{{ end }}
49+
{{ end }}
4550
spec:
4651
affinity:
4752
nodeAffinity:

pkg/bootstrap/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type OVNHyperShiftBootstrapResult struct {
1212
ClusterID string
1313
Namespace string
1414
HCPNodeSelector map[string]string
15+
HCPLabels map[string]string
1516
HCPTolerations []string
1617
ControlPlaneReplicas int
1718
ReleaseImage string

pkg/hypershift/hypershift.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type HostedControlPlane struct {
5858
ClusterID string
5959
ControllerAvailabilityPolicy AvailabilityPolicy
6060
NodeSelector map[string]string
61+
Labels map[string]string
6162
Tolerations []string
6263
AdvertiseAddress string
6364
AdvertisePort int
@@ -155,6 +156,11 @@ func ParseHostedControlPlane(hcp *unstructured.Unstructured) (*HostedControlPlan
155156
return nil, fmt.Errorf("failed extract nodeSelector: %v", err)
156157
}
157158

159+
labels, _, err := unstructured.NestedStringMap(hcp.UnstructuredContent(), "spec", "labels")
160+
if err != nil {
161+
return nil, fmt.Errorf("failed to extract labels: %v", err)
162+
}
163+
158164
var tolerations []corev1.Toleration
159165
var tolerationsYaml []string
160166
tolerationsArray, tolerationsArrayFound, err := unstructured.NestedFieldCopy(hcp.UnstructuredContent(), "spec", "tolerations")
@@ -253,6 +259,7 @@ func ParseHostedControlPlane(hcp *unstructured.Unstructured) (*HostedControlPlan
253259
ControllerAvailabilityPolicy: AvailabilityPolicy(controllerAvailabilityPolicy),
254260
ClusterID: clusterID,
255261
NodeSelector: nodeSelector,
262+
Labels: labels,
256263
Tolerations: tolerationsYaml,
257264
AdvertiseAddress: advertiseAddress,
258265
AdvertisePort: int(advertisePort),

pkg/network/cloud_network.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func renderCloudNetworkConfigController(conf *operv1.NetworkSpec, bootstrapResul
9595
data.Data["HostedClusterNamespace"] = hcpCfg.Namespace
9696
data.Data["ReleaseImage"] = hcpCfg.ReleaseImage
9797
data.Data["HCPNodeSelector"] = cloudBootstrapResult.HostedControlPlane.NodeSelector
98+
data.Data["HCPLabels"] = cloudBootstrapResult.HostedControlPlane.Labels
9899
data.Data["HCPTolerations"] = cloudBootstrapResult.HostedControlPlane.Tolerations
99100
data.Data["RunAsUser"] = hcpCfg.RunAsUser
100101
// In HyperShift CloudNetworkConfigController is deployed as a part of the hosted cluster controlplane

pkg/network/multus_admission_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func renderMultusAdmissonControllerConfig(manifestDir string, externalControlPla
113113
data.Data["ClusterIDLabel"] = hypershift.ClusterIDLabel
114114
data.Data["ClusterID"] = bootstrapResult.Infra.HostedControlPlane.ClusterID
115115
data.Data["HCPNodeSelector"] = bootstrapResult.Infra.HostedControlPlane.NodeSelector
116+
data.Data["HCPLabels"] = bootstrapResult.Infra.HostedControlPlane.Labels
116117
data.Data["HCPTolerations"] = bootstrapResult.Infra.HostedControlPlane.Tolerations
117118
data.Data["PriorityClass"] = bootstrapResult.Infra.HostedControlPlane.PriorityClass
118119

pkg/network/node_identity.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func renderNetworkNodeIdentity(conf *operv1.NetworkSpec, bootstrapResult *bootst
100100
data.Data["TokenMinterImage"] = os.Getenv("TOKEN_MINTER_IMAGE")
101101
data.Data["TokenAudience"] = os.Getenv("TOKEN_AUDIENCE")
102102
data.Data["HCPNodeSelector"] = bootstrapResult.Infra.HostedControlPlane.NodeSelector
103+
data.Data["HCPLabels"] = bootstrapResult.Infra.HostedControlPlane.Labels
103104
data.Data["HCPTolerations"] = bootstrapResult.Infra.HostedControlPlane.Tolerations
104105

105106
data.Data["NetworkNodeIdentityImage"] = hcpCfg.ControlPlaneImage // OVN_CONTROL_PLANE_IMAGE

pkg/network/ovn_kubernetes.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ func renderOVNKubernetes(conf *operv1.NetworkSpec, bootstrapResult *bootstrap.Bo
231231
data.Data["ClusterID"] = bootstrapResult.OVN.OVNKubernetesConfig.HyperShiftConfig.ClusterID
232232
data.Data["ClusterIDLabel"] = hypershift.ClusterIDLabel
233233
data.Data["HCPNodeSelector"] = bootstrapResult.OVN.OVNKubernetesConfig.HyperShiftConfig.HCPNodeSelector
234+
data.Data["HCPLabels"] = bootstrapResult.OVN.OVNKubernetesConfig.HyperShiftConfig.HCPLabels
234235
data.Data["HCPTolerations"] = bootstrapResult.OVN.OVNKubernetesConfig.HyperShiftConfig.HCPTolerations
235236
data.Data["OVN_NB_INACTIVITY_PROBE"] = nb_inactivity_probe
236237
data.Data["OVN_CERT_CN"] = OVN_CERT_CN
@@ -724,6 +725,7 @@ func bootstrapOVNHyperShiftConfig(hc *hypershift.HyperShiftConfig, kubeClient cn
724725

725726
ovnHypershiftResult.ClusterID = hcp.ClusterID
726727
ovnHypershiftResult.HCPNodeSelector = hcp.NodeSelector
728+
ovnHypershiftResult.HCPLabels = hcp.Labels
727729
ovnHypershiftResult.HCPTolerations = hcp.Tolerations
728730

729731
switch hcp.ControllerAvailabilityPolicy {

0 commit comments

Comments
 (0)