Skip to content

Commit

Permalink
k8s/debug: also mount nginx dir on debug container
Browse files Browse the repository at this point in the history
  • Loading branch information
morpheu committed Aug 29, 2023
1 parent a625520 commit 15c7ff3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions internal/pkg/rpaas/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ func (m *k8sRpaasManager) generateDebugContainer(ctx context.Context, args *Debu
ImagePullPolicy: corev1.PullIfNotPresent,
Stdin: args.Stdin != nil,
TTY: args.TTY,
VolumeMounts: []corev1.VolumeMount{
{
Name: "nginx-config",
MountPath: "/etc/nginx",
ReadOnly: true,
},
},
}, TargetContainerName: args.Container,
}
instancePodWithDebug := instancePod.DeepCopy()
Expand Down
16 changes: 14 additions & 2 deletions internal/pkg/rpaas/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4906,7 +4906,13 @@ func Test_k8sRpaasManager_Debug(t *testing.T) {
instancePod := corev1.Pod{}
err = m.cli.Get(context.Background(), types.NamespacedName{Name: "pod1", Namespace: instance2.Namespace}, &instancePod)
require.NoError(t, err)
expectedEphemerals := []corev1.EphemeralContainer{{EphemeralContainerCommon: corev1.EphemeralContainerCommon{Name: "debugger-1", Image: "tsuru/debug-image", ImagePullPolicy: corev1.PullIfNotPresent, Stdin: true}, TargetContainerName: "nginx"}}
expectedEphemerals := []corev1.EphemeralContainer{{EphemeralContainerCommon: corev1.EphemeralContainerCommon{
Name: "debugger-1",
Image: "tsuru/debug-image",
ImagePullPolicy: corev1.PullIfNotPresent,
Stdin: true,
VolumeMounts: []corev1.VolumeMount{{Name: "nginx-config", MountPath: "/etc/nginx", ReadOnly: true}},
}, TargetContainerName: "nginx"}}
assert.Equal(t, expectedEphemerals, instancePod.Spec.EphemeralContainers)
},
},
Expand All @@ -4927,7 +4933,13 @@ func Test_k8sRpaasManager_Debug(t *testing.T) {
instancePod := corev1.Pod{}
err = m.cli.Get(context.Background(), types.NamespacedName{Name: "pod1", Namespace: instance2.Namespace}, &instancePod)
require.NoError(t, err)
expectedEphemerals := []corev1.EphemeralContainer{{EphemeralContainerCommon: corev1.EphemeralContainerCommon{Name: "debugger-2", Image: "tsuru/debug-image", ImagePullPolicy: corev1.PullIfNotPresent, Stdin: true}, TargetContainerName: "nginx"}}
expectedEphemerals := []corev1.EphemeralContainer{{EphemeralContainerCommon: corev1.EphemeralContainerCommon{
Name: "debugger-2",
Image: "tsuru/debug-image",
ImagePullPolicy: corev1.PullIfNotPresent,
Stdin: true,
VolumeMounts: []corev1.VolumeMount{{Name: "nginx-config", MountPath: "/etc/nginx", ReadOnly: true}},
}, TargetContainerName: "nginx"}}
assert.Equal(t, expectedEphemerals, instancePod.Spec.EphemeralContainers)
},
},
Expand Down

0 comments on commit 15c7ff3

Please sign in to comment.