-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cdh golang client interface #557
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ChengyuZhu6 .
I think the pkg
in golang for CDH would make great sense to users working in k8s ecosystem. Some comments
@@ -0,0 +1,46 @@ | |||
syntax = "proto3"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reuse the proto already defined in https://github.com/confidential-containers/guest-components/blob/main/confidential-data-hub/hub/protos/api.proto? This could help with so-called "single truth of source".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Support to unseal secret from env in in grpc client. Fixes: confidential-containers#556 Signed-off-by: ChengyuZhu6 <[email protected]>
Support to unseal secret from file in cdh grpc client. Signed-off-by: ChengyuZhu6 <[email protected]>
Support to build cdh go grpc client. Signed-off-by: ChengyuZhu6 <[email protected]>
Support to unseal secret from env in in ttrpc client. Signed-off-by: ChengyuZhu6 <[email protected]>
Support to unseal secret from file in cdh ttrpc client. Signed-off-by: ChengyuZhu6 <[email protected]>
Support to build cdh go ttrpc client. Signed-off-by: ChengyuZhu6 <[email protected]>
Define an interface `SecretUnsealer` that both gRPC and TTRPC go clients can implement. Define common implementation `UnsealEnv` and `UnsealFile` that can be used by both gRPC and TTRPC clients. Signed-off-by: ChengyuZhu6 <[email protected]>
89ad7b2
to
ead51b2
Compare
support to configure flags by command line input, such as : OperationType: The operation type to perform Socket: The rpc socket path OperationInterface: The interface to use for the operation OperationInput: The input value to use for the operation interface rpcType: get the rpc type for the client Signed-off-by: ChengyuZhu6 <[email protected]>
Add README for cdh go client. Signed-off-by: ChengyuZhu6 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to me. One last question is that we'd better have CI to cover this, but I think it is ok to be in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this will be used inside of a guest? I associate Go more with k8s on the host. Can you elaborate on the integrations that you mentioned? I am slightly wary of supporting more languages although overall this PR looks fine (with my modest understanding of Go).
Ok. I have successfully integrated CDH with NRI plugin in containerd. This allows us to unseal secrets in NRI plugin using the CDH Go client, rather than having to execute CDH binary to get unsealed values. |
I unseal secret with NRI plugin during CreateContainer stage in k8s. pod yaml: apiVersion: v1
kind: Pod
metadata:
name: registry
spec:
containers:
- name: registry
image: quay.io/chengyu_zhu/registry:latest
command: [ "/bin/sh", "-c", "env && sleep 3000" ]
env:
- name: SECRET_USERNAME
valueFrom:
secretKeyRef:
name: secret-sealed
key: sealed-secret sealed secret: ---
apiVersion: v1
kind: Secret
metadata:
name: secret-sealed
type: Opaque
stringData:
sealed-secret: sealed.fakeheader.ewogICJ2ZXJzaW9uIjogIjAuMS4wIiwKICAidHlwZSI6ICJ2YXVsdCIsCiAgIm5hbWUiOiAia2JzOi8vL2RlZmF1bHQvdHlwZS90YWciLAogICJwcm92aWRlciI6ICJrYnMiLAogICJwcm92aWRlcl9zZXR0aW5ncyI6IHt9LAogICJhbm5vdGF0aW9ucyI6IHt9Cn0K.fakesignature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm a bit wary of supporting another language, but I think I understand this use case.
As AA/CDH would be used in more scenarios beyond CoCo, it would make sense to maintain only the client side code of both in some way. Probably wdyt? |
Yeah in some ways this seems better although there would probably be some synchronization cost. wdyth @mkulke |
I'd agree that it's a valid use case to leverage CDH with existing container tooling, but I'm not sure it should be in guest-components, since I understand this is not a (confidential) guest-component for kata-guests. |
We do already have some client tools in this repo, such as the secret-cli. (that might be the only one, I forget) |
I see, in this case the having golang libraries maintained alongside is fine, I guess. |
@fitzthum @mkulke Ok. Let's could move the golang things to a separate repo if needed. Over all, thanks @ChengyuZhu6 for the work! |
This client interface streamlines the process of connecting to CDH and leveraging its APIs. The Go version is very useful for integrating the CDH with containerd plugins, including NRI and image verifiers, where CDH operates as an independent module.
Note that this PR includes only the interface for
UnsealSecret
.I think other interfaces can be implemented in the following PRs.
Fixes: #556