Skip to content

Commit 9f81648

Browse files
authored
Merge pull request #1 from IBM/power-dev
Create Helm Deployment
2 parents 903cf13 + 6d612e4 commit 9f81648

16 files changed

+427
-5
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
*
2-
!cdi/*.sh
3-
41
# But not these files...
52
!/.gitignore
63

@@ -15,6 +12,7 @@
1512
!pkg/webhook/testdata/pod.json
1613
!manifests/webhook/*.yaml
1714
!Makefile
15+
!Dockerfile
1816

1917
# Image
2018
!build/Containerfile
@@ -26,4 +24,4 @@
2624
!.github/workflows/publish.yaml
2725

2826
# ...even if they are in subdirectories
29-
!*/
27+
!*/

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ARG GOLANG_VERSION=1.23.3
2+
FROM golang:${GOLANG_VERSION} as build
3+
ARG CLIENT_GEN_VERSION=0.26.1
4+
ARG LISTER_GEN_VERSION=0.26.1
5+
ARG INFORMER_GEN_VERSION=0.26.1
6+
ARG CONTROLLER_GEN_VERSION=0.17.1
7+
ARG CI_LINT_VERSION=1.52.0
8+
ARG MOQ_VERSION=0.3.4
9+
10+
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${CI_LINT_VERSION} && go install github.com/matryer/moq@v${MOQ_VERSION} && go install sigs.k8s.io/controller-tools/cmd/controller-gen@v${CONTROLLER_GEN_VERSION} && go install k8s.io/code-generator/cmd/client-gen@v${CLIENT_GEN_VERSION} && go install k8s.io/code-generator/cmd/lister-gen@v${LISTER_GEN_VERSION} && go install k8s.io/code-generator/cmd/informer-gen@v${INFORMER_GEN_VERSION}
11+
RUN git config --file=/.gitconfig --add safe.directory /work

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ARCH ?= ppc64le
33

44
REGISTRY ?= quay.io/jcho0
55
REPOSITORY ?= power-dra-driver
6-
TAG ?= first-test
6+
TAG ?= v0.1.0
77

