diff --git a/staging/src/k8s.io/sample-apiserver/artifacts/example/rc.yaml b/staging/src/k8s.io/sample-apiserver/artifacts/example/rc.yaml index d4fe6a48dc9..c2f05b74805 100644 --- a/staging/src/k8s.io/sample-apiserver/artifacts/example/rc.yaml +++ b/staging/src/k8s.io/sample-apiserver/artifacts/example/rc.yaml @@ -19,8 +19,8 @@ spec: - name: wardle-server # build from staging/src/k8s.io/sample-apiserver/artifacts/simple-image/Dockerfile # or - # docker pull gcr.io/kubernetes-e2e-test-images/sample-apiserver:1.10 - # docker tag gcr.io/kubernetes-e2e-test-images/sample-apiserver:1.10 kube-sample-apiserver:latest + # docker pull gcr.io/kubernetes-e2e-test-images/sample-apiserver:1.17 + # docker tag gcr.io/kubernetes-e2e-test-images/sample-apiserver:1.17 kube-sample-apiserver:latest image: kube-sample-apiserver:latest imagePullPolicy: Never args: [ "--etcd-servers=http://localhost:2379" ] diff --git a/test/conformance/testdata/conformance.txt b/test/conformance/testdata/conformance.txt index 6525febbdf8..31f2c290513 100644 --- a/test/conformance/testdata/conformance.txt +++ b/test/conformance/testdata/conformance.txt @@ -1,4 +1,4 @@ -test/e2e/apimachinery/aggregator.go: "Should be able to support the 1.10 Sample API Server using the current Aggregator" +test/e2e/apimachinery/aggregator.go: "Should be able to support the 1.17 Sample API Server using the current Aggregator" test/e2e/apimachinery/crd_conversion_webhook.go: "should be able to convert from CR v1 to CR v2" test/e2e/apimachinery/crd_conversion_webhook.go: "should be able to convert a non homogeneous list of CRs" test/e2e/apimachinery/crd_publish_openapi.go: "works for CRD with validation schema" diff --git a/test/e2e/apimachinery/aggregator.go b/test/e2e/apimachinery/aggregator.go index 86a0e7b287d..3c807bd412d 100644 --- a/test/e2e/apimachinery/aggregator.go +++ b/test/e2e/apimachinery/aggregator.go @@ -29,6 +29,7 @@ import ( rbacv1 "k8s.io/api/rbac/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" unstructuredv1 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/intstr" @@ -88,18 +89,18 @@ var _ = SIGDescribe("Aggregator", func() { /* Testname: aggregator-supports-the-sample-apiserver - Description: Ensure that the sample-apiserver code from 1.10 and compiled against 1.10 + Description: Ensure that the sample-apiserver code from 1.17 and compiled against 1.17 will work on the current Aggregator/API-Server. */ - framework.ConformanceIt("Should be able to support the 1.10 Sample API Server using the current Aggregator", func() { - // Testing a 1.10 version of the sample-apiserver + framework.ConformanceIt("Should be able to support the 1.17 Sample API Server using the current Aggregator", func() { + // Testing a 1.17 version of the sample-apiserver TestSampleAPIServer(f, aggrclient, imageutils.GetE2EImage(imageutils.APIServer)) }) }) func cleanTest(client clientset.Interface, aggrclient *aggregatorclient.Clientset, namespace string) { // delete the APIService first to avoid causing discovery errors - _ = aggrclient.ApiregistrationV1().APIServices().Delete("v1alpha1.wardle.k8s.io", nil) + _ = aggrclient.ApiregistrationV1().APIServices().Delete("v1alpha1.wardle.example.com", nil) _ = client.AppsV1().Deployments(namespace).Delete("sample-apiserver-deployment", nil) _ = client.CoreV1().Secrets(namespace).Delete("sample-apiserver-secret", nil) @@ -325,21 +326,21 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl // kubectl create -f apiservice.yaml _, err = aggrclient.ApiregistrationV1().APIServices().Create(&apiregistrationv1.APIService{ - ObjectMeta: metav1.ObjectMeta{Name: "v1alpha1.wardle.k8s.io"}, + ObjectMeta: metav1.ObjectMeta{Name: "v1alpha1.wardle.example.com"}, Spec: apiregistrationv1.APIServiceSpec{ Service: &apiregistrationv1.ServiceReference{ Namespace: namespace, Name: "sample-api", Port: pointer.Int32Ptr(aggregatorServicePort), }, - Group: "wardle.k8s.io", + Group: "wardle.example.com", Version: "v1alpha1", CABundle: context.signingCert, GroupPriorityMinimum: 2000, VersionPriority: 200, }, }) - framework.ExpectNoError(err, "creating apiservice %s with namespace %s", "v1alpha1.wardle.k8s.io", namespace) + framework.ExpectNoError(err, "creating apiservice %s with namespace %s", "v1alpha1.wardle.example.com", namespace) var ( currentAPIService *apiregistrationv1.APIService @@ -348,10 +349,10 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl err = pollTimed(100*time.Millisecond, 60*time.Second, func() (bool, error) { - currentAPIService, _ = aggrclient.ApiregistrationV1().APIServices().Get("v1alpha1.wardle.k8s.io", metav1.GetOptions{}) + currentAPIService, _ = aggrclient.ApiregistrationV1().APIServices().Get("v1alpha1.wardle.example.com", metav1.GetOptions{}) currentPods, _ = client.CoreV1().Pods(namespace).List(metav1.ListOptions{}) - request := restClient.Get().AbsPath("/apis/wardle.k8s.io/v1alpha1/namespaces/default/flunders") + request := restClient.Get().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders") request.SetHeader("Accept", "application/json") _, err := request.DoRaw() if err != nil { @@ -390,42 +391,49 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl flunderName := generateFlunderName("rest-flunder") // kubectl create -f flunders-1.yaml -v 9 - // curl -k -v -XPOST https://localhost/apis/wardle.k8s.io/v1alpha1/namespaces/default/flunders - // Request Body: {"apiVersion":"wardle.k8s.io/v1alpha1","kind":"Flunder","metadata":{"labels":{"sample-label":"true"},"name":"test-flunder","namespace":"default"}} - flunder := `{"apiVersion":"wardle.k8s.io/v1alpha1","kind":"Flunder","metadata":{"labels":{"sample-label":"true"},"name":"` + flunderName + `","namespace":"default"}}` - result := restClient.Post().AbsPath("/apis/wardle.k8s.io/v1alpha1/namespaces/default/flunders").Body([]byte(flunder)).Do() + // curl -k -v -XPOST https://localhost/apis/wardle.example.com/v1alpha1/namespaces/default/flunders + // Request Body: {"apiVersion":"wardle.example.com/v1alpha1","kind":"Flunder","metadata":{"labels":{"sample-label":"true"},"name":"test-flunder","namespace":"default"}} + flunder := `{"apiVersion":"wardle.example.com/v1alpha1","kind":"Flunder","metadata":{"labels":{"sample-label":"true"},"name":"` + flunderName + `","namespace":"default"}}` + result := restClient.Post().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders").Body([]byte(flunder)).SetHeader("Accept", "application/json").Do() framework.ExpectNoError(result.Error(), "creating a new flunders resource") var statusCode int result.StatusCode(&statusCode) if statusCode != 201 { framework.Failf("Flunders client creation response was status %d, not 201", statusCode) } + u := &unstructured.Unstructured{} + if err := result.Into(u); err != nil { + framework.ExpectNoError(err, "reading created response") + } + framework.ExpectEqual(u.GetAPIVersion(), "wardle.example.com/v1alpha1") + framework.ExpectEqual(u.GetKind(), "Flunder") + framework.ExpectEqual(u.GetName(), flunderName) pods, err := client.CoreV1().Pods(namespace).List(metav1.ListOptions{}) framework.ExpectNoError(err, "getting pods for flunders service") // kubectl get flunders -v 9 - // curl -k -v -XGET https://localhost/apis/wardle.k8s.io/v1alpha1/namespaces/default/flunders - contents, err := restClient.Get().AbsPath("/apis/wardle.k8s.io/v1alpha1/namespaces/default/flunders").SetHeader("Accept", "application/json").DoRaw() + // curl -k -v -XGET https://localhost/apis/wardle.example.com/v1alpha1/namespaces/default/flunders + contents, err := restClient.Get().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders").SetHeader("Accept", "application/json").DoRaw() framework.ExpectNoError(err, "attempting to get a newly created flunders resource") var flundersList samplev1alpha1.FlunderList err = json.Unmarshal(contents, &flundersList) - validateErrorWithDebugInfo(f, err, pods, "Error in unmarshalling %T response from server %s", contents, "/apis/wardle.k8s.io/v1alpha1") + validateErrorWithDebugInfo(f, err, pods, "Error in unmarshalling %T response from server %s", contents, "/apis/wardle.example.com/v1alpha1") if len(flundersList.Items) != 1 { framework.Failf("failed to get back the correct flunders list %v", flundersList) } // kubectl delete flunder test-flunder -v 9 - // curl -k -v -XDELETE https://35.193.112.40/apis/wardle.k8s.io/v1alpha1/namespaces/default/flunders/test-flunder - _, err = restClient.Delete().AbsPath("/apis/wardle.k8s.io/v1alpha1/namespaces/default/flunders/" + flunderName).DoRaw() + // curl -k -v -XDELETE https://35.193.112.40/apis/wardle.example.com/v1alpha1/namespaces/default/flunders/test-flunder + _, err = restClient.Delete().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders/" + flunderName).DoRaw() validateErrorWithDebugInfo(f, err, pods, "attempting to delete a newly created flunders(%v) resource", flundersList.Items) // kubectl get flunders -v 9 - // curl -k -v -XGET https://localhost/apis/wardle.k8s.io/v1alpha1/namespaces/default/flunders - contents, err = restClient.Get().AbsPath("/apis/wardle.k8s.io/v1alpha1/namespaces/default/flunders").SetHeader("Accept", "application/json").DoRaw() + // curl -k -v -XGET https://localhost/apis/wardle.example.com/v1alpha1/namespaces/default/flunders + contents, err = restClient.Get().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders").SetHeader("Accept", "application/json").DoRaw() framework.ExpectNoError(err, "confirming delete of a newly created flunders resource") err = json.Unmarshal(contents, &flundersList) - validateErrorWithDebugInfo(f, err, pods, "Error in unmarshalling %T response from server %s", contents, "/apis/wardle.k8s.io/v1alpha1") + validateErrorWithDebugInfo(f, err, pods, "Error in unmarshalling %T response from server %s", contents, "/apis/wardle.example.com/v1alpha1") if len(flundersList.Items) != 0 { framework.Failf("failed to get back the correct deleted flunders list %v", flundersList) } @@ -436,7 +444,7 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl resources, discoveryErr := client.Discovery().ServerPreferredNamespacedResources() groupVersionResources, err := discovery.GroupVersionResources(resources) framework.ExpectNoError(err, "getting group version resources for dynamic client") - gvr := schema.GroupVersionResource{Group: "wardle.k8s.io", Version: "v1alpha1", Resource: "flunders"} + gvr := schema.GroupVersionResource{Group: "wardle.example.com", Version: "v1alpha1", Resource: "flunders"} _, ok := groupVersionResources[gvr] if !ok { framework.Failf("could not find group version resource for dynamic client and wardle/flunders (discovery error: %v, discovery results: %#v)", discoveryErr, groupVersionResources) @@ -444,11 +452,11 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl dynamicClient := f.DynamicClient.Resource(gvr).Namespace(namespace) // kubectl create -f flunders-1.yaml - // Request Body: {"apiVersion":"wardle.k8s.io/v1alpha1","kind":"Flunder","metadata":{"labels":{"sample-label":"true"},"name":"test-flunder","namespace":"default"}} + // Request Body: {"apiVersion":"wardle.example.com/v1alpha1","kind":"Flunder","metadata":{"labels":{"sample-label":"true"},"name":"test-flunder","namespace":"default"}} testFlunder := samplev1alpha1.Flunder{ TypeMeta: metav1.TypeMeta{ Kind: "Flunder", - APIVersion: "wardle.k8s.io/v1alpha1", + APIVersion: "wardle.example.com/v1alpha1", }, ObjectMeta: metav1.ObjectMeta{Name: flunderName}, Spec: samplev1alpha1.FlunderSpec{}, diff --git a/test/e2e/kubectl/kubectl.go b/test/e2e/kubectl/kubectl.go index e2599c13f5d..e3f0cfd88ca 100644 --- a/test/e2e/kubectl/kubectl.go +++ b/test/e2e/kubectl/kubectl.go @@ -460,7 +460,7 @@ var _ = SIGDescribe("Kubectl client", func() { // tolerate discovery errors for non-k8s.io groups (like aggregated/crd groups) continue } - if gv.Group == "wardle.k8s.io" || gv.Group == "metrics.k8s.io" { + if gv.Group == "metrics.k8s.io" { // tolerate discovery errors for known test k8s.io groups like aggregated/metrics groups continue } diff --git a/test/images/sample-apiserver/Dockerfile b/test/images/sample-apiserver/Dockerfile index 2c1ca2d1add..6866a210526 100644 --- a/test/images/sample-apiserver/Dockerfile +++ b/test/images/sample-apiserver/Dockerfile @@ -12,25 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM k8s.gcr.io/kube-cross:v1.10.4-1 as build_k8s_1_10_sample_apiserver +FROM k8s.gcr.io/kube-cross:v1.13.4-1 as build_k8s_1_17_sample_apiserver ENV GOPATH /go RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin ENV PATH $GOPATH/bin:$PATH -# The e2e aggregator test was originally added in #50347 and is designed to test ability to run a 1.7 -# sample-apiserver in newer releases. please see e2e test named "Should be able to support the 1.7 Sample -# API Server using the current Aggregator" -RUN go get -d k8s.io/sample-apiserver \ - && cd ${GOPATH}/src/k8s.io/sample-apiserver \ - && git checkout --track origin/release-1.10 \ - && CGO_ENABLED=0 GOOS=linux GOARCH=BASEARCH go install . + +# The e2e aggregator test is designed to test ability to run sample-apiserver as an aggregated server. +# see e2e test named "Should be able to support the 1.17 Sample API Server using the current Aggregator" + +# Build v1.17.0 to ensure the current release supports a prior version of the sample apiserver +# Get without building to populate module cache +RUN GO111MODULE=on go get -d k8s.io/sample-apiserver@v0.17.0 +# Get with OS/ARCH-specific env to build +RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=BASEARCH go get k8s.io/sample-apiserver@v0.17.0 # for arm, go install uses go/bin/linux_arm, so just find the file and copy it to the root so # we can copy it out from this throw away container image from a standard location RUN find /go/bin -name sample-apiserver -exec cp {} / \; FROM BASEIMAGE -COPY --from=build_k8s_1_10_sample_apiserver /sample-apiserver /sample-apiserver +COPY --from=build_k8s_1_17_sample_apiserver /sample-apiserver /sample-apiserver ENTRYPOINT ["/sample-apiserver"] diff --git a/test/images/sample-apiserver/VERSION b/test/images/sample-apiserver/VERSION index c044b1a3269..b48f3226098 100644 --- a/test/images/sample-apiserver/VERSION +++ b/test/images/sample-apiserver/VERSION @@ -1 +1 @@ -1.10 +1.17 diff --git a/test/utils/image/manifest.go b/test/utils/image/manifest.go index cf48e88b46b..9fedd100d25 100644 --- a/test/utils/image/manifest.go +++ b/test/utils/image/manifest.go @@ -211,7 +211,7 @@ func initImageConfigs() map[int]Config { configs[AgnhostPrivate] = Config{PrivateRegistry, "agnhost", "2.6"} configs[AuthenticatedAlpine] = Config{gcAuthenticatedRegistry, "alpine", "3.7"} configs[AuthenticatedWindowsNanoServer] = Config{gcAuthenticatedRegistry, "windows-nanoserver", "v1"} - configs[APIServer] = Config{e2eRegistry, "sample-apiserver", "1.10"} + configs[APIServer] = Config{e2eRegistry, "sample-apiserver", "1.17"} configs[AppArmorLoader] = Config{e2eRegistry, "apparmor-loader", "1.0"} configs[BusyBox] = Config{dockerLibraryRegistry, "busybox", "1.29"} configs[CheckMetadataConcealment] = Config{e2eRegistry, "metadata-concealment", "1.2"}