Skip to content

Commit cfa165d

Browse files
authored
Merge pull request #75 from nojnhuh/webhook
Add validating admission webhook to Helm chart
2 parents 5eb2322 + 162b104 commit cfa165d

20 files changed

+909
-10
lines changed

Diff for: README.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ kube-system kube-scheduler-dra-example-driver-cluster-control-plane
7171
local-path-storage local-path-provisioner-7dbf974f64-9jmc7 1/1 Running 0 1m
7272
```
7373

74+
The validating admission webhook is disabled by default. To enable it, install cert-manager and its CRDs, then
75+
set the `webhook.enabled=true` value when the dra-example-driver chart is installed.
76+
```bash
77+
helm install \
78+
--repo https://charts.jetstack.io \
79+
--version v1.16.3 \
80+
--create-namespace \
81+
--namespace cert-manager \
82+
--wait \
83+
--set crds.enabled=true \
84+
cert-manager \
85+
cert-manager
86+
```
87+
More options for installing cert-manager can be found in [their docs](https://cert-manager.io/docs/installation/)
88+
7489
And then install the example resource driver via `helm`.
7590
```bash
7691
helm upgrade -i \
@@ -83,8 +98,9 @@ helm upgrade -i \
8398
Double check the driver components have come up successfully:
8499
```console
85100
$ kubectl get pod -n dra-example-driver
86-
NAME READY STATUS RESTARTS AGE
87-
dra-example-driver-kubeletplugin-qwmbl 1/1 Running 0 1m
101+
NAME READY STATUS RESTARTS AGE
102+
dra-example-driver-kubeletplugin-qwmbl 1/1 Running 0 1m
103+
dra-example-driver-webhook-7d465fbd5b-n2wxt 1/1 Running 0 1m
88104
```
89105

90106
And show the initial state of available GPU devices on the worker node:

Diff for: cmd/dra-example-kubeletplugin/cdi.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ import (
2020
"fmt"
2121
"os"
2222

23+
"sigs.k8s.io/dra-example-driver/pkg/consts"
24+
2325
cdiapi "tags.cncf.io/container-device-interface/pkg/cdi"
2426
cdiparser "tags.cncf.io/container-device-interface/pkg/parser"
2527
cdispec "tags.cncf.io/container-device-interface/specs-go"
2628
)
2729

2830
const (
29-
cdiVendor = "k8s." + DriverName
31+
cdiVendor = "k8s." + consts.DriverName
3032
cdiClass = "gpu"
3133
cdiKind = cdiVendor + "/" + cdiClass
3234

@@ -60,7 +62,7 @@ func (cdi *CDIHandler) CreateCommonSpecFile() error {
6062
ContainerEdits: cdispec.ContainerEdits{
6163
Env: []string{
6264
fmt.Sprintf("KUBERNETES_NODE_NAME=%s", os.Getenv("NODE_NAME")),
63-
fmt.Sprintf("DRA_RESOURCE_DRIVER_NAME=%s", DriverName),
65+
fmt.Sprintf("DRA_RESOURCE_DRIVER_NAME=%s", consts.DriverName),
6466
},
6567
},
6668
},

Diff for: cmd/dra-example-kubeletplugin/driver.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626
"k8s.io/klog/v2"
2727

2828
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1beta1"
29+
30+
"sigs.k8s.io/dra-example-driver/pkg/consts"
2931
)
3032

3133
var _ drapbv1.DRAPluginServer = &driver{}
@@ -52,7 +54,7 @@ func NewDriver(ctx context.Context, config *Config) (*driver, error) {
5254
[]any{driver},
5355
kubeletplugin.KubeClient(config.coreclient),
5456
kubeletplugin.NodeName(config.flags.nodeName),
55-
kubeletplugin.DriverName(DriverName),
57+
kubeletplugin.DriverName(consts.DriverName),
5658
kubeletplugin.RegistrarSocketPath(PluginRegistrationPath),
5759
kubeletplugin.PluginSocketPath(DriverPluginSocketPath),
5860
kubeletplugin.KubeletPluginSocketPath(DriverPluginSocketPath))

Diff for: cmd/dra-example-kubeletplugin/main.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ import (
2828
coreclientset "k8s.io/client-go/kubernetes"
2929
"k8s.io/klog/v2"
3030

31+
"sigs.k8s.io/dra-example-driver/pkg/consts"
3132
"sigs.k8s.io/dra-example-driver/pkg/flags"
3233
)
3334

3435
const (
35-
DriverName = "gpu.example.com"
36-
37-
PluginRegistrationPath = "/var/lib/kubelet/plugins_registry/" + DriverName + ".sock"
38-
DriverPluginPath = "/var/lib/kubelet/plugins/" + DriverName
36+
PluginRegistrationPath = "/var/lib/kubelet/plugins_registry/" + consts.DriverName + ".sock"
37+
DriverPluginPath = "/var/lib/kubelet/plugins/" + consts.DriverName
3938
DriverPluginSocketPath = DriverPluginPath + "/plugin.sock"
4039
DriverPluginCheckpointFile = "checkpoint.json"
4140
)

Diff for: cmd/dra-example-kubeletplugin/state.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager"
2828

2929
configapi "sigs.k8s.io/dra-example-driver/api/example.com/resource/gpu/v1alpha1"
30+
"sigs.k8s.io/dra-example-driver/pkg/consts"
3031

3132
cdiapi "tags.cncf.io/container-device-interface/pkg/cdi"
3233
cdispec "tags.cncf.io/container-device-interface/specs-go"
@@ -180,7 +181,7 @@ func (s *DeviceState) prepareDevices(claim *resourceapi.ResourceClaim) (Prepared
180181
// Retrieve the full set of device configs for the driver.
181182
configs, err := GetOpaqueDeviceConfigs(
182183
configapi.Decoder,
183-
DriverName,
184+
consts.DriverName,
184185
claim.Status.Allocation.Devices.Config,
185186
)
186187
if err != nil {

0 commit comments

Comments
 (0)