Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions charts/noe/templates/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ spec:
workingDir: /workdir
args:
- --registry-proxies={{ .Values.proxies | join "," }}
{{ if .Values.schedulableArchitectures }}
- --cluster-schedulable-archs={{ .Values.schedulableArchitectures | join "," }}
{{ end }}
{{ if and .Values.kubeletConfig .Values.kubeletConfig.binDir }}
- --image-credential-provider-bin-dir={{ .Values.kubeletConfig.binDir }}
{{ end }}
Expand All @@ -97,6 +99,9 @@ spec:
{{ end }}
{{ if .Values.privateRegistries }}
- --private-registries={{ .Values.privateRegistries | join "," }}
{{ end }}
{{ if .Values.preferredArchitecture }}
- --preferred-arch={{ .Values.preferredArchitecture }}
{{ end }}
ports:
- containerPort: 8443
Expand Down
1 change: 1 addition & 0 deletions charts/noe/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ image:
registry: ghcr.io
repository: adevinta/noe
tag: latest
preferredArchitecture: ""
schedulableArchitectures: []
proxies: []
# - docker.io=docker-proxy.company.corp
Expand Down
2 changes: 1 addition & 1 deletion cmd/noe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {
var kubeletImageCredentialProviderBinBir, kubeletImageCredentialProviderConfig string
var privateregistriesPatterns string

flag.StringVar(&preferredArch, "preferred-arch", "amd64", "Preferred architecture when placing pods")
flag.StringVar(&preferredArch, "preferred-arch", "", "Preferred architecture when placing pods")
flag.StringVar(&schedulableArchs, "cluster-schedulable-archs", "", "Comma separated list of architectures schedulable in the cluster")
flag.StringVar(&systemOS, "system-os", "linux", "Sole OS supported by the system")
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
Expand Down
50 changes: 50 additions & 0 deletions pkg/arch/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,56 @@ func TestHookHonorsDefaultPreferredArch(t *testing.T) {
)
}

func TestHookSelectsAllMatchingArthitecturesWhenPreferredArchIsNotSet(t *testing.T) {
resp := runWebhookTest(
t,
NewHandler(
fake.NewClientBuilder().Build(),
RegistryFunc(func(ctx context.Context, imagePullSecret, image string) ([]registry.Platform, error) {
assert.Equal(t, "ubuntu", image)
return []registry.Platform{
{OS: "linux", Architecture: "arm64"},
{OS: "linux", Architecture: "amd64"},
{OS: "windows", Architecture: "amd64"},
}, nil
}),
WithOS("linux"),
),
&v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Name: "object",
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Image: "ubuntu",
},
},
},
},
)
assert.True(t, resp.Allowed)
assert.Equal(t, http.StatusOK, int(resp.Result.Code))
require.Len(t, resp.Patches, 1)
assert.Contains(
t,
resp.Patches,
archNodeSelectorPatchForArchs("amd64", "arm64"),
)
assert.NotContains(
t,
resp.Patches,
jsonpatch.Operation{
Operation: "add",
Path: "/spec/nodeSelector",
Value: map[string]interface{}{
"kubernetes.io/arch": "amd64",
},
},
)
}

func TestHookAcceptsMultipleImagesAndAddsSelector(t *testing.T) {
resp := runWebhookTest(
t,
Expand Down
Loading