88
CONTAINER_RUNTIME ?= $(shell command -v podman 2> /dev/null || echo docker)
99

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/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: power-dra-driver
3+
description: An Helm chart for a Dynamic Resource Allocation (DRA) resource driver
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.1.0
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.1.0"
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "power-dra-driver.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 "power-dra-driver.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+
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
28+
*/}}
29+
{{- define "power-dra-driver.namespace" -}}
30+
{{- if .Values.namespaceOverride -}}
31+
{{- .Values.namespaceOverride -}}
32+
{{- else -}}
33+
{{- .Release.Namespace -}}
34+
{{- end -}}
35+
{{- end -}}
36+
37+
{{/*
38+
Create chart name and version as used by the chart label.
39+
*/}}
40+
{{- define "power-dra-driver.chart" -}}
41+
{{- $name := default .Chart.Name .Values.nameOverride -}}
42+
{{- printf "%s-%s" $name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
43+
{{- end }}
44+
45+
{{/*
46+
Common labels
47+
*/}}
48+
{{- define "power-dra-driver.labels" -}}
49+
helm.sh/chart: {{ include "power-dra-driver.chart" . }}
50+
{{ include "power-dra-driver.templateLabels" . }}
51+
{{- if .Chart.AppVersion }}
52+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
53+
{{- end }}
54+
app.kubernetes.io/managed-by: {{ .Release.Service }}
55+
{{- end }}
56+
57+
{{/*
58+
Template labels
59+
*/}}
60+
{{- define "power-dra-driver.templateLabels" -}}
61+
app.kubernetes.io/name: {{ include "power-dra-driver.name" . }}
62+
app.kubernetes.io/instance: {{ .Release.Name }}
63+
{{- if .Values.selectorLabelsOverride }}
64+
{{ toYaml .Values.selectorLabelsOverride }}
65+
{{- end }}
66+
{{- end }}
67+
68+
{{/*
69+
Selector labels
70+
*/}}
71+
{{- define "power-dra-driver.selectorLabels" -}}
72+
{{- if .Values.selectorLabelsOverride -}}
73+
{{ toYaml .Values.selectorLabelsOverride }}
74+
{{- else -}}
75+
{{ include "power-dra-driver.templateLabels" . }}
76+
{{- end }}
77+
{{- end }}
78+
79+
{{/*
80+
Full image name with tag
81+
*/}}
82+
{{- define "power-dra-driver.fullimage" -}}
83+
{{- $tag := printf "v%s" .Chart.AppVersion }}
84+
{{- .Values.image.repository -}}:{{- .Values.image.tag | default $tag -}}
85+
{{- end }}
86+
87+
{{/*
88+
Create the name of the service account to use
89+
*/}}
90+
{{- define "power-dra-driver.serviceAccountName" -}}
91+
{{- $name := printf "%s-service-account" (include "power-dra-driver.fullname" .) }}
92+
{{- if .Values.serviceAccount.create }}
93+
{{- default $name .Values.serviceAccount.name }}
94+
{{- else }}
95+
{{- default "default" .Values.serviceAccount.name }}
96+
{{- end }}
97+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: {{ include "power-dra-driver.fullname" . }}-role
5+
namespace: {{ include "power-dra-driver.namespace" . }}
6+
rules:
7+
- apiGroups: ["resource.k8s.io"]
8+
resources: ["resourceclaims"]
9+
verbs: ["get"]
10+
- apiGroups: [""]
11+
resources: ["nodes"]
12+
verbs: ["get"]
13+
- apiGroups: ["resource.k8s.io"]
14+
resources: ["resourceslices"]
15+
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: {{ include "power-dra-driver.fullname" . }}-role-binding
5+
namespace: {{ include "power-dra-driver.namespace" . }}
6+
subjects:
7+
- kind: ServiceAccount
8+
name: {{ include "power-dra-driver.serviceAccountName" . }}
9+
namespace: {{ include "power-dra-driver.namespace" . }}
10+
roleRef:
11+
kind: ClusterRole
12+
name: {{ include "power-dra-driver.fullname" . }}-role
13+
apiGroup: rbac.authorization.k8s.io
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: resource.k8s.io/v1alpha3
2+
kind: DeviceClass
3+
metadata:
4+
name: gpu.powervs-openshift-ipi.cis.ibm.net
5+
spec:
6+
selectors:
7+
- cel:
8+
expression: "device.driver == 'gpu.powervs-openshift-ipi.cis.ibm.net'"
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: {{ include "power-dra-driver.fullname" . }}-kubeletplugin
5+
namespace: {{ include "power-dra-driver.namespace" . }}
6+
labels:
7+
{{- include "power-dra-driver.labels" . | nindent 4 }}
8+
spec:
9+
selector:
10+
matchLabels:
11+
{{- include "power-dra-driver.selectorLabels" . | nindent 6 }}
12+
{{- with .Values.kubeletPlugin.updateStrategy }}
13+
updateStrategy:
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
template:
17+
metadata:
18+
{{- with .Values.kubeletPlugin.podAnnotations }}
19+
annotations:
20+
{{- toYaml . | nindent 8 }}
21+
{{- end }}
22+
labels:
23+
{{- include "power-dra-driver.templateLabels" . | nindent 8 }}
24+
spec:
25+
{{- if .Values.kubeletPlugin.priorityClassName }}
26+
priorityClassName: {{ .Values.kubeletPlugin.priorityClassName }}
27+
{{- end }}
28+
{{- with .Values.imagePullSecrets }}
29+
imagePullSecrets:
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
serviceAccountName: {{ include "power-dra-driver.serviceAccountName" . }}
33+
securityContext:
34+
{{- toYaml .Values.kubeletPlugin.podSecurityContext | nindent 8 }}
35+
containers:
36+
- name: plugin
37+
securityContext:
38+
{{- toYaml .Values.kubeletPlugin.containers.plugin.securityContext | nindent 10 }}
39+
image: {{ include "power-dra-driver.fullimage" . }}
40+
imagePullPolicy: {{ .Values.image.pullPolicy }}
41+
command: ["power-dra-kubeletplugin"]
42+
resources:
43+
{{- toYaml .Values.kubeletPlugin.containers.plugin.resources | nindent 10 }}
44+
env:
45+
- name: CDI_ROOT
46+
value: /var/run/cdi
47+
- name: NODE_NAME
48+
valueFrom:
49+
fieldRef:
50+
fieldPath: spec.nodeName
51+
- name: NAMESPACE
52+
valueFrom:
53+
fieldRef:
54+
fieldPath: metadata.namespace
55+
# Simulated number of devices the example driver will pretend to have.
56+
- name: NUM_DEVICES
57+
value: "8"
58+
volumeMounts:
59+
- name: plugins-registry
60+
mountPath: /var/lib/kubelet/plugins_registry
61+
- name: plugins
62+
mountPath: /var/lib/kubelet/plugins
63+
- name: cdi
64+
mountPath: /var/run/cdi
65+
volumes:
66+
- name: plugins-registry
67+
hostPath:
68+
path: /var/lib/kubelet/plugins_registry
69+
- name: plugins
70+
hostPath:
71+
path: /var/lib/kubelet/plugins
72+
- name: cdi
73+
hostPath:
74+
path: /var/run/cdi
75+
{{- with .Values.kubeletPlugin.nodeSelector }}
76+
nodeSelector:
77+
{{- toYaml . | nindent 8 }}
78+
{{- end }}
79+
{{- with .Values.kubeletPlugin.affinity }}
80+
affinity:
81+
{{- toYaml . | nindent 8 }}
82+
{{- end }}
83+
{{- with .Values.kubeletPlugin.tolerations }}
84+
tolerations:
85+
{{- toYaml . | nindent 8 }}
86+
{{- end }}

0 commit comments

Comments
 (0)