-
Notifications
You must be signed in to change notification settings - Fork 1
Enable the SPIFFE socket volume and endpoint to be configured #309
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
base: main
Are you sure you want to change the base?
Changes from all commits
afc8169
8e4147f
fc76d24
fb6564f
9fdb7a6
ec8968f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,7 +20,7 @@ import ( | |||||
| ) | ||||||
|
|
||||||
| const debugContainerNamePrefix = "cofidectl-debug" | ||||||
| const debugContainerImage = "ghcr.io/cofide/cofidectl-debug-container:v0.2.1" | ||||||
| const debugContainerImage = "ghcr.io/cofide/cofidectl-debug-container:v0.2.2-dev" | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks to be causing failures in the CI |
||||||
|
|
||||||
| type Workload struct { | ||||||
| Name string | ||||||
|
|
@@ -145,15 +145,15 @@ func GetUnregisteredWorkloads(ctx context.Context, kubeCfgFile string, kubeConte | |||||
| return unregisteredWorkloads, nil | ||||||
| } | ||||||
|
|
||||||
| func GetStatus(ctx context.Context, statusCh chan<- *provisionpb.Status, dataCh chan string, client *kubeutil.Client, podName string, namespace string) { | ||||||
| func GetStatus(ctx context.Context, statusCh chan<- *provisionpb.Status, dataCh chan string, client *kubeutil.Client, podName, namespace, spiffeSocketEndpoint, spiffeSocketVolumeMount string) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The parameter for the SPIFFE socket volume name is inconsistent across function calls ( I suggest refactoring to use
Suggested change
|
||||||
| debugContainerName := fmt.Sprintf("%s-%s", debugContainerNamePrefix, rand.String(5)) | ||||||
|
|
||||||
| statusCh <- provision.StatusOk( | ||||||
| "Creating", | ||||||
| fmt.Sprintf("Waiting for ephemeral debug container to be created in %s", podName), | ||||||
| ) | ||||||
|
|
||||||
| if err := createDebugContainer(ctx, client, podName, namespace, debugContainerName); err != nil { | ||||||
| if err := createDebugContainer(ctx, client, podName, namespace, spiffeSocketEndpoint, spiffeSocketVolumeMount, debugContainerName); err != nil { | ||||||
| statusCh <- provision.StatusError( | ||||||
| "Creating", | ||||||
| fmt.Sprintf("Failed waiting for ephemeral debug container to be created in %s", podName), | ||||||
|
|
@@ -193,7 +193,7 @@ func GetStatus(ctx context.Context, statusCh chan<- *provisionpb.Status, dataCh | |||||
| ) | ||||||
| } | ||||||
|
|
||||||
| func createDebugContainer(ctx context.Context, client *kubeutil.Client, podName string, namespace string, debugContainerName string) error { | ||||||
| func createDebugContainer(ctx context.Context, client *kubeutil.Client, podName, namespace, spiffeSocketEndpoint, spiffeSocketVolumeName, debugContainerName string) error { | ||||||
| pod, err := client.Clientset.CoreV1().Pods(namespace).Get(ctx, podName, metav1.GetOptions{}) | ||||||
| if err != nil { | ||||||
| return err | ||||||
|
|
@@ -209,13 +209,20 @@ func createDebugContainer(ctx context.Context, client *kubeutil.Client, podName | |||||
| VolumeMounts: []v1.VolumeMount{ | ||||||
| { | ||||||
| ReadOnly: true, | ||||||
| Name: "spiffe-workload-api", | ||||||
| Name: spiffeSocketVolumeName, | ||||||
| MountPath: "/spiffe-workload-api", | ||||||
| }}, | ||||||
| }, | ||||||
| TargetContainerName: pod.Spec.Containers[0].Name, | ||||||
| } | ||||||
|
|
||||||
| if spiffeSocketEndpoint != "" { | ||||||
| debugContainer.Env = append(debugContainer.Env, v1.EnvVar{ | ||||||
| Name: "SPIFFE_ENDPOINT_SOCKET", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To check: does this work with the existing image? go-spiffe should support this natively. |
||||||
| Value: spiffeSocketEndpoint, | ||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| pod.Spec.EphemeralContainers = append(pod.Spec.EphemeralContainers, debugContainer) | ||||||
|
|
||||||
| _, err = client.Clientset.CoreV1().Pods(namespace).UpdateEphemeralContainers( | ||||||
|
|
||||||
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.
The help text for
spiffe-socket-endpointis a bit confusing. It mentions a "full... URI" but also that it "should be prefixed with". This can be ambiguous for users. A clearer description explaining that this is a path inside the container and giving an example would be more helpful.