Commit f5ee25e2 authored by Hannes Hoerl's avatar Hannes Hoerl

Merge remote-tracking branch 'origin/master' into release-1.14

parents 06860bb0 1d441c1f
......@@ -15,51 +15,7 @@
# This file creates a standard build environment for building cross
# platform go binary for the architecture kubernetes cares about.
FROM golang:1.12.0
################################################################################
# this is from the upstream golang image source so we can get go1.2.1
# https://github.com/docker-library/golang/blob/fd272b2b72db82a0bd516ce3d09bba624651516c/1.12/stretch/Dockerfile#L12-L44
# TODO(bentheelder): remove this block
################################################################################
ENV GOLANG_VERSION 1.12.1
RUN set -eux; \
\
# this "case" statement is generated via "update.sh"
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) goRelArch='linux-amd64'; goRelSha256='2a3fdabf665496a0db5f41ec6af7a9b15a49fbe71a85a50ca38b1f13a103aeec' ;; \
armhf) goRelArch='linux-armv6l'; goRelSha256='ceac33f07f8fdbccd6c6f7339db33479e1be8c206e67458ba259470fe796dbf2' ;; \
arm64) goRelArch='linux-arm64'; goRelSha256='10dba44cf95c7aa7abc3c72610c12ebcaf7cad6eed761d5ad92736ca3bc0d547' ;; \
i386) goRelArch='linux-386'; goRelSha256='af74b6572dd0c133e5de121928616eab60a6252c66f6d9b15007c82207416a2c' ;; \
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='e1258c81f420c88339abf40888423904c0023497b4e9bbffac9ee484597a57d3' ;; \
s390x) goRelArch='linux-s390x'; goRelSha256='a9b8f49be6b2083e2586c2ce8a2a86d5dbf47cca64ac6195546a81c9927f9513' ;; \
*) goRelArch='src'; goRelSha256='0be127684df4b842a64e58093154f9d15422f1405f1fcff4b2c36ffc6a15818a'; \
echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \
esac; \
\
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
wget -O go.tgz "$url"; \
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \
\
if [ "$goRelArch" = 'src' ]; then \
echo >&2; \
echo >&2 'error: UNIMPLEMENTED'; \
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
echo >&2; \
exit 1; \
fi; \
\
export PATH="/usr/local/go/bin:$PATH"; \
go version
################################################################################
# below is our usual sources
################################################################################
FROM golang:1.12.1
ENV GOARM 7
ENV KUBE_DYNAMIC_CROSSPLATFORMS \
......
......@@ -25,7 +25,7 @@ ALL_ARCH = amd64 arm arm64 ppc64le s390x
CACHEBUST?=1
BASEIMAGE=k8s.gcr.io/debian-base-$(ARCH):0.4.1
CNI_VERSION=v0.6.0
CNI_VERSION=v0.7.5
TEMP_DIR:=$(shell mktemp -d)
CNI_TARBALL=cni-plugins-$(ARCH)-$(CNI_VERSION).tgz
......
......@@ -5,7 +5,7 @@ License: ASL 2.0
Summary: Container Cluster Manager - Kubernetes Cluster Bootstrapping Tool
Requires: kubelet >= 1.8.0
Requires: kubectl >= 1.8.0
Requires: kubernetes-cni >= 0.6.0
Requires: kubernetes-cni >= 0.7.5
Requires: cri-tools >= 1.11.0
URL: https://kubernetes.io
......
......@@ -11,7 +11,7 @@ Requires: ebtables
Requires: ethtool
Requires: iproute
Requires: iptables >= 1.4.21
Requires: kubernetes-cni >= 0.6.0
Requires: kubernetes-cni >= 0.7.5
Requires: socat
Requires: util-linux
......
......@@ -17,13 +17,13 @@ load("//build:workspace_mirror.bzl", "mirror")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("@io_bazel_rules_docker//container:container.bzl", "container_pull")
CNI_VERSION = "0.6.0"
CNI_VERSION = "0.7.5"
_CNI_TARBALL_ARCH_SHA256 = {
"amd64": "f04339a21b8edf76d415e7f17b620e63b8f37a76b2f706671587ab6464411f2d",
"arm": "ffb62021d2fc6e1266dc6ef7f2058125b6e6b44c016291a2b04a15ed9b4be70a",
"arm64": "016bbc989877e35e3cd49fafe11415fb2717e52c74fde6b1650411154cb91b81",
"ppc64le": "dd38dec69b167cfe40ecbba4b18cfe5b4296f2e49b90c00804b3988ef968e859",
"s390x": "7708289eee7e52ad055407c421033d8e593f5cf1a0b43a872f09eb4e1508aafc",
"amd64": "3ca15c0a18ee830520cf3a95408be826cbd255a1535a38e0be9608b25ad8bf64",
"arm": "0eb4a528b5b2e4ce23ebc96e41b2f5280d5a64d41eec8dd8b16c3d66aaa0f6b8",
"arm64": "7fec91af78e9548df306f0ec43bea527c8c10cc3a9682c33e971c8522a7fcded",
"ppc64le": "9164a26ed8dd398b2fe3b15d9d456271dfa59aa537528d10572ea9fa2cef7679",
"s390x": "415cdcf02c65c22f5b7e55b0ab61208a10f2b95a0c8310176c771d07a9f448cf",
}
CRI_TOOLS_VERSION = "1.12.0"
......
......@@ -323,7 +323,7 @@ function find-tar() {
# KUBE_MANIFESTS_TAR
function find-release-tars() {
SERVER_BINARY_TAR=$(find-tar kubernetes-server-linux-amd64.tar.gz)
if [[ "${NUM_WINDOWS_NODES}" -gt "0" && "${USE_RELEASE_NODE_BINARIES:-false}" == "false" ]]; then
if [[ "${NUM_WINDOWS_NODES}" -gt "0" ]]; then
NODE_BINARY_TAR=$(find-tar kubernetes-node-windows-amd64.tar.gz)
fi
......
......@@ -24,8 +24,8 @@ set -o nounset
set -o pipefail
### Hardcoded constants
DEFAULT_CNI_VERSION="v0.6.0"
DEFAULT_CNI_SHA1="d595d3ded6499a64e8dac02466e2f5f2ce257c9f"
DEFAULT_CNI_VERSION="v0.7.5"
DEFAULT_CNI_SHA1="52e9d2de8a5f927307d9397308735658ee44ab8d"
DEFAULT_NPD_VERSION="v0.6.0"
DEFAULT_NPD_SHA1="a28e960a21bb74bc0ae09c267b6a340f30e5b3a6"
DEFAULT_CRICTL_VERSION="v1.12.0"
......
......@@ -63,11 +63,25 @@ var (
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/
You can now join any number of machines by running the following on each node
as root:
{{.joinCommand}}
{{if .ControlPlaneEndpoint -}}
{{if .UploadCerts -}}
You can now join any number of the control-plane node running the following command on each as root:
{{.joinControlPlaneCommand}}
Please note that the certificate-key gives access to cluster sensitive data, keep it secret!
As a safeguard, uploaded-certs will be deleted in two hours; If necessary, you can use
"kubeadm init phase upload-certs --experimental-upload-certs" to reload certs afterward.
{{else -}}
You can now join any number of control-plane nodes by copying certificate authorities
and service account keys on each node and then running the following as root:
{{.joinControlPlaneCommand}}
{{end}}{{end}}Then you can join any number of worker nodes by running the following on each as root:
{{.joinWorkerCommand}}
`)))
)
......@@ -509,14 +523,22 @@ func (d *initData) Tokens() []string {
}
func printJoinCommand(out io.Writer, adminKubeConfigPath, token string, i *initData) error {
joinCommand, err := cmdutil.GetJoinCommand(adminKubeConfigPath, token, i.certificateKey, i.skipTokenPrint, i.uploadCerts, i.skipCertificateKeyPrint)
joinControlPlaneCommand, err := cmdutil.GetJoinControlPlaneCommand(adminKubeConfigPath, token, i.certificateKey, i.skipTokenPrint, i.skipCertificateKeyPrint)
if err != nil {
return err
}
joinWorkerCommand, err := cmdutil.GetJoinWorkerCommand(adminKubeConfigPath, token, i.skipTokenPrint)
if err != nil {
return err
}
ctx := map[string]string{
"KubeConfigPath": adminKubeConfigPath,
"joinCommand": joinCommand,
ctx := map[string]interface{}{
"KubeConfigPath": adminKubeConfigPath,
"ControlPlaneEndpoint": i.Cfg().ControlPlaneEndpoint,
"UploadCerts": i.uploadCerts,
"joinControlPlaneCommand": joinControlPlaneCommand,
"joinWorkerCommand": joinWorkerCommand,
}
return initDoneTempl.Execute(out, ctx)
......
......@@ -228,11 +228,8 @@ func RunCreateToken(out io.Writer, client clientset.Interface, cfgPath string, c
// if --print-join-command was specified, print the full `kubeadm join` command
// otherwise, just print the token
if printJoinCommand {
key := ""
skipTokenPrint := false
uploadCerts := false
skipCertificateKeyPrint := false
joinCommand, err := cmdutil.GetJoinCommand(kubeConfigFile, internalcfg.BootstrapTokens[0].Token.String(), key, skipTokenPrint, uploadCerts, skipCertificateKeyPrint)
joinCommand, err := cmdutil.GetJoinWorkerCommand(kubeConfigFile, internalcfg.BootstrapTokens[0].Token.String(), skipTokenPrint)
if err != nil {
return errors.Wrap(err, "failed to get join command")
}
......
......@@ -30,19 +30,24 @@ import (
)
var joinCommandTemplate = template.Must(template.New("join").Parse(`` +
`{{if .UploadCerts}}You can now join any number of control-plane node running the following command on each as a root:{{else}}You can now join any number of control-plane node by copying the required certificate authorities on each node and then running the following as root:{{end}}
kubeadm join {{.ControlPlaneHostPort}} --token {{.Token}}{{range $h := .CAPubKeyPins}} --discovery-token-ca-cert-hash {{$h}}{{end}} --experimental-control-plane {{if .UploadCerts}}--certificate-key {{.CertificateKey}}
Please note that the certificate-key gives access to cluster sensitive data, keep it secret!
As a safeguard, uploaded-certs will be deleted in two hours; If necessary, you can use kubeadm init phase upload-certs to reload certs afterward.{{end}}
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join {{.ControlPlaneHostPort}} --token {{.Token}}{{range $h := .CAPubKeyPins}} --discovery-token-ca-cert-hash {{$h}}{{end}}`,
`kubeadm join {{.ControlPlaneHostPort}} --token {{.Token}} \
{{range $h := .CAPubKeyPins}}--discovery-token-ca-cert-hash {{$h}} {{end}}{{if .ControlPlane}}\
--experimental-control-plane {{if .CertificateKey}}--certificate-key {{.CertificateKey}}{{end}}{{end}}`,
))
// GetJoinCommand returns the kubeadm join command for a given token and
// GetJoinWorkerCommand returns the kubeadm join command for a given token and
// and Kubernetes cluster (the current cluster in the kubeconfig file)
func GetJoinCommand(kubeConfigFile, token, key string, skipTokenPrint, uploadCerts, skipCertificateKeyPrint bool) (string, error) {
func GetJoinWorkerCommand(kubeConfigFile, token string, skipTokenPrint bool) (string, error) {
return getJoinCommand(kubeConfigFile, token, "", false, skipTokenPrint, false)
}
// GetJoinControlPlaneCommand returns the kubeadm join command for a given token and
// and Kubernetes cluster (the current cluster in the kubeconfig file)
func GetJoinControlPlaneCommand(kubeConfigFile, token, key string, skipTokenPrint, skipCertificateKeyPrint bool) (string, error) {
return getJoinCommand(kubeConfigFile, token, key, true, skipTokenPrint, skipCertificateKeyPrint)
}
func getJoinCommand(kubeConfigFile, token, key string, controlPlane, skipTokenPrint, skipCertificateKeyPrint bool) (string, error) {
// load the kubeconfig file to get the CA certificate and endpoint
config, err := clientcmd.LoadFromFile(kubeConfigFile)
if err != nil {
......@@ -81,8 +86,8 @@ func GetJoinCommand(kubeConfigFile, token, key string, skipTokenPrint, uploadCer
"Token": token,
"CAPubKeyPins": publicKeyPins,
"ControlPlaneHostPort": strings.Replace(clusterConfig.Server, "https://", "", -1),
"UploadCerts": uploadCerts,
"CertificateKey": key,
"ControlPlane": controlPlane,
}
if skipTokenPrint {
......
......@@ -585,7 +585,7 @@ func getLocalIP() ([]v1.NodeAddress, error) {
)
klog.V(4).Infof("Detected local IP address as %q", ipnet.IP.String())
} else {
klog.Warningf("Failed to patch IP as MAC address %q does not belong to a VMware platform", vmMACAddr)
klog.V(4).Infof("Failed to patch IP for interface %q as MAC address %q does not belong to a VMware platform", i.Name, vmMACAddr)
}
}
}
......
......@@ -439,7 +439,7 @@ func NewKubectlCommand(in io.Reader, out, err io.Writer) *cobra.Command {
addProfilingFlags(flags)
kubeConfigFlags := genericclioptions.NewConfigFlags(true)
kubeConfigFlags := genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag()
kubeConfigFlags.AddFlags(flags)
matchVersionKubeConfigFlags := cmdutil.NewMatchVersionFlags(kubeConfigFlags)
matchVersionKubeConfigFlags.AddFlags(cmds.PersistentFlags())
......
......@@ -674,6 +674,9 @@ func (proxier *Proxier) syncProxyRules() {
if svcInfo, ok := proxier.serviceMap[svcPortName]; ok && svcInfo != nil && svcInfo.GetProtocol() == v1.ProtocolUDP {
klog.V(2).Infof("Stale udp service %v -> %s", svcPortName, svcInfo.ClusterIPString())
staleServices.Insert(svcInfo.ClusterIPString())
for _, extIP := range svcInfo.ExternalIPStrings() {
staleServices.Insert(extIP)
}
}
}
......
......@@ -741,6 +741,9 @@ func (proxier *Proxier) syncProxyRules() {
if svcInfo, ok := proxier.serviceMap[svcPortName]; ok && svcInfo != nil && svcInfo.GetProtocol() == v1.ProtocolUDP {
klog.V(2).Infof("Stale udp service %v -> %s", svcPortName, svcInfo.ClusterIPString())
staleServices.Insert(svcInfo.ClusterIPString())
for _, extIP := range svcInfo.ExternalIPStrings() {
staleServices.Insert(extIP)
}
}
}
......
......@@ -59,6 +59,7 @@ go_library(
"//vendor/k8s.io/utils/nsenter:go_default_library",
],
"@io_bazel_rules_go//go/platform:windows": [
"//vendor/k8s.io/utils/keymutex:go_default_library",
"//vendor/k8s.io/utils/nsenter:go_default_library",
"//vendor/k8s.io/utils/path:go_default_library",
],
......
......@@ -28,6 +28,7 @@ import (
"strings"
"k8s.io/klog"
"k8s.io/utils/keymutex"
utilpath "k8s.io/utils/path"
)
......@@ -48,6 +49,9 @@ func New(mounterPath string) Interface {
}
}
// acquire lock for smb mount
var getSMBMountMutex = keymutex.NewHashed(0)
// Mount : mounts source to target with given options.
// currently only supports cifs(smb), bind mount(for disk)
func (mounter *Mounter) Mount(source string, target string, fstype string, options []string) error {
......@@ -83,6 +87,10 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio
return fmt.Errorf("only cifs mount is supported now, fstype: %q, mounting source (%q), target (%q), with options (%q)", fstype, source, target, options)
}
// lock smb mount for the same source
getSMBMountMutex.LockKey(source)
defer getSMBMountMutex.UnlockKey(source)
if output, err := newSMBMapping(options[0], options[1], source); err != nil {
if isSMBMappingExist(source) {
klog.V(2).Infof("SMB Mapping(%s) already exists, now begin to remove and remount", source)
......
......@@ -82,6 +82,7 @@ go_library(
"//test/e2e/framework:go_default_library",
"//test/e2e/framework/metrics:go_default_library",
"//test/utils:go_default_library",
"//test/utils/crd:go_default_library",
"//test/utils/image:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/onsi/ginkgo:go_default_library",
......
......@@ -32,6 +32,7 @@ import (
"k8s.io/client-go/dynamic"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/utils/crd"
imageutils "k8s.io/kubernetes/test/utils/image"
. "github.com/onsi/ginkgo"
......@@ -100,7 +101,7 @@ var _ = SIGDescribe("CustomResourceConversionWebhook [Feature:CustomResourceWebh
})
It("Should be able to convert from CR v1 to CR v2", func() {
testcrd, err := framework.CreateMultiVersionTestCRD(f, "stable.example.com", apiVersions,
testcrd, err := crd.CreateMultiVersionTestCRD(f, "stable.example.com", apiVersions,
&v1beta1.WebhookClientConfig{
CABundle: context.signingCert,
Service: &v1beta1.ServiceReference{
......@@ -116,7 +117,7 @@ var _ = SIGDescribe("CustomResourceConversionWebhook [Feature:CustomResourceWebh
})
It("Should be able to convert a non homogeneous list of CRs", func() {
testcrd, err := framework.CreateMultiVersionTestCRD(f, "stable.example.com", apiVersions,
testcrd, err := crd.CreateMultiVersionTestCRD(f, "stable.example.com", apiVersions,
&v1beta1.WebhookClientConfig{
CABundle: context.signingCert,
Service: &v1beta1.ServiceReference{
......@@ -325,7 +326,7 @@ func testCustomResourceConversionWebhook(f *framework.Framework, crd *v1beta1.Cu
verifyV2Object(f, crd, v2crd)
}
func testCRListConversion(f *framework.Framework, testCrd *framework.TestCrd) {
func testCRListConversion(f *framework.Framework, testCrd *crd.TestCrd) {
crd := testCrd.Crd
customResourceClients := testCrd.DynamicClients
name1 := "cr-instance-1"
......@@ -346,7 +347,7 @@ func testCRListConversion(f *framework.Framework, testCrd *framework.TestCrd) {
Expect(err).To(BeNil())
// Now cr-instance-1 is stored as v1. lets change storage version
crd, err = integration.UpdateCustomResourceDefinitionWithRetry(testCrd.ApiExtensionClient, crd.Name, func(c *v1beta1.CustomResourceDefinition) {
crd, err = integration.UpdateCustomResourceDefinitionWithRetry(testCrd.APIExtensionClient, crd.Name, func(c *v1beta1.CustomResourceDefinition) {
c.Spec.Versions = alternativeApiVersions
})
Expect(err).To(BeNil())
......
......@@ -37,6 +37,7 @@ import (
k8sclientset "k8s.io/client-go/kubernetes"
openapiutil "k8s.io/kube-openapi/pkg/util"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/utils/crd"
"sigs.k8s.io/yaml"
)
......@@ -58,7 +59,7 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
framework.Failf("%v", err)
}
meta := fmt.Sprintf(metaPattern, crd.Kind, crd.ApiGroup, crd.Versions[0].Name, "test-foo")
meta := fmt.Sprintf(metaPattern, crd.Kind, crd.APIGroup, crd.Versions[0].Name, "test-foo")
ns := fmt.Sprintf("--namespace=%v", f.Namespace.Name)
By("client-side validation (kubectl create and apply) allows request with known and required properties")
......@@ -126,7 +127,7 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
framework.Failf("%v", err)
}
meta := fmt.Sprintf(metaPattern, crd.Kind, crd.ApiGroup, crd.Versions[0].Name, "test-cr")
meta := fmt.Sprintf(metaPattern, crd.Kind, crd.APIGroup, crd.Versions[0].Name, "test-cr")
ns := fmt.Sprintf("--namespace=%v", f.Namespace.Name)
By("client-side validation (kubectl create and apply) allows request with any unknown properties")
......@@ -164,8 +165,8 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
if err != nil {
framework.Failf("%v", err)
}
if crdFoo.ApiGroup == crdWaldo.ApiGroup {
framework.Failf("unexpected: CRDs should be of different group %v, %v", crdFoo.ApiGroup, crdWaldo.ApiGroup)
if crdFoo.APIGroup == crdWaldo.APIGroup {
framework.Failf("unexpected: CRDs should be of different group %v, %v", crdFoo.APIGroup, crdWaldo.APIGroup)
}
if err := waitForDefinition(f.ClientSet, definitionName(crdWaldo, "v1beta1"), schemaWaldo); err != nil {
framework.Failf("%v", err)
......@@ -206,8 +207,8 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
if err != nil {
framework.Failf("%v", err)
}
if crdFoo.ApiGroup != crdWaldo.ApiGroup {
framework.Failf("unexpected: CRDs should be of the same group %v, %v", crdFoo.ApiGroup, crdWaldo.ApiGroup)
if crdFoo.APIGroup != crdWaldo.APIGroup {
framework.Failf("unexpected: CRDs should be of the same group %v, %v", crdFoo.APIGroup, crdWaldo.APIGroup)
}
if err := waitForDefinition(f.ClientSet, definitionName(crdWaldo, "v5"), schemaWaldo); err != nil {
framework.Failf("%v", err)
......@@ -233,8 +234,8 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
if err != nil {
framework.Failf("%v", err)
}
if crdFoo.ApiGroup != crdWaldo.ApiGroup {
framework.Failf("unexpected: CRDs should be of the same group %v, %v", crdFoo.ApiGroup, crdWaldo.ApiGroup)
if crdFoo.APIGroup != crdWaldo.APIGroup {
framework.Failf("unexpected: CRDs should be of the same group %v, %v", crdFoo.APIGroup, crdWaldo.APIGroup)
}
if err := waitForDefinition(f.ClientSet, definitionName(crdWaldo, "v6"), schemaWaldo); err != nil {
framework.Failf("%v", err)
......@@ -265,7 +266,7 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
By("rename a version")
patch := []byte(`{"spec":{"versions":[{"name":"v2","served":true,"storage":true},{"name":"v4","served":true,"storage":false}]}}`)
crdMultiVer.Crd, err = crdMultiVer.ApiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Patch(crdMultiVer.GetMetaName(), types.MergePatchType, patch)
crdMultiVer.Crd, err = crdMultiVer.APIExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Patch(crdMultiVer.GetMetaName(), types.MergePatchType, patch)
if err != nil {
framework.Failf("%v", err)
}
......@@ -307,7 +308,7 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
By("mark a version not serverd")
crd.Crd.Spec.Versions[1].Served = false
crd.Crd, err = crd.ApiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Update(crd.Crd)
crd.Crd, err = crd.APIExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Update(crd.Crd)
if err != nil {
framework.Failf("%v", err)
}
......@@ -327,7 +328,7 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
})
})
func setupCRD(f *framework.Framework, schema []byte, groupSuffix string, versions ...string) (*framework.TestCrd, error) {
func setupCRD(f *framework.Framework, schema []byte, groupSuffix string, versions ...string) (*crd.TestCrd, error) {
group := fmt.Sprintf("%s-test-%s.k8s.io", f.BaseName, groupSuffix)
if len(versions) == 0 {
return nil, fmt.Errorf("require at least one version for CRD")
......@@ -343,7 +344,7 @@ func setupCRD(f *framework.Framework, schema []byte, groupSuffix string, version
}
apiVersions[0].Storage = true
crd, err := framework.CreateMultiVersionTestCRD(f, group, apiVersions, nil)
crd, err := crd.CreateMultiVersionTestCRD(f, group, apiVersions, nil)
if err != nil {
return nil, fmt.Errorf("failed to create CRD: %v", err)
}
......@@ -366,7 +367,7 @@ func setupCRD(f *framework.Framework, schema []byte, groupSuffix string, version
return crd, nil
}
func cleanupCRD(f *framework.Framework, crd *framework.TestCrd) error {
func cleanupCRD(f *framework.Framework, crd *crd.TestCrd) error {
crd.CleanUp()
for _, v := range crd.Versions {
name := definitionName(crd, v.Name)
......@@ -378,13 +379,13 @@ func cleanupCRD(f *framework.Framework, crd *framework.TestCrd) error {
}
// patchSchema takes schema in YAML and patches it to given CRD in given version
func patchSchema(schema []byte, crd *framework.TestCrd) error {
func patchSchema(schema []byte, crd *crd.TestCrd) error {
s, err := utilyaml.ToJSON(schema)
if err != nil {
return fmt.Errorf("failed to create json patch: %v", err)
}
patch := []byte(fmt.Sprintf(`{"spec":{"validation":{"openAPIV3Schema":%s}}}`, string(s)))
crd.Crd, err = crd.ApiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Patch(crd.GetMetaName(), types.MergePatchType, patch)
crd.Crd, err = crd.APIExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Patch(crd.GetMetaName(), types.MergePatchType, patch)
return err
}
......@@ -484,8 +485,8 @@ func verifyKubectlExplain(name, pattern string) error {
}
// definitionName returns the openapi definition name for given CRD in given version
func definitionName(crd *framework.TestCrd, version string) string {
return openapiutil.ToRESTFriendlyName(fmt.Sprintf("%s/%s/%s", crd.ApiGroup, version, crd.Kind))
func definitionName(crd *crd.TestCrd, version string) string {
return openapiutil.ToRESTFriendlyName(fmt.Sprintf("%s/%s/%s", crd.APIGroup, version, crd.Kind))
}
var schemaFoo = []byte(`description: Foo CRD for Testing
......
......@@ -20,6 +20,7 @@ import (
utilversion "k8s.io/apimachinery/pkg/util/version"
"k8s.io/apiserver/pkg/endpoints/discovery"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/utils/crd"
. "github.com/onsi/ginkgo"
)
......@@ -40,13 +41,13 @@ var _ = SIGDescribe("Discovery", func() {
})
It("[Feature:StorageVersionHash] Custom resource should have storage version hash", func() {
testcrd, err := framework.CreateTestCRD(f)
testcrd, err := crd.CreateTestCRD(f)
if err != nil {
return
}
defer testcrd.CleanUp()
spec := testcrd.Crd.Spec
resources, err := testcrd.ApiExtensionClient.Discovery().ServerResourcesForGroupVersion(spec.Group + "/" + spec.Versions[0].Name)
resources, err := testcrd.APIExtensionClient.Discovery().ServerResourcesForGroupVersion(spec.Group + "/" + spec.Versions[0].Name)
if err != nil {
framework.Failf("failed to find the discovery doc for %v: %v", resources, err)
}
......
......@@ -38,6 +38,7 @@ import (
"k8s.io/client-go/dynamic"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/utils/crd"
imageutils "k8s.io/kubernetes/test/utils/image"
. "github.com/onsi/ginkgo"
......@@ -130,7 +131,7 @@ var _ = SIGDescribe("AdmissionWebhook", func() {
})
It("Should be able to deny custom resource creation", func() {
testcrd, err := framework.CreateTestCRD(f)
testcrd, err := crd.CreateTestCRD(f)
if err != nil {
return
}
......@@ -167,7 +168,7 @@ var _ = SIGDescribe("AdmissionWebhook", func() {
})
It("Should mutate custom resource", func() {
testcrd, err := framework.CreateTestCRD(f)
testcrd, err := crd.CreateTestCRD(f)
if err != nil {
return
}
......@@ -185,7 +186,7 @@ var _ = SIGDescribe("AdmissionWebhook", func() {
})
It("Should mutate custom resource with different stored version", func() {
testcrd, err := framework.CreateMultiVersionTestCRDWithV1Storage(f)
testcrd, err := crd.CreateMultiVersionTestCRDWithV1Storage(f)
if err != nil {
return
}
......@@ -1186,7 +1187,7 @@ func cleanWebhookTest(client clientset.Interface, namespaceName string) {
_ = client.RbacV1beta1().RoleBindings("kube-system").Delete(roleBindingName, nil)
}
func registerWebhookForCustomResource(f *framework.Framework, context *certContext, testcrd *framework.TestCrd) func() {
func registerWebhookForCustomResource(f *framework.Framework, context *certContext, testcrd *crd.TestCrd) func() {
client := f.ClientSet
By("Registering the custom resource webhook via the AdmissionRegistration API")
......@@ -1202,7 +1203,7 @@ func registerWebhookForCustomResource(f *framework.Framework, context *certConte
Rules: []v1beta1.RuleWithOperations{{
Operations: []v1beta1.OperationType{v1beta1.Create, v1beta1.Update},
Rule: v1beta1.Rule{
APIGroups: []string{testcrd.ApiGroup},
APIGroups: []string{testcrd.APIGroup},
APIVersions: testcrd.GetAPIVersions(),
Resources: []string{testcrd.GetPluralName()},
},
......@@ -1227,7 +1228,7 @@ func registerWebhookForCustomResource(f *framework.Framework, context *certConte
}
}
func registerMutatingWebhookForCustomResource(f *framework.Framework, context *certContext, testcrd *framework.TestCrd) func() {
func registerMutatingWebhookForCustomResource(f *framework.Framework, context *certContext, testcrd *crd.TestCrd) func() {
client := f.ClientSet
By("Registering the mutating webhook for a custom resource via the AdmissionRegistration API")
......@@ -1243,7 +1244,7 @@ func registerMutatingWebhookForCustomResource(f *framework.Framework, context *c
Rules: []v1beta1.RuleWithOperations{{
Operations: []v1beta1.OperationType{v1beta1.Create, v1beta1.Update},
Rule: v1beta1.Rule{
APIGroups: []string{testcrd.ApiGroup},
APIGroups: []string{testcrd.APIGroup},
APIVersions: testcrd.GetAPIVersions(),
Resources: []string{testcrd.GetPluralName()},
},
......@@ -1262,7 +1263,7 @@ func registerMutatingWebhookForCustomResource(f *framework.Framework, context *c
Rules: []v1beta1.RuleWithOperations{{
Operations: []v1beta1.OperationType{v1beta1.Create},
Rule: v1beta1.Rule{
APIGroups: []string{testcrd.ApiGroup},
APIGroups: []string{testcrd.APIGroup},
APIVersions: testcrd.GetAPIVersions(),
Resources: []string{testcrd.GetPluralName()},
},
......@@ -1338,7 +1339,7 @@ func testMutatingCustomResourceWebhook(f *framework.Framework, crd *apiextension
}
}
func testMultiVersionCustomResourceWebhook(f *framework.Framework, testcrd *framework.TestCrd) {
func testMultiVersionCustomResourceWebhook(f *framework.Framework, testcrd *crd.TestCrd) {
customResourceClient := testcrd.GetV1DynamicClient()
By("Creating a custom resource while v1 is storage version")
crName := "cr-instance-1"
......@@ -1360,7 +1361,7 @@ func testMultiVersionCustomResourceWebhook(f *framework.Framework, testcrd *fram
By("Patching Custom Resource Definition to set v2 as storage")
apiVersionWithV2StoragePatch := fmt.Sprint(`{"spec": {"versions": [{"name": "v1", "storage": false, "served": true},{"name": "v2", "storage": true, "served": true}]}}`)
_, err = testcrd.ApiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Patch(testcrd.Crd.Name, types.StrategicMergePatchType, []byte(apiVersionWithV2StoragePatch))
_, err = testcrd.APIExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Patch(testcrd.Crd.Name, types.StrategicMergePatchType, []byte(apiVersionWithV2StoragePatch))
Expect(err).NotTo(HaveOccurred(), "failed to patch custom resource definition %s in namespace: %s", testcrd.Crd.Name, f.Namespace.Name)
By("Patching the custom resource while v2 is storage version")
......@@ -1427,10 +1428,10 @@ func testCRDDenyWebhook(f *framework.Framework) {
Storage: true,
},
}
testcrd := &framework.TestCrd{
testcrd := &crd.TestCrd{
Name: name,
Kind: kind,
ApiGroup: group,
APIGroup: group,
Versions: apiVersions,
}
......@@ -1453,7 +1454,7 @@ func testCRDDenyWebhook(f *framework.Framework) {
},
},
Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{
Group: testcrd.ApiGroup,
Group: testcrd.APIGroup,
Versions: testcrd.Versions,
Names: apiextensionsv1beta1.CustomResourceDefinitionNames{
Plural: testcrd.GetPluralName(),
......
......@@ -55,7 +55,8 @@ var (
)
// TODO: Get rid of [DisabledForLargeClusters] when feature request #53455 is ready.
var _ = SIGDescribe("Advanced Audit [DisabledForLargeClusters]", func() {
// Marked as flaky until a reliable method for collecting server-side audit logs is available. See http://issue.k8s.io/74745#issuecomment-474052439
var _ = SIGDescribe("Advanced Audit [DisabledForLargeClusters][Flaky]", func() {
f := framework.NewDefaultFramework("audit")
var namespace string
BeforeEach(func() {
......
......@@ -7,7 +7,6 @@ go_library(
srcs = [
"authorizer_util.go",
"cleanup.go",
"crd_util.go",
"create.go",
"deployment_util.go",
"exec_util.go",
......@@ -83,9 +82,6 @@ go_library(
"//staging/src/k8s.io/api/rbac/v1:go_default_library",
"//staging/src/k8s.io/api/rbac/v1beta1:go_default_library",
"//staging/src/k8s.io/api/storage/v1:go_default_library",
"//staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library",
"//staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset:go_default_library",
"//staging/src/k8s.io/apiextensions-apiserver/test/integration/fixtures:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
......
......@@ -32,7 +32,6 @@ import (
"time"
"k8s.io/api/core/v1"
apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
......@@ -75,7 +74,6 @@ type Framework struct {
ClientSet clientset.Interface
KubemarkExternalClusterClientSet clientset.Interface
APIExtensionsClientSet apiextensionsclient.Interface
InternalClientset *internalclientset.Clientset
AggregatorClient *aggregatorclient.Clientset
......@@ -182,8 +180,6 @@ func (f *Framework) BeforeEach() {
}
f.ClientSet, err = clientset.NewForConfig(config)
ExpectNoError(err)
f.APIExtensionsClientSet, err = apiextensionsclient.NewForConfig(config)
ExpectNoError(err)
f.InternalClientset, err = internalclientset.NewForConfig(config)
ExpectNoError(err)
f.AggregatorClient, err = aggregatorclient.NewForConfig(config)
......
......@@ -1060,7 +1060,7 @@ func WaitForPersistentVolumeClaimsPhase(phase v1.PersistentVolumeClaimPhase, c c
func findAvailableNamespaceName(baseName string, c clientset.Interface) (string, error) {
var name string
err := wait.PollImmediate(Poll, 30*time.Second, func() (bool, error) {
name = fmt.Sprintf("%v-%v", baseName, randomSuffix())
name = fmt.Sprintf("%v-%v", baseName, RandomSuffix())
_, err := c.CoreV1().Namespaces().Get(name, metav1.GetOptions{})
if err == nil {
// Already taken
......@@ -2154,7 +2154,7 @@ func LoadClientset() (*clientset.Clientset, error) {
// for pods and replication controllers so we don't
// need to use such a function and can instead
// use the UUID utility function.
func randomSuffix() string {
func RandomSuffix() string {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
return strconv.Itoa(r.Int() % 10000)
}
......
......@@ -34,6 +34,7 @@ go_library(
"//test/e2e/framework/testfiles:go_default_library",
"//test/e2e/scheduling:go_default_library",
"//test/utils:go_default_library",
"//test/utils/crd:go_default_library",
"//test/utils/image:go_default_library",
"//vendor/github.com/elazarl/goproxy:go_default_library",
"//vendor/github.com/onsi/ginkgo:go_default_library",
......
......@@ -61,6 +61,7 @@ import (
"k8s.io/kubernetes/test/e2e/framework/testfiles"
"k8s.io/kubernetes/test/e2e/scheduling"
testutils "k8s.io/kubernetes/test/utils"
"k8s.io/kubernetes/test/utils/crd"
uexec "k8s.io/utils/exec"
"github.com/onsi/ginkgo"
......@@ -823,7 +824,7 @@ metadata:
framework.KubeDescribe("Kubectl client-side validation", func() {
ginkgo.It("should create/apply a CR with unknown fields for CRD with no validation schema", func() {
ginkgo.By("create CRD with no validation schema")
crd, err := framework.CreateTestCRD(f)
crd, err := crd.CreateTestCRD(f)
if err != nil {
framework.Failf("failed to create test CRD: %v", err)
}
......@@ -832,7 +833,7 @@ metadata:
ginkgo.By("sleep for 10s to wait for potential crd openapi publishing alpha feature")
time.Sleep(10 * time.Second)
meta := fmt.Sprintf(metaPattern, crd.Kind, crd.ApiGroup, crd.Versions[0].Name, "test-cr")
meta := fmt.Sprintf(metaPattern, crd.Kind, crd.APIGroup, crd.Versions[0].Name, "test-cr")
randomCR := fmt.Sprintf(`{%s,"a":{"b":[{"c":"d"}]}}`, meta)
if err := createApplyCustomResource(randomCR, f.Namespace.Name, "test-cr", crd); err != nil {
framework.Failf("%v", err)
......@@ -841,7 +842,7 @@ metadata:
ginkgo.It("should create/apply a valid CR for CRD with validation schema", func() {
ginkgo.By("prepare CRD with validation schema")
crd, err := framework.CreateTestCRD(f)
crd, err := crd.CreateTestCRD(f)
if err != nil {
framework.Failf("failed to create test CRD: %v", err)
}
......@@ -853,7 +854,7 @@ metadata:
ginkgo.By("sleep for 10s to wait for potential crd openapi publishing alpha feature")
time.Sleep(10 * time.Second)
meta := fmt.Sprintf(metaPattern, crd.Kind, crd.ApiGroup, crd.Versions[0].Name, "test-cr")
meta := fmt.Sprintf(metaPattern, crd.Kind, crd.APIGroup, crd.Versions[0].Name, "test-cr")
validCR := fmt.Sprintf(`{%s,"spec":{"bars":[{"name":"test-bar"}]}}`, meta)
if err := createApplyCustomResource(validCR, f.Namespace.Name, "test-cr", crd); err != nil {
framework.Failf("%v", err)
......@@ -862,7 +863,7 @@ metadata:
ginkgo.It("should create/apply a valid CR with arbitrary-extra properties for CRD with partially-specified validation schema", func() {
ginkgo.By("prepare CRD with partially-specified validation schema")
crd, err := framework.CreateTestCRD(f)
crd, err := crd.CreateTestCRD(f)
if err != nil {
framework.Failf("failed to create test CRD: %v", err)
}
......@@ -874,7 +875,7 @@ metadata:
ginkgo.By("sleep for 10s to wait for potential crd openapi publishing alpha feature")
time.Sleep(10 * time.Second)
meta := fmt.Sprintf(metaPattern, crd.Kind, crd.ApiGroup, crd.Versions[0].Name, "test-cr")
meta := fmt.Sprintf(metaPattern, crd.Kind, crd.APIGroup, crd.Versions[0].Name, "test-cr")
validArbitraryCR := fmt.Sprintf(`{%s,"spec":{"bars":[{"name":"test-bar"}],"extraProperty":"arbitrary-value"}}`, meta)
if err := createApplyCustomResource(validArbitraryCR, f.Namespace.Name, "test-cr", crd); err != nil {
framework.Failf("%v", err)
......@@ -2226,7 +2227,7 @@ func startLocalProxy() (srv *httptest.Server, logs *bytes.Buffer) {
// createApplyCustomResource asserts that given CustomResource be created and applied
// without being rejected by client-side validation
func createApplyCustomResource(resource, namespace, name string, crd *framework.TestCrd) error {
func createApplyCustomResource(resource, namespace, name string, crd *crd.TestCrd) error {
ns := fmt.Sprintf("--namespace=%v", namespace)
ginkgo.By("successfully create CR")
if _, err := framework.RunKubectlInput(resource, ns, "create", "-f", "-"); err != nil {
......
......@@ -27,7 +27,7 @@ import (
// utils.go contains functions used across test suites.
const (
cniVersion = "v0.6.0"
cniVersion = "v0.7.5"
cniArch = "amd64"
cniDirectory = "cni/bin" // The CNI tarball places binaries under directory under "cni/bin".
cniConfDirectory = "cni/net.d"
......
......@@ -76,6 +76,7 @@ filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//test/utils/crd:all-srcs",
"//test/utils/harness:all-srcs",
"//test/utils/image:all-srcs",
"//test/utils/junit:all-srcs",
......
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["crd_util.go"],
importpath = "k8s.io/kubernetes/test/utils/crd",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library",
"//staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset:go_default_library",
"//staging/src/k8s.io/apiextensions-apiserver/test/integration/fixtures:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/yaml:go_default_library",
"//staging/src/k8s.io/client-go/dynamic:go_default_library",
"//test/e2e/framework:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package framework
package crd
import (
"fmt"
......@@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/types"
utilyaml "k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/dynamic"
"k8s.io/kubernetes/test/e2e/framework"
)
// CleanCrdFn declares the clean up function needed to remove the CRD
......@@ -36,40 +37,40 @@ type CleanCrdFn func() error
type TestCrd struct {
Name string
Kind string
ApiGroup string
APIGroup string
Versions []apiextensionsv1beta1.CustomResourceDefinitionVersion
ApiExtensionClient *crdclientset.Clientset
APIExtensionClient *crdclientset.Clientset
Crd *apiextensionsv1beta1.CustomResourceDefinition
DynamicClients map[string]dynamic.ResourceInterface
CleanUp CleanCrdFn
}
// CreateTestCRD creates a new CRD specifically for the calling test.
func CreateMultiVersionTestCRD(f *Framework, group string, apiVersions []apiextensionsv1beta1.CustomResourceDefinitionVersion, conversionWebhook *apiextensionsv1beta1.WebhookClientConfig) (*TestCrd, error) {
suffix := randomSuffix()
// CreateMultiVersionTestCRD creates a new CRD specifically for the calling test.
func CreateMultiVersionTestCRD(f *framework.Framework, group string, apiVersions []apiextensionsv1beta1.CustomResourceDefinitionVersion, conversionWebhook *apiextensionsv1beta1.WebhookClientConfig) (*TestCrd, error) {
suffix := framework.RandomSuffix()
name := fmt.Sprintf("e2e-test-%s-%s-crd", f.BaseName, suffix)
kind := fmt.Sprintf("E2e-test-%s-%s-crd", f.BaseName, suffix)
testcrd := &TestCrd{
Name: name,
Kind: kind,
ApiGroup: group,
APIGroup: group,
Versions: apiVersions,
}
// Creating a custom resource definition for use by assorted tests.
config, err := LoadConfig()
config, err := framework.LoadConfig()
if err != nil {
Failf("failed to load config: %v", err)
framework.Failf("failed to load config: %v", err)
return nil, err
}
apiExtensionClient, err := crdclientset.NewForConfig(config)
if err != nil {
Failf("failed to initialize apiExtensionClient: %v", err)
framework.Failf("failed to initialize apiExtensionClient: %v", err)
return nil, err
}
dynamicClient, err := dynamic.NewForConfig(config)
if err != nil {
Failf("failed to initialize dynamic client: %v", err)
framework.Failf("failed to initialize dynamic client: %v", err)
return nil, err
}
......@@ -85,7 +86,7 @@ func CreateMultiVersionTestCRD(f *Framework, group string, apiVersions []apiexte
//create CRD and waits for the resource to be recognized and available.
crd, err = fixtures.CreateNewCustomResourceDefinitionWatchUnsafe(crd, apiExtensionClient)
if err != nil {
Failf("failed to create CustomResourceDefinition: %v", err)
framework.Failf("failed to create CustomResourceDefinition: %v", err)
return nil, err
}
......@@ -97,13 +98,13 @@ func CreateMultiVersionTestCRD(f *Framework, group string, apiVersions []apiexte
}
}
testcrd.ApiExtensionClient = apiExtensionClient
testcrd.APIExtensionClient = apiExtensionClient
testcrd.Crd = crd
testcrd.DynamicClients = resourceClients
testcrd.CleanUp = func() error {
err := fixtures.DeleteCustomResourceDefinition(crd, apiExtensionClient)
if err != nil {
Failf("failed to delete CustomResourceDefinition(%s): %v", name, err)
framework.Failf("failed to delete CustomResourceDefinition(%s): %v", name, err)
}
return err
}
......@@ -111,7 +112,7 @@ func CreateMultiVersionTestCRD(f *Framework, group string, apiVersions []apiexte
}
// CreateTestCRD creates a new CRD specifically for the calling test.
func CreateTestCRD(f *Framework) (*TestCrd, error) {
func CreateTestCRD(f *framework.Framework) (*TestCrd, error) {
group := fmt.Sprintf("%s-crd-test.k8s.io", f.BaseName)
apiVersions := []apiextensionsv1beta1.CustomResourceDefinitionVersion{
{
......@@ -123,8 +124,8 @@ func CreateTestCRD(f *Framework) (*TestCrd, error) {
return CreateMultiVersionTestCRD(f, group, apiVersions, nil)
}
// CreateTestCRD creates a new CRD specifically for the calling test.
func CreateMultiVersionTestCRDWithV1Storage(f *Framework) (*TestCrd, error) {
// CreateMultiVersionTestCRDWithV1Storage creates a new CRD specifically for the calling test.
func CreateMultiVersionTestCRDWithV1Storage(f *framework.Framework) (*TestCrd, error) {
group := fmt.Sprintf("%s-multiversion-crd-test.k8s.io", f.BaseName)
apiVersions := []apiextensionsv1beta1.CustomResourceDefinitionVersion{
{
......@@ -146,7 +147,7 @@ func newCRDForTest(testcrd *TestCrd) *apiextensionsv1beta1.CustomResourceDefinit
return &apiextensionsv1beta1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{Name: testcrd.GetMetaName()},
Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{
Group: testcrd.ApiGroup,
Group: testcrd.APIGroup,
Versions: testcrd.Versions,
Names: apiextensionsv1beta1.CustomResourceDefinitionNames{
Plural: testcrd.GetPluralName(),
......@@ -161,7 +162,7 @@ func newCRDForTest(testcrd *TestCrd) *apiextensionsv1beta1.CustomResourceDefinit
// GetMetaName returns the metaname for the CRD.
func (c *TestCrd) GetMetaName() string {
return c.Name + "s." + c.ApiGroup
return c.Name + "s." + c.APIGroup
}
// GetPluralName returns the plural form of the CRD name
......@@ -174,6 +175,7 @@ func (c *TestCrd) GetListName() string {
return c.Name + "List"
}
// GetAPIVersions returns the API versions served by the CRD.
func (c *TestCrd) GetAPIVersions() []string {
ret := []string{}
for _, v := range c.Versions {
......@@ -184,6 +186,7 @@ func (c *TestCrd) GetAPIVersions() []string {
return ret
}
// GetV1DynamicClient returns the dynamic client for v1.
func (c *TestCrd) GetV1DynamicClient() dynamic.ResourceInterface {
return c.DynamicClients["v1"]
}
......@@ -195,6 +198,6 @@ func (c *TestCrd) PatchSchema(schema []byte) error {
return fmt.Errorf("failed to create json patch: %v", err)
}
patch := []byte(fmt.Sprintf(`{"spec":{"validation":{"openAPIV3Schema":%s}}}`, string(s)))
c.Crd, err = c.ApiExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Patch(c.GetMetaName(), types.MergePatchType, patch)
c.Crd, err = c.APIExtensionClient.ApiextensionsV1beta1().CustomResourceDefinitions().Patch(c.GetMetaName(), types.MergePatchType, patch)
return err
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment