Skip to content

Commit 4267c3c

Browse files
committed
Add scheduler plugins helm chart
Signed-off-by: carlory <[email protected]>
1 parent aeae36a commit 4267c3c

File tree

8 files changed

+324
-0
lines changed

8 files changed

+324
-0
lines changed

chart/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

chart/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: scheduler-plugins
3+
description: deploy scheduler plugin as a second scheduler in cluster
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.0.1
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "0.0.1"

chart/templates/_helpers.tpl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "chart.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "chart.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "chart.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "chart.labels" -}}
37+
helm.sh/chart: {{ include "chart.chart" . }}
38+
{{ include "chart.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "chart.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "chart.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "chart.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

chart/templates/configmap.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.plugins.enabled }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ .Values.scheduler.name }}-scheduler-config
6+
data:
7+
scheduler-config.yaml: |
8+
apiVersion: kubescheduler.config.k8s.io/v1
9+
kind: KubeSchedulerConfiguration
10+
leaderElection:
11+
leaderElect: {{ .Values.scheduler.leaderElect }}
12+
resourceNamespace: {{ .Release.Namespace }}
13+
resourceName: {{ .Values.scheduler.name }}
14+
profiles:
15+
# Compose all plugins in one profile
16+
- schedulerName: {{ .Values.scheduler.name }}
17+
plugins:
18+
multiPoint:
19+
enabled:
20+
{{- range $.Values.plugins.enabled }}
21+
- name: {{ title .name }}
22+
weight: {{ .weight }}
23+
{{- end }}
24+
disabled:
25+
{{- range $.Values.plugins.disabled }}
26+
- name: {{ title .name }}
27+
{{- end }}
28+
{{- if $.Values.pluginConfig }}
29+
pluginConfig: {{ toYaml $.Values.pluginConfig | nindent 6 }}
30+
{{- end }}
31+
32+
{{- end }}

chart/templates/deployment.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ .Values.scheduler.name }}
5+
labels:
6+
app.kubernetes.io/component: scheduler
7+
app.kubernetes.io/created-by: scheduler-plugins
8+
app.kubernetes.io/part-of: scheduler-plugins
9+
control-plane: scheduler
10+
{{- include "chart.labels" . | nindent 4 }}
11+
spec:
12+
replicas: {{ .Values.scheduler.replicaCount }}
13+
selector:
14+
matchLabels:
15+
control-plane: scheduler
16+
{{- include "chart.selectorLabels" . | nindent 6 }}
17+
template:
18+
metadata:
19+
labels:
20+
control-plane: scheduler
21+
{{- include "chart.selectorLabels" . | nindent 8 }}
22+
annotations:
23+
kubectl.kubernetes.io/default-container: scheduler
24+
spec:
25+
{{- with .Values.scheduler.priorityClassName }}
26+
priorityClassName: {{ . }}
27+
{{- end }}
28+
serviceAccountName: {{ .Values.scheduler.name }}
29+
containers:
30+
- command: {{- toYaml .Values.scheduler.command | nindent 8 }}
31+
args:
32+
- --config=/etc/kubernetes/scheduler-config.yaml
33+
image: {{ .Values.scheduler.image.repository }}:{{ .Values.scheduler.image.tag | default .Chart.AppVersion }}
34+
{{- with .Values.scheduler.image.pullPolicy }}
35+
imagePullPolicy: {{ . }}
36+
{{- end }}
37+
livenessProbe:
38+
httpGet:
39+
path: /healthz
40+
port: 10259
41+
scheme: HTTPS
42+
initialDelaySeconds: 15
43+
name: scheduler
44+
readinessProbe:
45+
httpGet:
46+
path: /healthz
47+
port: 10259
48+
scheme: HTTPS
49+
{{- with .Values.scheduler.resources }}
50+
resources: {{- toYaml . | nindent 10 }}
51+
{{- end }}
52+
securityContext:
53+
privileged: false
54+
volumeMounts:
55+
- name: scheduler-config
56+
mountPath: /etc/kubernetes
57+
readOnly: true
58+
hostNetwork: false
59+
hostPID: false
60+
volumes:
61+
- name: scheduler-config
62+
configMap:
63+
name: {{ .Values.scheduler.name }}-scheduler-config
64+
{{- with .Values.scheduler.nodeSelector }}
65+
nodeSelector: {{- toYaml . | nindent 8 }}
66+
{{- end }}
67+
{{- with .Values.scheduler.affinity }}
68+
affinity: {{- toYaml . | nindent 8 }}
69+
{{- end }}
70+
{{- with .Values.scheduler.tolerations }}
71+
tolerations: {{- toYaml . | nindent 8 }}
72+
{{- end }}

