Skip to content

Commit dd4e4f1

Browse files
authored
Merge pull request kubernetes#133262 from BenTheElder/no-authenticated-image-pulling
remove broken test that depends on expired credential, remove hardcoded credential, add TODOs
2 parents 924b324 + 8ace0fb commit dd4e4f1

File tree

4 files changed

+25
-217
lines changed

4 files changed

+25
-217
lines changed

test/e2e/common/node/runtime.go

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ package node
1919
import (
2020
"context"
2121
"fmt"
22-
"os"
2322
"path"
2423
"time"
2524

2625
v1 "k8s.io/api/core/v1"
27-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28-
"k8s.io/apimachinery/pkg/util/uuid"
2926
"k8s.io/kubernetes/pkg/kubelet/images"
3027
"k8s.io/kubernetes/test/e2e/framework"
3128
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
@@ -262,7 +259,7 @@ while true; do sleep 1; done
262259
// Images used for ConformanceContainer are not added into NodePrePullImageList, because this test is
263260
// testing image pulling, these images don't need to be prepulled. The ImagePullPolicy
264261
// is v1.PullAlways, so it won't be blocked by framework image pre-pull list check.
265-
imagePullTest := func(ctx context.Context, image string, hasSecret bool, expectedPhase v1.PodPhase, expectedPullStatus bool, windowsImage bool) {
262+
imagePullTest := func(ctx context.Context, image string, expectedPhase v1.PodPhase, expectedPullStatus bool, windowsImage bool) {
266263
command := []string{"/bin/sh", "-c", "while true; do sleep 1; done"}
267264
if windowsImage {
268265
// -t: Ping the specified host until stopped.
@@ -278,34 +275,7 @@ while true; do sleep 1; done
278275
},
279276
RestartPolicy: v1.RestartPolicyNever,
280277
}
281-
if hasSecret {
282-
// The service account only has pull permission
283-
auth := `
284-
{
285-
"auths": {
286-
"https://gcr.io": {
287-
"auth": "X2pzb25fa2V5OnsKICAidHlwZSI6ICJzZXJ2aWNlX2FjY291bnQiLAogICJwcm9qZWN0X2lkIjogImF1dGhlbnRpY2F0ZWQtaW1hZ2UtcHVsbGluZyIsCiAgInByaXZhdGVfa2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XMVJMbVZubEFpSEx1L0xcbmxtZkF3RFdtRWlJMFVnK1BMbm9Pdk81dFE1ZDRXMS94RU44bFA0cWtzcGtmZk1Rbk5oNFNZR0VlQlQzMlpxQ1RcbkpSZ2YwWGpveXZ2dXA5eFhqTWtYcnBZL3ljMXpmcVRaQzBNTzkvMVVjMWJSR2RaMmR5M2xSNU5XYXA3T1h5Zk9cblBQcE5Gb1BUWGd2M3FDcW5sTEhyR3pNPVxuLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLVxuIiwKICAiY2xpZW50X2VtYWlsIjogImltYWdlLXB1bGxpbmdAYXV0aGVudGljYXRlZC1pbWFnZS1wdWxsaW5nLmlhbS5nc2VydmljZWFjY291bnQuY29tIiwKICAiY2xpZW50X2lkIjogIjExMzc5NzkxNDUzMDA3MzI3ODcxMiIsCiAgImF1dGhfdXJpIjogImh0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbS9vL29hdXRoMi9hdXRoIiwKICAidG9rZW5fdXJpIjogImh0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbS9vL29hdXRoMi90b2tlbiIsCiAgImF1dGhfcHJvdmlkZXJfeDUwOV9jZXJ0X3VybCI6ICJodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9vYXV0aDIvdjEvY2VydHMiLAogICJjbGllbnRfeDUwOV9jZXJ0X3VybCI6ICJodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9yb2JvdC92MS9tZXRhZGF0YS94NTA5L2ltYWdlLXB1bGxpbmclNDBhdXRoZW50aWNhdGVkLWltYWdlLXB1bGxpbmcuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20iCn0=",
288-
"email": "image-pulling@authenticated-image-pulling.iam.gserviceaccount.com"
289-
}
290-
}
291-
}`
292-
// we might be told to use a different docker config JSON.
293-
if framework.TestContext.DockerConfigFile != "" {
294-
contents, err := os.ReadFile(framework.TestContext.DockerConfigFile)
295-
framework.ExpectNoError(err)
296-
auth = string(contents)
297-
}
298-
secret := &v1.Secret{
299-
Data: map[string][]byte{v1.DockerConfigJsonKey: []byte(auth)},
300-
Type: v1.SecretTypeDockerConfigJson,
301-
}
302-
secret.Name = "image-pull-secret-" + string(uuid.NewUUID())
303-
ginkgo.By("create image pull secret")
304-
_, err := f.ClientSet.CoreV1().Secrets(f.Namespace.Name).Create(ctx, secret, metav1.CreateOptions{})
305-
framework.ExpectNoError(err)
306-
ginkgo.DeferCleanup(f.ClientSet.CoreV1().Secrets(f.Namespace.Name).Delete, secret.Name, metav1.DeleteOptions{})
307-
container.ImagePullSecrets = []string{secret.Name}
308-
}
278+
309279
// checkContainerStatus checks whether the container status matches expectation.
310280
checkContainerStatus := func(ctx context.Context) error {
311281
status, err := container.GetStatus(ctx)
@@ -370,29 +340,24 @@ while true; do sleep 1; done
370340

371341
f.It("should not be able to pull image from invalid registry", f.WithNodeConformance(), func(ctx context.Context) {
372342
image := imageutils.GetE2EImage(imageutils.InvalidRegistryImage)
373-
imagePullTest(ctx, image, false, v1.PodPending, true, false)
343+
imagePullTest(ctx, image, v1.PodPending, true, false)
374344
})
375345

376346
f.It("should be able to pull image", f.WithNodeConformance(), func(ctx context.Context) {
377347
// NOTE(claudiub): The agnhost image is supposed to work on both Linux and Windows.
378348
image := imageutils.GetE2EImage(imageutils.Agnhost)
379-
imagePullTest(ctx, image, false, v1.PodRunning, false, false)
349+
imagePullTest(ctx, image, v1.PodRunning, false, false)
380350
})
381351

352+
// TODO: https://github.com/kubernetes/kubernetes/issues/130271
353+
// Switch this to use a locally hosted private image and not depend on this host
382354
f.It("should not be able to pull from private registry without secret", f.WithNodeConformance(), func(ctx context.Context) {
383355
image := imageutils.GetE2EImage(imageutils.AuthenticatedAlpine)
384-
imagePullTest(ctx, image, false, v1.PodPending, true, false)
356+
imagePullTest(ctx, image, v1.PodPending, true, false)
385357
})
386358

387-
f.It("should be able to pull from private registry with secret", f.WithNodeConformance(), func(ctx context.Context) {
388-
image := imageutils.GetE2EImage(imageutils.AuthenticatedAlpine)
389-
isWindows := false
390-
if framework.NodeOSDistroIs("windows") {
391-
image = imageutils.GetE2EImage(imageutils.AuthenticatedWindowsNanoServer)
392-
isWindows = true
393-
}
394-
imagePullTest(ctx, image, true, v1.PodRunning, false, isWindows)
395-
})
359+
// TODO: https://github.com/kubernetes/kubernetes/issues/130271
360+
// Add a sustainable test for pulling with a private registry secret
396361
})
397362
})
398363
})

