Skip to content

Commit 05387fe

Browse files
empovitshivamerla
authored andcommitted
Fix make deploy on OpenShift
1 parent a35dc20 commit 05387fe

15 files changed

+65
-78
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ testbin/*
2727
.vscode
2828

2929
# Credentials and runtime environment
30-
hack/kubeconfig
31-
hack/.env
30+
kubeconfig
31+
.env
3232

3333
# Bundle artifacts
3434
bundle.Dockerfile

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,13 @@ uninstall: manifests kustomize
100100
$(KUSTOMIZE) build config/crd | kubectl delete -f -
101101

102102
# Deploy gpu-operator in the configured Kubernetes cluster in ~/.kube/config
103-
deploy: manifests kustomize
103+
deploy: manifests generate-env kustomize
104104
cd config/manager && $(KUSTOMIZE) edit set image gpu-operator=${IMAGE}
105105
$(KUSTOMIZE) build config/default | kubectl apply -f -
106106

107+
generate-env:
108+
./hack/prepare-env.sh
109+
107110
# UnDeploy gpu-operator from the configured Kubernetes cluster in ~/.kube/config
108111
undeploy:
109112
$(KUSTOMIZE) build config/default | kubectl delete -f -

config/manager/kustomization.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ configMapGenerator:
88
- files:
99
- controller_manager_config.yaml
1010
name: manager-config
11+
- envs:
12+
- .env
13+
name: gpu-operator-envs-cm
1114
apiVersion: kustomize.config.k8s.io/v1beta1
1215
kind: Kustomization
1316
images:

config/manager/manager.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ kind: Namespace
33
metadata:
44
labels:
55
control-plane: controller-manager
6+
security.openshift.io/scc.podSecurityLabelSync: 'false'
67
pod-security.kubernetes.io/enforce: privileged
78
name: system
89
---
910
apiVersion: apps/v1
1011
kind: Deployment
1112
metadata:
1213
name: gpu-operator
14+
namespace: system
1315
labels:
1416
app.kubernetes.io/component: gpu-operator
1517
app: gpu-operator
@@ -28,7 +30,7 @@ spec:
2830
serviceAccountName: gpu-operator
2931
containers:
3032
- name: gpu-operator
31-
image: nvcr.io/nvidia/gpu-operator:1.7.0
33+
image: gpu-operator
3234
args:
3335
- --leader-elect
3436
command:
@@ -63,6 +65,9 @@ spec:
6365
valueFrom:
6466
fieldRef:
6567
fieldPath: metadata.namespace
68+
envFrom:
69+
- configMapRef:
70+
name: gpu-operator-envs-cm
6671
ports:
6772
- name: metrics
6873
containerPort: 8080

config/rbac/auth_proxy_role_binding.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ roleRef:
88
name: proxy-role
99
subjects:
1010
- kind: ServiceAccount
11-
name: default
11+
name: gpu-operator
1212
namespace: system

config/rbac/kustomization.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
resources:
2+
- service_account.yaml
23
- role.yaml
34
- role_binding.yaml
45
- leader_election_role.yaml

config/rbac/leader_election_role_binding.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ roleRef:
88
name: leader-election-role
99
subjects:
1010
- kind: ServiceAccount
11-
name: default
11+
name: gpu-operator
1212
namespace: system

config/rbac/role.yaml

+30-8
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ rules:
5555
- pods
5656
verbs:
5757
- list
58+
- apiGroups:
59+
- apiextensions.k8s.io
60+
resources:
61+
- customresourcedefinitions
62+
verbs:
63+
- get
64+
- list
65+
- watch
5866
- apiGroups:
5967
- apps
6068
resources:
@@ -127,15 +135,27 @@ rules:
127135
- apiGroups:
128136
- monitoring.coreos.com
129137
resources:
130-
- prometheusrule
138+
- prometheusrules
131139
- servicemonitors
132140
verbs:
133141
- create
142+
- delete
134143
- get
135144
- list
136145
- patch
137146
- update
138147
- watch
148+
- apiGroups:
149+
- node.k8s.io
150+
resources:
151+
- runtimeclasses
152+
verbs:
153+
- create
154+
- delete
155+
- get
156+
- list
157+
- update
158+
- watch
139159
- apiGroups:
140160
- nvidia.com
141161
resources:
@@ -156,13 +176,7 @@ rules:
156176
- rolebindings
157177
- roles
158178
verbs:
159-
- create
160-
- delete
161-
- get
162-
- list
163-
- patch
164-
- update
165-
- watch
179+
- '*'
166180
- apiGroups:
167181
- route.openshift.io
168182
resources:
@@ -195,3 +209,11 @@ rules:
195209
- patch
196210
- update
197211
- watch
212+
- apiGroups:
213+
- security.openshift.io
214+
resourceNames:
215+
- privileged
216+
resources:
217+
- securitycontextconstraints
218+
verbs:
219+
- use

config/rbac/role_binding.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ roleRef:
88
name: gpu-operator-role
99
subjects:
1010
- kind: ServiceAccount
11-
name: default
11+
name: gpu-operator
1212
namespace: system

config/rbac/service_account.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: gpu-operator
5+
namespace: system

controllers/clusterpolicy_controller.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,19 @@ type ClusterPolicyReconciler struct {
6161
// +kubebuilder:rbac:groups=nvidia.com,resources=*,verbs=get;list;watch;create;update;patch;delete
6262
// +kubebuilder:rbac:groups=config.openshift.io,resources=clusterversions;proxies,verbs=get;list;watch
6363
// +kubebuilder:rbac:groups=security.openshift.io,resources=securitycontextconstraints,verbs=get;list;watch;create;update;patch;delete
64-
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles;clusterrolebindings;roles;rolebindings,verbs=get;list;watch;create;update;patch;delete
64+
// +kubebuilder:rbac:groups=security.openshift.io,resources=securitycontextconstraints,verbs=use,resourceNames=privileged
65+
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles;clusterrolebindings;roles;rolebindings,verbs=*
6566
// +kubebuilder:rbac:groups="",resources=namespaces;serviceaccounts;pods;pods/eviction;services;services/finalizers;endpoints,verbs=get;list;watch;create;update;patch;delete
6667
// +kubebuilder:rbac:groups="",resources=persistentvolumeclaims;events;configmaps;secrets;nodes,verbs=get;list;watch;create;update;patch;delete
6768
// +kubebuilder:rbac:groups=apps,resources=deployments;daemonsets;replicasets;statefulsets,verbs=get;list;watch;create;update;patch;delete
6869
// +kubebuilder:rbac:groups=apps,resources=controllerrevisions,verbs=get;list;watch
69-
// +kubebuilder:rbac:groups=monitoring.coreos.com,resources=servicemonitors;prometheusrule,verbs=get;list;watch;create;update;patch
70+
// +kubebuilder:rbac:groups=monitoring.coreos.com,resources=servicemonitors;prometheusrules,verbs=get;list;watch;create;update;patch;delete
7071
// +kubebuilder:rbac:groups=scheduling.k8s.io,resources=priorityclasses,verbs=get;list;watch;create
7172
// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;patch
7273
// +kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=get;list;watch;create;update;patch
7374
// +kubebuilder:rbac:groups=image.openshift.io,resources=imagestreams,verbs=get;list;watch
75+
// +kubebuilder:rbac:groups=node.k8s.io,resources=runtimeclasses,verbs=get;list;create;update;watch;delete
76+
// +kubebuilder:rbac:groups=apiextensions.k8s.io,resources=customresourcedefinitions,verbs=get;list;watch
7477

7578
// Reconcile is part of the main kubernetes reconciliation loop which aims to
7679
// move the current state of the cluster closer to the desired state.

hack/README.md

-23
This file was deleted.

hack/prepare-env.sh

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
#! /bin/bash
22

3+
dest=config/manager/.env
4+
35
env=$(cat bundle/manifests/gpu-operator-certified.clusterserviceversion.yaml \
4-
| yq \
5-
| jq '.spec.install.spec.deployments[].spec.template.spec.containers[].env[] | .name, "=", .value, ";"' -r )
6+
| yq '.spec.install.spec.deployments[].spec.template.spec.containers[].env[] | with_entries(select(.value != "OPERATOR_NAMESPACE"))' \
7+
| jq 'select( .name != null and .value != null) | .name, "=", .value, ";"' -r )
68
env=${env//$'\n'/}
7-
echo $env > ./hack/.env
8-
sed -i 's/;/\n/g' ./hack/.env
9-
10-
echo KUBECONFIG=${PWD}/hack/kubeconfig >> ./hack/.env
11-
echo OPERATOR_NAMESPACE=nvidia-gpu-operator >> ./hack/.env
12-
13-
export KUBECONFIG=${PWD}/hack/kubeconfig
14-
export OPERATOR_NAMESPACE=nvidia-gpu-operator
15-
16-
kubectl create namespace ${OPERATOR_NAMESPACE} 2>/dev/null || true
17-
kubectl apply -f ./config/crd/bases/nvidia.com_clusterpolicies.yaml
18-
kubectl apply -f ./config/samples/v1_clusterpolicy.yaml
9+
echo $env > ${dest}
10+
sed -i 's/;/\n/g' ${dest}

hack/vscode/launch.json

-15
This file was deleted.

hack/vscode/tasks.json

-9
This file was deleted.

0 commit comments

Comments
 (0)