chart/templates/rbac.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: {{ .Values.scheduler.name }}-plugins
5+
rules:
6+
{{- /* resources need to be updated with the scheduler plugins used */}}
7+
{{- range .Values.plugins.enabled }}
8+
{{- if eq .name "ResourceFungibility" }}
9+
- apiGroups: [ "llmaz.io" ]
10+
resources: [ "openmodels" ]
11+
verbs: [ "get" ]
12+
{{- end }}
13+
{{- end }}
14+
---
15+
kind: ClusterRoleBinding
16+
apiVersion: rbac.authorization.k8s.io/v1
17+
metadata:
18+
name: {{ .Values.scheduler.name }}-plugins
19+
roleRef:
20+
apiGroup: rbac.authorization.k8s.io
21+
kind: ClusterRole
22+
name: {{ .Values.scheduler.name }}-plugins
23+
subjects:
24+
- kind: ServiceAccount
25+
name: {{ .Values.scheduler.name }}
26+
namespace: {{ .Release.Namespace }}
27+
---
28+
kind: ClusterRoleBinding
29+
apiVersion: rbac.authorization.k8s.io/v1
30+
metadata:
31+
name: {{ .Values.scheduler.name }}-kube-scheduler
32+
roleRef:
33+
apiGroup: rbac.authorization.k8s.io
34+
kind: ClusterRole
35+
name: system:kube-scheduler
36+
subjects:
37+
- kind: ServiceAccount
38+
name: {{ .Values.scheduler.name }}
39+
namespace: {{ .Release.Namespace }}
40+
---
41+
apiVersion: rbac.authorization.k8s.io/v1
42+
kind: ClusterRoleBinding
43+
metadata:
44+
name: {{ .Values.scheduler.name }}-kube-scheduler-volume-scheduler
45+
roleRef:
46+
apiGroup: rbac.authorization.k8s.io
47+
kind: ClusterRole
48+
name: system:volume-scheduler
49+
subjects:
50+
- kind: ServiceAccount
51+
name: {{ .Values.scheduler.name }}
52+
namespace: {{ .Release.Namespace }}
53+
---
54+
apiVersion: rbac.authorization.k8s.io/v1
55+
kind: RoleBinding
56+
metadata:
57+
name: {{ .Values.scheduler.name }}-extension-apiserver-authentication-reader
58+
namespace: kube-system
59+
roleRef:
60+
apiGroup: rbac.authorization.k8s.io
61+
kind: Role
62+
name: extension-apiserver-authentication-reader
63+
subjects:
64+
- kind: ServiceAccount
65+
name: {{ .Values.scheduler.name }}
66+
namespace: {{ .Release.Namespace }}

chart/templates/serviceaccount.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: {{ .Values.scheduler.name }}
5+
labels:
6+
app.kubernetes.io/component: rbac
7+
app.kubernetes.io/created-by: scheduler-plugins
8+
app.kubernetes.io/part-of: scheduler-plugins
9+
{{- include "chart.labels" . | nindent 4 }}

chart/values.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Default values for chart.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
scheduler:
6+
name: llmaz-scheduler
7+
image:
8+
repository: inftyai/kube-scheduler
9+
tag: v0.0.1
10+
pullPolicy: IfNotPresent
11+
command:
12+
- /kube-scheduler
13+
replicaCount: 1
14+
leaderElect: false
15+
priorityClassName: ""
16+
resources: {}
17+
nodeSelector: {}
18+
affinity: {}
19+
tolerations: []
20+
21+
22+
plugins:
23+
enabled:
24+
- name: ResourceFungibility
25+
weight: 10 # make sure this plugin dominates the scheduling since GPU is scarce
26+
disabled: [] # only in-tree plugins need to be defined here
27+
28+
# Customize the enabled plugins' config.
29+
# Refer to the "pluginConfig" section of manifests/<plugin>/scheduler-config.yaml.
30+
# For example, for ResourceFungibility plugin, like below:
31+
pluginConfig:
32+
# - name: ResourceFungibility
33+
# args:
34+
#
35+
# Or, customize the other plugins
36+
# ...

0 commit comments

Comments
 (0)