Skip to content
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

HOSTEDCP-2166: Add ability to set Labels on HCP Pods #5114

Merged
merged 2 commits into from
Nov 22, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
},
{
"name": "OpenStack"
},
{
"name": "HCPPodsLabels"
}
],
"enabled": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
},
{
"name": "OpenStack"
},
{
"name": "HCPPodsLabels"
}
],
"version": ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
},
{
"name": "OpenStack"
},
{
"name": "HCPPodsLabels"
}
],
"enabled": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
},
{
"name": "OpenStack"
},
{
"name": "HCPPodsLabels"
}
],
"version": ""
Expand Down
12 changes: 12 additions & 0 deletions api/hypershift/v1beta1/hosted_controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ type HostedControlPlaneSpec struct {
//
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// labels when specified, define what custom labels are added to the hcp pods.
// Changing this day 2 will cause a rollout of all hcp pods.
// Duplicate keys are not supported. If duplicate keys are defined, only the last key/value pair is preserved.
// Valid values are those in https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
//
// -kubebuilder:validation:XValidation:rule=`self.all(key, size(key) <= 317 && key.matches('^(([A-Za-z0-9]+(\\.[A-Za-z0-9]+)?)*[A-Za-z0-9]\\/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$'))`, message="label key must have two segments: an optional prefix and name, separated by a slash (/). The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between. The prefix is optional. If specified, the prefix must be a DNS subdomain: a series of DNS labels separated by dots (.), not longer than 253 characters in total, followed by a slash (/)"
// -kubebuilder:validation:XValidation:rule=`self.all(key, size(self[key]) <= 63 && self[key].matches('^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$'))`, message="label value must be 63 characters or less (can be empty), consist of alphanumeric characters, dashes (-), underscores (_) or dots (.), and begin and end with an alphanumeric character"
// TODO: key/value validations break cost budget for <=4.17. We should figure why and enable it back.
// +kubebuilder:validation:MaxProperties=20
// +optional
muraee marked this conversation as resolved.
Show resolved Hide resolved
Labels map[string]string `json:"labels,omitempty"`
}

// availabilityPolicy specifies a high level availability policy for components.
Expand Down
13 changes: 13 additions & 0 deletions api/hypershift/v1beta1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,19 @@ type HostedClusterSpec struct {
//
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// labels when specified, define what custom labels are added to the hcp pods.
// Changing this day 2 will cause a rollout of all hcp pods.
// Duplicate keys are not supported. If duplicate keys are defined, only the last key/value pair is preserved.
// Valid values are those in https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
//
// -kubebuilder:validation:XValidation:rule=`self.all(key, size(key) <= 317 && key.matches('^(([A-Za-z0-9]+(\\.[A-Za-z0-9]+)?)*[A-Za-z0-9]\\/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$'))`, message="label key must have two segments: an optional prefix and name, separated by a slash (/). The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between. The prefix is optional. If specified, the prefix must be a DNS subdomain: a series of DNS labels separated by dots (.), not longer than 253 characters in total, followed by a slash (/)"
// -kubebuilder:validation:XValidation:rule=`self.all(key, size(self[key]) <= 63 && self[key].matches('^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$'))`, message="label value must be 63 characters or less (can be empty), consist of alphanumeric characters, dashes (-), underscores (_) or dots (.), and begin and end with an alphanumeric character"
// TODO: key/value validations break cost budget for <=4.17. We should figure why and enable it back.
// +kubebuilder:validation:MaxProperties=20
// +optional
muraee marked this conversation as resolved.
Show resolved Hide resolved
// +openshift:enable:FeatureGate=HCPPodsLabels
Labels map[string]string `json:"labels,omitempty"`
}

// OLMCatalogPlacement is an enum specifying the placement of OLM catalog components.
Expand Down
14 changes: 14 additions & 0 deletions api/hypershift/v1beta1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ hostedclusters.hypershift.openshift.io:
- AROHCPManagedIdentities
- DynamicResourceAllocation
- ExternalOIDC
- HCPPodsLabels
- NetworkDiagnosticsConfig
- OpenStack
FilenameOperatorName: ""
Expand Down
Loading