Skip to content

Commit

Permalink
Merge pull request #108 from openshift-cherrypick-robot/cherry-pick-1…
Browse files Browse the repository at this point in the history
…07-to-release-4.13

[release-4.13] OCPBUGS-10967: feat: add workload annotations
  • Loading branch information
openshift-merge-robot committed Mar 29, 2023
2 parents eb2c1be + 90b1e71 commit ce1c9a3
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions assets/core-capi/core-cluster-api.yaml
Expand Up @@ -20,6 +20,8 @@ data:
strategy: {}
template:
metadata:
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
creationTimestamp: null
labels:
cluster.x-k8s.io/provider: cluster-api
Expand Down
1 change: 1 addition & 0 deletions assets/infrastructure-providers/infrastructure-aws.yaml
Expand Up @@ -22,6 +22,7 @@ data:
metadata:
annotations:
iam.amazonaws.com/role: ${AWS_CONTROLLER_IAM_ROLE:=""}
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
creationTimestamp: null
labels:
cluster.x-k8s.io/provider: infrastructure-aws
Expand Down
1 change: 1 addition & 0 deletions assets/infrastructure-providers/infrastructure-azure.yaml
Expand Up @@ -23,6 +23,7 @@ data:
metadata:
annotations:
kubectl.kubernetes.io/default-container: manager
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
creationTimestamp: null
labels:
aadpodidbinding: capz-controller-aadpodidentity-selector
Expand Down
1 change: 1 addition & 0 deletions assets/infrastructure-providers/infrastructure-gcp.yaml
Expand Up @@ -22,6 +22,7 @@ data:
metadata:
annotations:
kubectl.kubernetes.io/default-container: manager
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
creationTimestamp: null
labels:
cluster.x-k8s.io/provider: infrastructure-gcp
Expand Down
2 changes: 2 additions & 0 deletions assets/infrastructure-providers/infrastructure-ibmcloud.yaml
Expand Up @@ -46,6 +46,8 @@ data:
strategy: {}
template:
metadata:
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
creationTimestamp: null
labels:
cluster.x-k8s.io/provider: infrastructure-ibmcloud
Expand Down
23 changes: 23 additions & 0 deletions hack/assets/customizations.go
Expand Up @@ -34,6 +34,15 @@ var (
"include.release.openshift.io/self-managed-high-availability": "true",
"include.release.openshift.io/single-node-developer": "true",
}

// Workload annotations are used by the workload admission webhook to modify pod
// resources and correctly schedule them while also pinning them to specific CPUSets.
// See for more info:
// https://github.com/openshift/enhancements/blob/master/enhancements/workload-partitioning/wide-availability-workload-partitioning.md
openshiftWorkloadAnnotation = map[string]string{
"target.workload.openshift.io/management": `{"effect": "PreferredDuringScheduling"}`,
}

techPreviewAnnotation = "release.openshift.io/feature-set"
techPreviewAnnotationValue = "TechPreviewNoUpgrade"

Expand Down Expand Up @@ -214,6 +223,8 @@ func customizeDeployments(obj *unstructured.Unstructured) {
}
deployment.Spec.Template.Spec.PriorityClassName = "system-cluster-critical"

deployment.Spec.Template.Annotations = mergeMaps(deployment.Spec.Template.Annotations, openshiftWorkloadAnnotation)

for i := range deployment.Spec.Template.Spec.Containers {
container := &deployment.Spec.Template.Spec.Containers[i]
// Add resource requests
Expand Down Expand Up @@ -312,3 +323,15 @@ func fetchAndCompileComponents(url string) ([]byte, error) {

return m.AsYaml()
}

// Variadic function to merge maps of like kind.
// Note: keys of next map will override keys in previous map if previous map contains same key.
func mergeMaps[K comparable, V any](maps ...map[K]V) map[K]V {
result := map[K]V{}
for _, m := range maps {
for k, v := range m {
result[k] = v
}
}
return result
}
2 changes: 2 additions & 0 deletions manifests/0000_30_cluster-api_11_deployment.upstream.yaml
Expand Up @@ -25,6 +25,8 @@ spec:
strategy: {}
template:
metadata:
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
creationTimestamp: null
labels:
clusterctl.cluster.x-k8s.io/core: capi-operator
Expand Down

0 comments on commit ce1c9a3

Please sign in to comment.