Skip to content

Commit b896c91

Browse files
authored
Moving to istio-proxy image (#57)
* Moving to istio-proxy image * Fix tests * Adds SPIFFE workload API volume, adds param on privilege escalation * Add target to build local Docker image
1 parent a771e39 commit b896c91

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

Justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
build tag='local':
2+
docker build -t ghcr.io/cofide/spiffe-enable:{{tag}} .
3+
14
test *args:
25
go run gotest.tools/gotestsum@latest --format github-actions ./... -short {{args}}
36

internal/proxy/config.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import (
88
"text/template"
99

1010
"github.com/cofide/spiffe-enable/internal/helper"
11+
"github.com/cofide/spiffe-enable/internal/workload"
1112
corev1 "k8s.io/api/core/v1"
1213
"k8s.io/utils/ptr"
1314
)
1415

1516
// Envoy-specific constants
1617
var (
17-
EnvoyImage = "envoyproxy/envoy:v1.33-latest"
18+
IstioImage = "docker.io/istio/proxyv2:1.26.4"
1819
)
1920

2021
const (
@@ -25,7 +26,7 @@ const (
2526
EnvoyConfigContentEnvVar = "ENVOY_CONFIG_CONTENT"
2627
EnvoyConfigInitContainerName = "inject-envoy-config"
2728
EnvoyPort = 10000
28-
EnvoyUID = 101
29+
EnvoyUID = 1337
2930
DNSProxyPort = 15053
3031
)
3132

@@ -241,15 +242,21 @@ func (e *Envoy) GetSidecarContainer() corev1.Container {
241242

242243
return corev1.Container{
243244
Name: EnvoySidecarContainerName,
244-
Image: EnvoyImage,
245+
Image: IstioImage,
245246
ImagePullPolicy: corev1.PullIfNotPresent,
246247
Command: []string{"envoy"},
247248
Args: []string{"-c", configFilePath},
248-
VolumeMounts: []corev1.VolumeMount{{Name: EnvoyConfigVolumeName, MountPath: EnvoyConfigMountPath}},
249+
VolumeMounts: []corev1.VolumeMount{
250+
{Name: EnvoyConfigVolumeName, MountPath: EnvoyConfigMountPath},
251+
workload.GetSPIFFEVolumeMount(),
252+
},
249253
SecurityContext: &corev1.SecurityContext{
250-
RunAsUser: ptr.To(int64(101)), // # Run as non-root user
251-
RunAsGroup: ptr.To(int64(101)), // # Run as non-root group
252-
RunAsNonRoot: ptr.To(true),
254+
AllowPrivilegeEscalation: ptr.To(false),
255+
RunAsUser: ptr.To(int64(EnvoyUID)), // # Run as non-root user
256+
RunAsGroup: ptr.To(int64(EnvoyUID)), // # Run as non-root group
257+
RunAsNonRoot: ptr.To(true),
258+
Privileged: ptr.To(false),
259+
Capabilities: &corev1.Capabilities{Drop: []corev1.Capability{"all"}},
253260
},
254261
Ports: []corev1.ContainerPort{
255262
{

internal/webhook/webhook_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ func TestSpiffeEnableWebhook_Handle(t *testing.T) {
229229
for _, c := range mutatedPod.Spec.Containers {
230230
if c.Name == proxy.EnvoySidecarContainerName {
231231
foundProxySidecar = true
232-
assert.Equal(t, proxy.EnvoyImage, c.Image)
232+
assert.Equal(t, proxy.IstioImage, c.Image)
233233
// Check args, mounts, security context, ports for sidecar
234234
require.NotNil(t, c.SecurityContext)
235-
assert.Equal(t, ptr.To(int64(101)), c.SecurityContext.RunAsUser)
235+
assert.Equal(t, ptr.To(int64(1337)), c.SecurityContext.RunAsUser)
236236
assert.Equal(t, ptr.To(true), c.SecurityContext.RunAsNonRoot)
237237
require.Len(t, c.Ports, 1)
238238
assert.Equal(t, int32(proxy.EnvoyPort), c.Ports[0].ContainerPort)

0 commit comments

Comments
 (0)