Skip to content

Commit 8a33935

Browse files
authored
Add topology crd to the installation (#292)
1 parent 59bed26 commit 8a33935

File tree

16 files changed

+223
-6
lines changed

16 files changed

+223
-6
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ test: envtest-docker-go
2727

2828
.PHONY: build
2929
build: $(SERVICE_NAMES)
30+
$(MAKE) docker-build-crd-upgrader
3031

3132
$(SERVICE_NAMES):
3233
$(MAKE) build-go SERVICE_NAME=$@
@@ -57,7 +58,7 @@ gen-license: addlicense
5758

5859
.PHONY: manifests
5960
manifests: controller-gen kustomize ## Generate ClusterRole and CustomResourceDefinition objects.
60-
$(CONTROLLER_GEN) crd:allowDangerousTypes=true,generateEmbeddedObjectMeta=true,headerFile="./hack/boilerplate.yaml.txt" paths="./pkg/apis/..." output:crd:artifacts:config=deployments/kai-scheduler/crds
61+
$(CONTROLLER_GEN) crd:allowDangerousTypes=true,generateEmbeddedObjectMeta=true,headerFile="./hack/boilerplate.yaml.txt" paths="./pkg/apis/..." output:crd:artifacts:config=deployments/crds/internal
6162
$(CONTROLLER_GEN) rbac:roleName=kai-podgrouper,headerFile="./hack/boilerplate.yaml.txt" paths="./pkg/podgrouper/..." paths="./cmd/podgrouper/..." output:stdout > deployments/kai-scheduler/templates/rbac/podgrouper.yaml
6263
$(CONTROLLER_GEN) rbac:roleName=kai-binder,headerFile="./hack/boilerplate.yaml.txt" paths="./pkg/binder/..." paths="./cmd/binder/..." output:stdout > deployments/kai-scheduler/templates/rbac/binder.yaml
6364
$(CONTROLLER_GEN) rbac:roleName=kai-resource-reservation,headerFile="./hack/boilerplate.yaml.txt" paths="./pkg/resourcereservation/..." paths="./cmd/resourcereservation/..." output:stdout > deployments/kai-scheduler/templates/rbac/resourcereservation.yaml

NOTICE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8737,6 +8737,10 @@ This project was originally forked from kube-batch in 2019, therefore it include
87378737
Copyright (c) The Kubernetes Authors.
87388738
This project includes components derived from kube-batch, originally developed by The Kubernetes Authors.
87398739

8740+
This project includes components from kueue, which is licensed under the Apache License, Version 2.0.
8741+
Copyright (c) The Kubernetes Authors.
8742+
This project includes components derived from kueue, originally developed by The Kubernetes Authors.
8743+
87408744
pkg/common/k8s_utils/framework_handle.go file was forked from volcano-sh/volcano, which is licensed under the Apache License, Version 2.0.
87418745
Copyright 2020 The Volcano Authors.
87428746
This file was originally developed by the Volcano Authors.

build/makefile/base.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SUCCESS_MESSAGE_HANDLER=(${ECHO_COMMAND} ${GREEN_CONSOLE} "${CONSOLE_PREFIX} Suc
99

1010
DOCKER_SOCK_PATH=/var/run/docker.sock
1111
DOCKERFILE_PATH=./Dockerfile
12+
CRD_UPGRADER_DOCKERFILE_PATH=./deployments/crds/crd-upgrader/Dockerfile
1213

1314
DOCKER_TAG?=0.0.0
1415
VERSION?=${DOCKER_TAG}
@@ -52,6 +53,10 @@ builder:
5253
DOCKER_BUILDKIT=1 docker buildx build -f build/builder/Dockerfile --load -t builder:${GO_IMAGE_VERSION} .
5354
.PHONY: builder
5455

56+
docker-build-crd-upgrader:
57+
$(MAKE) docker-build-generic DOCKERFILE_PATH=${CRD_UPGRADER_DOCKERFILE_PATH} DOCKER_BUILD_ADDITIONAL_ARGS="" SERVICE_NAME="crd-upgrader"
58+
.PHONY: docker-build-crd-upgrader
59+
5560
docker-build-generic:
5661
DOCKER_BUILDKIT=1 docker buildx build ${DOCKER_BUILD_ADDITIONAL_ARGS} --build-arg SERVICE_NAME=${SERVICE_NAME} -f ${DOCKERFILE_PATH} -t ${DOCKER_IMAGE_NAME} ${DOCKER_BUILDX_ADDITIONAL_ARGS} --platform ${DOCKER_BUILD_PLATFORM} .
5762
.PHONY: docker-build-generic
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2025 NVIDIA CORPORATION
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
FROM registry.access.redhat.com/ubi9/ubi-minimal
5+
ARG TARGETARCH
6+
ENV TARGETARCH=$TARGETARCH
7+
RUN curl -o kubectl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/$TARGETARCH/kubectl" \
8+
&& chmod +x kubectl && mv kubectl /usr/bin/kubectl
9+
10+
11+
COPY deployments/crds/internal /internal-crds
12+
COPY deployments/crds/external /external-crds
13+
COPY NOTICE .
14+
COPY deployments/crds/crd-upgrader/apply-crds.sh /apply-crds.sh
15+
RUN chmod +x /apply-crds.sh
16+
17+
USER 65532:65532
18+
19+
CMD ["/apply-crds.sh"]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
# Copyright 2025 NVIDIA CORPORATION
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
6+
# Using --force-conflicts to claim ownership of the CRDs from helm
7+
kubectl apply --server-side=true --force-conflicts -f /internal-crds
8+
9+
# Check and apply external CRDs only if they don't already exist in the cluster
10+
for crd_file in /external-crds/*.yaml; do
11+
if [ -f "$crd_file" ]; then
12+
# Extract CRD name from the file
13+
crd_name=$(grep "^ name:" "$crd_file" | head -1 | awk '{print $2}')
14+
if [ -n "$crd_name" ]; then
15+
# Check if CRD already exists in the cluster
16+
if kubectl get crd "$crd_name" >/dev/null 2>&1; then
17+
echo "CRD $crd_name already exists in cluster, skipping..."
18+
else
19+
echo "Applying CRD $crd_name..."
20+
kubectl apply --server-side=true -f "$crd_file"
21+
fi
22+
else
23+
echo "Warning: Could not extract CRD name from $crd_file"
24+
fi
25+
fi
26+
done
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Copyright The Kubernetes Authors.
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
3+
#
4+
# http://www.apache.org/licenses/LICENSE-2.0
5+
#
6+
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
7+
apiVersion: apiextensions.k8s.io/v1
8+
kind: CustomResourceDefinition
9+
metadata:
10+
annotations:
11+
controller-gen.kubebuilder.io/version: v0.18.0
12+
name: topologies.kueue.x-k8s.io
13+
spec:
14+
group: kueue.x-k8s.io
15+
names:
16+
kind: Topology
17+
listKind: TopologyList
18+
plural: topologies
19+
singular: topology
20+
scope: Cluster
21+
versions:
22+
- name: v1alpha1
23+
schema:
24+
openAPIV3Schema:
25+
description: Topology is the Schema for the topology API
26+
properties:
27+
apiVersion:
28+
description: |-
29+
APIVersion defines the versioned schema of this representation of an object.
30+
Servers should convert recognized schemas to the latest internal value, and
31+
may reject unrecognized values.
32+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
33+
type: string
34+
kind:
35+
description: |-
36+
Kind is a string value representing the REST resource this object represents.
37+
Servers may infer this from the endpoint the client submits requests to.
38+
Cannot be updated.
39+
In CamelCase.
40+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
41+
type: string
42+
metadata:
43+
type: object
44+
spec:
45+
description: TopologySpec defines the desired state of Topology
46+
properties:
47+
levels:
48+
description: levels define the levels of topology.
49+
items:
50+
description: TopologyLevel defines the desired state of TopologyLevel
51+
properties:
52+
nodeLabel:
53+
description: |-
54+
nodeLabel indicates the name of the node label for a specific topology
55+
level.
56+
57+
Examples:
58+
- cloud.provider.com/topology-block
59+
- cloud.provider.com/topology-rack
60+
maxLength: 316
61+
minLength: 1
62+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
63+
type: string
64+
required:
65+
- nodeLabel
66+
type: object
67+
maxItems: 16
68+
minItems: 1
69+
type: array
70+
x-kubernetes-list-type: atomic
71+
x-kubernetes-validations:
72+
- message: field is immutable
73+
rule: self == oldSelf
74+
- message: must be unique
75+
rule: size(self.filter(i, size(self.filter(j, j == i)) > 1)) == 0
76+
- message: the kubernetes.io/hostname label can only be used at the lowest level of topology
77+
rule: size(self.filter(i, i.nodeLabel == 'kubernetes.io/hostname')) == 0 || self[size(self) - 1].nodeLabel == 'kubernetes.io/hostname'
78+
required:
79+
- levels
80+
type: object
81+
required:
82+
- spec
83+
type: object
84+
served: true
85+
storage: true
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2025 NVIDIA CORPORATION
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: batch/v1
5+
kind: Job
6+
metadata:
7+
name: crd-upgrader
8+
namespace: {{ .Release.Namespace }}
9+
annotations:
10+
"helm.sh/hook": pre-install,pre-upgrade
11+
"helm.sh/hook-weight": "2"
12+
"helm.sh/hook-delete-policy": hook-succeeded
13+
spec:
14+
template:
15+
spec:
16+
serviceAccountName: kai-scheduler-crd-manager
17+
containers:
18+
- name: upgrader
19+
image: "{{ .Values.global.registry }}/{{ .Values.crdupgrader.image.name }}:{{ .Chart.Version }}"
20+
imagePullPolicy: {{ .Values.crdupgrader.image.pullPolicy }}
21+
restartPolicy: OnFailure

0 commit comments

Comments
 (0)