Repository navigation
Add validating admission webhook to verify opaque configs - #461
Conversation
1e6ea3d to
4610207
Compare
| contentType := r.Header.Get("Content-Type") | ||
| if contentType != "application/json" { | ||
| msg := fmt.Sprintf("contentType=%s, expected application/json", contentType) | ||
| klog.Error(msg) |
There was a problem hiding this comment.
Let's log with info or warning level.
(from the perspective of this request handler here that's not an error -- just an HTTP request coming in that this handler is not supposed to handle)
There was a problem hiding this comment.
Can look into as followup
| if r.Body != nil { | ||
| data, err := io.ReadAll(r.Body) | ||
| if err != nil { | ||
| klog.Error(err) |
There was a problem hiding this comment.
also here: not an error from the handler's perspective
There was a problem hiding this comment.
I will change these as an add-on commit, because I tried to keep the diff in the first commit as minimal to kubernetes-sigs/dra-example-driver#75 as possible.
There was a problem hiding this comment.
From sync discussion: I am happy with doing any logging-around-HTTP-request-lifecycle consolidations in a follow-up.
| return | ||
| } | ||
|
|
||
| klog.V(2).Infof("handling request: %s", body) |
There was a problem hiding this comment.
It makes sense to not log the entire request body, but at most N bytes.
For N, I often pick something like 100 or 500 or something like that depending on context -- that shows everything of interest in a sane case. This is for not accidentally logging e.g. a megabyte of data in case something goes pearshaped. 🍐
There was a problem hiding this comment.
Include in the follow-up as well?
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/apimachinery/pkg/runtime/schema" | ||
|
|
| @@ -0,0 +1,106 @@ | |||
| /* | |||
| * Copyright 2024 NVIDIA CORPORATION. | |||
There was a problem hiding this comment.
Need to use the same license headers as the other newly added files
There was a problem hiding this comment.
This was in a commit that merged as part of another PR
| @@ -0,0 +1,417 @@ | |||
| /* | |||
| * Copyright 2024 NVIDIA CORPORATION. | |||
There was a problem hiding this comment.
same comment as previous
There was a problem hiding this comment.
This was in a commit that merged as part of another PR
| @@ -0,0 +1,255 @@ | |||
| /* | |||
| * Copyright 2024 NVIDIA CORPORATION. | |||
There was a problem hiding this comment.
same comment as previous
There was a problem hiding this comment.
This was in a commit that merged as part of another PR
| @@ -0,0 +1,54 @@ | |||
| /* | |||
| * Copyright 2024 NVIDIA CORPORATION. | |||
There was a problem hiding this comment.
same comment as previous
There was a problem hiding this comment.
This was in a commit that merged as part of another PR
| labels: | ||
| {{- include "nvidia-dra-driver-gpu.labels" . | nindent 4 }} | ||
| spec: | ||
| replicas: 1 |
There was a problem hiding this comment.
can we make the number of replicas configurable? I think it's good to have redundancy for the webhook especially when running this at scale
There was a problem hiding this comment.
Done in latest revision
| livenessProbe: | ||
| failureThreshold: 5 | ||
| httpGet: | ||
| path: /readyz |
There was a problem hiding this comment.
Just curious; I wonder where that trailing z convention comes from.
There was a problem hiding this comment.
I'm not sure. I remember it even during my days at google on all of their internal endpoints so I assume its carried over from there.
There was a problem hiding this comment.
In my mind, the z in readyz is the same as the z in lolz, so it looks a tiny bit silly. But that's ok.
| # Additional DNS names for the certificate | ||
| dnsNames: [] | ||
| secret: | ||
| # Name of the secret containing tls.crt and tls.key |
There was a problem hiding this comment.
When done properly, there should be documentation about the (various types of) input format(s) expected (for both the public key and the private key files). This is about content encoding as well as key types and strengths.
There was a problem hiding this comment.
Yes, and about the feature gates and their stages.
3eb2760 to
9063701
Compare
|
@jgehrcke and @tariq1890 new version pushed and all questions answered. PTAL |
3670276 to
6db96fd
Compare
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/klog/v2" | ||
|
|
||
| configapi "github.com/NVIDIA/k8s-dra-driver-gpu/api/nvidia.com/resource/v1beta1" |
There was a problem hiding this comment.
Curious, why use configapi as the import alias here? Wouldn't resourceapi be more intuitive?
There was a problem hiding this comment.
The name resourceapi is already taken (4 lines up).
Regardless, I always use nvapi for this, so changing this to that is the right thing to do.
This is a straight copy of this PR kubernetes-sigs/dra-example-driver#75, with minimal changes to make it work in this repo. Signed-off-by: Kevin Klues <kklues@nvidia.com>
Signed-off-by: Kevin Klues <kklues@nvidia.com>
Signed-off-by: Kevin Klues <kklues@nvidia.com>
Signed-off-by: Kevin Klues <kklues@nvidia.com>
Previously, the webhook only supported cert-manager with a self-signed issuer for TLS certificate generation and management. With this patch, users can now provide their own TLS certificates via secret mode or use custom cert-manager issuers (issuer/clusterissuer) with specified issuer names. Signed-off-by: Kevin Klues <kklues@nvidia.com>
6db96fd to
152c683
Compare
jgehrcke
left a comment
There was a problem hiding this comment.
LGTM!
As discussed out-of-band, it will be worthwhile 'productionizing' the HTTP request lifecycle (in particular w.r.t. logging and error handling) a bit, and also invest into reference docs for the various input parameters users can provide. We'll do that later.
This is an adaptation of the following from the example DRA driver:
kubernetes-sigs/dra-example-driver#75
It is customized to validate the opaque configs for all of the supported types in the DRA driver for GPUs.
It has also been updated to:
v1,v1beta1, andv1beta2resource APIs.Fixes: #461
Example configurations for webhook TLS certificate management
A test script that can be run (from the root of the repo) to make sure things render as expected