...

Source file src/k8s.io/kubernetes/test/e2e/common/node/image_credential_provider.go

Documentation: k8s.io/kubernetes/test/e2e/common/node

     1  /*
     2  Copyright 2022 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package node
    18  
    19  import (
    20  	"context"
    21  
    22  	"github.com/onsi/ginkgo/v2"
    23  
    24  	v1 "k8s.io/api/core/v1"
    25  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    26  	"k8s.io/apimachinery/pkg/util/uuid"
    27  	"k8s.io/kubernetes/test/e2e/feature"
    28  	"k8s.io/kubernetes/test/e2e/framework"
    29  	e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
    30  	imageutils "k8s.io/kubernetes/test/utils/image"
    31  	admissionapi "k8s.io/pod-security-admission/api"
    32  )
    33  
    34  var _ = SIGDescribe("ImageCredentialProvider", feature.KubeletCredentialProviders, func() {
    35  	f := framework.NewDefaultFramework("image-credential-provider")
    36  	f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
    37  	var podClient *e2epod.PodClient
    38  
    39  	ginkgo.BeforeEach(func() {
    40  		podClient = e2epod.NewPodClient(f)
    41  	})
    42  
    43  	/*
    44  		Release: v1.24
    45  		Testname: Test kubelet image pull with external credential provider plugins
    46  		Description: Create Pod with an image from a private registry. This test assumes that the kubelet credential provider plugin is enabled for the registry hosting imageutils.AgnhostPrivate.
    47  	*/
    48  	ginkgo.It("should be able to create pod with image credentials fetched from external credential provider ", func(ctx context.Context) {
    49  		privateimage := imageutils.GetConfig(imageutils.AgnhostPrivate)
    50  		name := "pod-auth-image-" + string(uuid.NewUUID())
    51  		pod := &v1.Pod{
    52  			ObjectMeta: metav1.ObjectMeta{
    53  				Name: name,
    54  			},
    55  			Spec: v1.PodSpec{
    56  				Containers: []v1.Container{
    57  					{
    58  						Name:            "container-auth-image",
    59  						Image:           privateimage.GetE2EImage(),
    60  						ImagePullPolicy: v1.PullAlways,
    61  					},
    62  				},
    63  			},
    64  		}
    65  
    66  		// CreateSync tests that the Pod is running and ready
    67  		podClient.CreateSync(ctx, pod)
    68  	})
    69  })
    70  

View as plain text