test/e2e_node/runtime_conformance_test.go

Lines changed: 0 additions & 161 deletions
This file was deleted.

test/images/.permitted-images

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# The sources for which are in test/images/agnhost.
55
# If agnhost is missing functionality for your tests, please reach out to SIG Testing.
66
gcr.io/authenticated-image-pulling/alpine
7-
gcr.io/authenticated-image-pulling/windows-nanoserver
87
gcr.io/k8s-authenticated-test/agnhost
98
invalid.registry.k8s.io/invalid/alpine
109
registry.k8s.io/build-image/distroless-iptables

test/utils/image/manifest.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,17 @@ func readFromURL(url string, writer io.Writer) error {
129129

130130
var (
131131
initRegistry = RegistryList{
132-
GcAuthenticatedRegistry: "gcr.io/authenticated-image-pulling",
133-
PromoterE2eRegistry: "registry.k8s.io/e2e-test-images",
134-
BuildImageRegistry: "registry.k8s.io/build-image",
135-
InvalidRegistry: "invalid.registry.k8s.io/invalid",
136-
GcEtcdRegistry: "registry.k8s.io",
137-
GcRegistry: "registry.k8s.io",
138-
SigStorageRegistry: "registry.k8s.io/sig-storage",
132+
// TODO: https://github.com/kubernetes/kubernetes/issues/130271
133+
// Eliminate GcAuthenticatedRegistry.
134+
GcAuthenticatedRegistry: "gcr.io/authenticated-image-pulling",
135+
PromoterE2eRegistry: "registry.k8s.io/e2e-test-images",
136+
BuildImageRegistry: "registry.k8s.io/build-image",
137+
InvalidRegistry: "invalid.registry.k8s.io/invalid",
138+
GcEtcdRegistry: "registry.k8s.io",
139+
GcRegistry: "registry.k8s.io",
140+
SigStorageRegistry: "registry.k8s.io/sig-storage",
141+
// TODO: https://github.com/kubernetes/kubernetes/issues/130271
142+
// Eliminate PrivateRegistry.
139143
PrivateRegistry: "gcr.io/k8s-authenticated-test",
140144
DockerLibraryRegistry: "docker.io/library",
141145
CloudProviderGcpRegistry: "registry.k8s.io/cloud-provider-gcp",
@@ -152,15 +156,17 @@ const (
152156
// Agnhost image
153157
Agnhost
154158
// AgnhostPrivate image
159+
// TODO: https://github.com/kubernetes/kubernetes/issues/130271
160+
// Eliminate this.
155161
AgnhostPrivate
156162
// APIServer image
157163
APIServer
158164
// AppArmorLoader image
159165
AppArmorLoader
160166
// AuthenticatedAlpine image
167+
// TODO: https://github.com/kubernetes/kubernetes/issues/130271
168+
// Eliminate this.
161169
AuthenticatedAlpine
162-
// AuthenticatedWindowsNanoServer image
163-
AuthenticatedWindowsNanoServer
164170
// BusyBox image
165171
BusyBox
166172
// DistrolessIptables Image
@@ -217,7 +223,6 @@ func initImageConfigs(list RegistryList) (map[ImageID]Config, map[ImageID]Config
217223
configs[Agnhost] = Config{list.PromoterE2eRegistry, "agnhost", "2.56"}
218224
configs[AgnhostPrivate] = Config{list.PrivateRegistry, "agnhost", "2.6"}
219225
configs[AuthenticatedAlpine] = Config{list.GcAuthenticatedRegistry, "alpine", "3.7"}
220-
configs[AuthenticatedWindowsNanoServer] = Config{list.GcAuthenticatedRegistry, "windows-nanoserver", "v1"}
221226
configs[APIServer] = Config{list.PromoterE2eRegistry, "sample-apiserver", "1.29.2"}
222227
configs[AppArmorLoader] = Config{list.PromoterE2eRegistry, "apparmor-loader", "1.4"}
223228
configs[BusyBox] = Config{list.PromoterE2eRegistry, "busybox", "1.37.0-1"}
@@ -267,7 +272,7 @@ func GetMappedImageConfigs(originalImageConfigs map[ImageID]Config, repo string)
267272
for i, config := range originalImageConfigs {
268273
switch i {
269274
case InvalidRegistryImage, AuthenticatedAlpine,
270-
AuthenticatedWindowsNanoServer, AgnhostPrivate:
275+
AgnhostPrivate:
271276
// These images are special and can't be run out of the cloud - some because they
272277
// are authenticated, and others because they are not real images. Tests that depend
273278
// on these images can't be run without access to the public internet.

0 commit comments

Comments
 (0)