From 70aad37a4fb6a9edc593859139dd6e0549badbc7 Mon Sep 17 00:00:00 2001 From: Amarnath Valluri Date: Sat, 10 Oct 2020 01:06:50 +0300 Subject: [PATCH] operator: do not install/uninstall CRD. As per operator developer [best-practices](https://github.com/operator-framework/community-operators/blob/master/docs/best-practices.md) the operator shall not self-register CRDs. So we stop doing so. FIXES: #761 --- .../crd/pmem-csi.intel.com_deployments.yaml | 183 ++++++++++++++++++ .../kustomize/olm-catalog/kustomization.yaml | 2 +- deploy/kustomize/operator/operator.yaml | 8 - docs/install.md | 6 + operator/operator.make | 8 +- pkg/apis/pmemcsi/v1alpha1/deployment_types.go | 146 -------------- .../pmemcsi/v1alpha1/deployment_types_test.go | 23 ++- .../controller/deployment/deployment_crd.go | 125 ------------ pkg/pmem-csi-operator/main.go | 13 +- test/start-operator.sh | 4 + test/stop-operator.sh | 3 + test/test.make | 2 +- 12 files changed, 221 insertions(+), 302 deletions(-) create mode 100644 deploy/crd/pmem-csi.intel.com_deployments.yaml delete mode 100644 pkg/pmem-csi-operator/controller/deployment/deployment_crd.go diff --git a/deploy/crd/pmem-csi.intel.com_deployments.yaml b/deploy/crd/pmem-csi.intel.com_deployments.yaml new file mode 100644 index 0000000000..f150706b47 --- /dev/null +++ b/deploy/crd/pmem-csi.intel.com_deployments.yaml @@ -0,0 +1,183 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.3.0 + creationTimestamp: null + name: deployments.pmem-csi.intel.com +spec: + group: pmem-csi.intel.com + names: + kind: Deployment + listKind: DeploymentList + plural: deployments + singular: deployment + scope: Cluster + subresources: + status: {} + validation: + openAPIV3Schema: + description: Deployment is the Schema for the deployments API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: DeploymentSpec defines the desired state of Deployment + properties: + caCert: + description: CACert encoded root certificate of the CA by which the + registry and node controller certificates are signed If not provided + operator uses a self-signed CA certificate + format: byte + type: string + controllerResources: + description: ControllerResources Compute resources required by Controller + driver + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute resources + allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount of compute resources + required. If Requests is omitted for a container, it defaults + to Limits if that is explicitly specified, otherwise to an implementation-defined + value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + type: object + deviceMode: + description: DeviceMode to use to manage PMEM devices. One of lvm, direct + type: string + image: + description: PMEM-CSI driver container image + type: string + imagePullPolicy: + description: PullPolicy image pull policy one of Always, Never, IfNotPresent + type: string + kubeletDir: + description: KubeletDir kubelet's root directory path + type: string + labels: + additionalProperties: + type: string + description: Labels contains additional labels for all objects created + by the operator. + type: object + logLevel: + description: LogLevel number for the log verbosity kubebuilder:default=3 + type: integer + nodeControllerCert: + description: NodeControllerCert encoded certificate signed by a CA for + node controller server authentication If not provided, provisioned + one by the operator using self-signed CA + format: byte + type: string + nodeControllerKey: + description: NodeControllerPrivateKey encoded private key used for node + controller server certificate If not provided, provisioned one by + the operator + format: byte + type: string + nodeRegistrarImage: + description: NodeRegistrarImage CSI node driver registrar sidecar image + type: string + nodeResources: + description: NodeResources Compute resources required by Node driver + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute resources + allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount of compute resources + required. If Requests is omitted for a container, it defaults + to Limits if that is explicitly specified, otherwise to an implementation-defined + value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' + type: object + type: object + nodeSelector: + additionalProperties: + type: string + description: NodeSelector node labels to use for selection of driver + node + type: object + pmemPercentage: + description: PMEMPercentage represents the percentage of space to be + used by the driver in each PMEM region on every node. This is only + valid for driver in LVM mode. -kubebuilder:validation:Minimum=1 -kubebuilder:validation:Maximum=100 + -kubebuilder:default=100 + type: integer + provisionerImage: + description: ProvisionerImage CSI provisioner sidecar image + type: string + registryCert: + description: RegistryCert encoded certificate signed by a CA for registry + server authentication If not provided, provisioned one by the operator + using self-signed CA + format: byte + type: string + registryKey: + description: RegistryPrivateKey encoded private key used for registry + server certificate If not provided, provisioned one by the operator + format: byte + type: string + type: object + status: + description: DeploymentStatus defines the observed state of Deployment + properties: + lastUpdated: + description: LastUpdated time of the deployment status + format: date-time + type: string + phase: + description: Phase indicates the state of the deployment + type: string + type: object + type: object + version: v1alpha1 + versions: + - name: v1alpha1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/deploy/kustomize/olm-catalog/kustomization.yaml b/deploy/kustomize/olm-catalog/kustomization.yaml index bddcc85820..543c52fe5e 100644 --- a/deploy/kustomize/olm-catalog/kustomization.yaml +++ b/deploy/kustomize/olm-catalog/kustomization.yaml @@ -1,9 +1,9 @@ bases: -- ./crd # this would be generated using: make operator-generate-crd - ../operator resources: - ../../common/pmem-csi.intel.com_v1alpha1_deployment_cr.yaml +- ../../crd/pmem-csi.intel.com_deployments.yaml images: - name: intel/pmem-csi-driver diff --git a/deploy/kustomize/operator/operator.yaml b/deploy/kustomize/operator/operator.yaml index 7b8c26073b..35149ca792 100644 --- a/deploy/kustomize/operator/operator.yaml +++ b/deploy/kustomize/operator/operator.yaml @@ -69,14 +69,6 @@ rules: - csidrivers verbs: - '*' -- apiGroups: - - apiextensions.k8s.io - resources: - - customresourcedefinitions - verbs: - - get - - create - - delete - apiGroups: - pmem-csi.intel.com resources: diff --git a/docs/install.md b/docs/install.md index a4298c933f..42d9ad9178 100644 --- a/docs/install.md +++ b/docs/install.md @@ -229,6 +229,12 @@ by the operator. operator's self-signed CA instead must provide the certificates generated from a trusted certificate authority. +- **Install the PMEM-CSI Deployment CRD** + +``` console +$ kubectl create -f https://github.com/intel/pmem-csi/raw/devel/deploy/crd/pmem-csi.intel.com_deployments.yaml +``` + - **Install the PMEM-CSI operator** ``` console diff --git a/operator/operator.make b/operator/operator.make index 13ce697c64..98a0d37325 100644 --- a/operator/operator.make +++ b/operator/operator.make @@ -44,6 +44,7 @@ endif MANIFESTS_DIR=deploy/kustomize/olm-catalog CATALOG_DIR=deploy/olm-catalog BUNDLE_DIR=deploy/bundle +CRD_DIR=deploy/crd KUBECONFIG := $(shell echo $(PWD)/_work/$(CLUSTER)/kube.config) @@ -52,9 +53,8 @@ OPERATOR_OUTPUT_DIR := $(CATALOG_DIR)/$(MAJOR_MINOR_PATCH_VERSION) # Generate CRD and add kustomization support operator-generate-crd: controller-gen - @echo "Generating CRD in $(MANIFESTS_DIR)/crd ..." - $(CONTROLLER_GEN) crd:trivialVersions=true,crdVersions=v1beta1 paths=./pkg/apis/... output:dir=$(MANIFESTS_DIR)/crd/ - @echo "resources: [pmem-csi.intel.com_deployments.yaml]" > $(MANIFESTS_DIR)/crd/kustomization.yaml + @echo "Generating CRD in $(CRD_DIR) ..." + $(CONTROLLER_GEN) crd:trivialVersions=true,crdVersions=v1beta1 paths=./pkg/apis/... output:dir=$(CRD_DIR)/ # Generate packagemanifests using operator-sdk. operator-generate-catalog: _work/bin/operator-sdk-$(OPERATOR_SDK_VERSION) _work/kustomize operator-generate-crd @@ -73,7 +73,7 @@ operator-generate-bundle: _work/bin/operator-sdk-$(OPERATOR_SDK_VERSION) _work/k @$(PATCH_VERSIONS) $(OPERATOR_OUTPUT_DIR)/pmem-csi-operator.clusterserviceversion.yaml operator-clean-crd: - rm -rf $(MANIFESTS_DIR)/crd + rm -rf $(CRD_DIR) operator-clean-catalog: rm -rf $(CATALOG_DIR) diff --git a/pkg/apis/pmemcsi/v1alpha1/deployment_types.go b/pkg/apis/pmemcsi/v1alpha1/deployment_types.go index 9860d8eb3e..9d690b2200 100644 --- a/pkg/apis/pmemcsi/v1alpha1/deployment_types.go +++ b/pkg/apis/pmemcsi/v1alpha1/deployment_types.go @@ -14,7 +14,6 @@ import ( "strings" corev1 "k8s.io/api/core/v1" - apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -423,151 +422,6 @@ func (d *Deployment) GetOwnerReference() metav1.OwnerReference { } } -func GetDeploymentCRDSchema() *apiextensions.JSONSchemaProps { - One := float64(1) - Hundred := float64(100) - return &apiextensions.JSONSchemaProps{ - Type: "object", - Description: "https://github.com/intel/pmem-csi.git", - Properties: map[string]apiextensions.JSONSchemaProps{ - "spec": apiextensions.JSONSchemaProps{ - Type: "object", - Description: "DeploymentSpec defines the desired state of Deployment", - Properties: map[string]apiextensions.JSONSchemaProps{ - "logLevel": apiextensions.JSONSchemaProps{ - Type: "integer", - Description: "logging level", - }, - "deviceMode": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "CSI Driver mode for device management: 'lvm' or 'direct'", - Enum: []apiextensions.JSON{ - apiextensions.JSON{Raw: []byte("\"" + DeviceModeLVM + "\"")}, - apiextensions.JSON{Raw: []byte("\"" + DeviceModeDirect + "\"")}, - }, - }, - "image": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "PMEM-CSI driver docker image", - }, - "provisionerImage": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "CSI provisioner docker image", - }, - "nodeRegistrarImage": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "CSI node driver registrar docker image", - }, - "imagePullPolicy": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "Docker image pull policy: Always, Never, IfNotPresent", - Enum: []apiextensions.JSON{ - apiextensions.JSON{Raw: []byte("\"" + corev1.PullAlways + "\"")}, - apiextensions.JSON{Raw: []byte("\"" + corev1.PullIfNotPresent + "\"")}, - apiextensions.JSON{Raw: []byte("\"" + corev1.PullNever + "\"")}, - }, - }, - "controllerResources": getResourceRequestsSchema(), - "nodeResources": getResourceRequestsSchema(), - "caCert": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "Encoded CA certificate", - }, - "registryCert": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "Encoded pmem-registry certificate", - }, - "registryKey": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "Encoded private key used for generating pmem-registry certificate", - }, - "nodeControllerCert": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "Encoded pmem-node-controller certificate", - }, - "nodeControllerKey": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "Encoded private key used for generating pmem-node-controller certificate", - }, - "nodeSelector": apiextensions.JSONSchemaProps{ - Type: "object", - Description: "Set of node labels to use to select a node to run PMEM-CSI driver", - AdditionalProperties: &apiextensions.JSONSchemaPropsOrBool{ - Allows: true, - Schema: &apiextensions.JSONSchemaProps{ - Type: "string", - }, - }, - }, - "pmemPercentage": apiextensions.JSONSchemaProps{ - Type: "integer", - Description: "Percentage of space to use from total available PMEM space, within range of 1 to 100", - Minimum: &One, - Maximum: &Hundred, - }, - "labels": apiextensions.JSONSchemaProps{ - Type: "object", - Description: "Set of additional labels for all objects created by the operator", - AdditionalProperties: &apiextensions.JSONSchemaPropsOrBool{ - Allows: true, - Schema: &apiextensions.JSONSchemaProps{ - Type: "string", - }, - }, - }, - "kubeletDir": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "Kubelet root directory path", - }, - }, - }, - "status": apiextensions.JSONSchemaProps{ - Type: "object", - Description: "State of the deployment", - Properties: map[string]apiextensions.JSONSchemaProps{ - "phase": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "deployment phase", - }, - "lastUpdated": apiextensions.JSONSchemaProps{ - Type: "string", - Description: "time when the status last updated", - }, - }, - }, - }, - } -} - -func getResourceRequestsSchema() apiextensions.JSONSchemaProps { - return apiextensions.JSONSchemaProps{ - Type: "object", - Description: "Compute resource requirements for controller driver Pod", - Properties: map[string]apiextensions.JSONSchemaProps{ - "limits": apiextensions.JSONSchemaProps{ - Type: "object", - Description: "The maximum amount of compute resources allowed", - AdditionalProperties: &apiextensions.JSONSchemaPropsOrBool{ - Allows: true, - Schema: &apiextensions.JSONSchemaProps{ - Type: "string", - }, - }, - }, - "requests": apiextensions.JSONSchemaProps{ - Type: "object", - Description: "The minimum amount of compute resources required", - AdditionalProperties: &apiextensions.JSONSchemaPropsOrBool{ - Allows: true, - Schema: &apiextensions.JSONSchemaProps{ - Type: "string", - }, - }, - }, - }, - } -} - func compareResources(rsA *corev1.ResourceRequirements, rsB *corev1.ResourceRequirements) bool { if rsA == nil { return rsB == nil diff --git a/pkg/apis/pmemcsi/v1alpha1/deployment_types_test.go b/pkg/apis/pmemcsi/v1alpha1/deployment_types_test.go index d48fd67076..75ca1109e1 100644 --- a/pkg/apis/pmemcsi/v1alpha1/deployment_types_test.go +++ b/pkg/apis/pmemcsi/v1alpha1/deployment_types_test.go @@ -6,6 +6,8 @@ SPDX-License-Identifier: Apache-2.0 package v1alpha1_test import ( + "io/ioutil" + "os" "testing" "github.com/intel/pmem-csi/pkg/apis" @@ -13,6 +15,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" + apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/client-go/kubernetes/scheme" ) @@ -191,12 +194,22 @@ spec: }) It("should have valid json schema", func() { - crd := api.GetDeploymentCRDSchema() - Expect(crd).ShouldNot(BeNil(), "Nil CRD schmea") - Expect(crd.Type).Should(BeEquivalentTo("object"), "Deployment JSON schema type mismatch") - spec, ok := crd.Properties["spec"] + + crdFile := os.Getenv("REPO_ROOT") + "/deploy/crd/pmem-csi.intel.com_deployments.yaml" + data, err := ioutil.ReadFile(crdFile) + Expect(err).ShouldNot(HaveOccurred(), "load crd data") + crd := &apiextensions.CustomResourceDefinition{} + + deserializer := scheme.Codecs.UniversalDeserializer() + _, _, err = deserializer.Decode(data, nil, crd) + Expect(err).ShouldNot(HaveOccurred(), "decode crd file") + + crdProp := crd.Spec.Validation.OpenAPIV3Schema + Expect(crdProp).ShouldNot(BeNil(), "Nil CRD schmea") + Expect(crdProp.Type).Should(BeEquivalentTo("object"), "Deployment JSON schema type mismatch") + spec, ok := crdProp.Properties["spec"] Expect(ok).Should(BeTrue(), "Deployment JSON schema does not have 'spec'") - status, ok := crd.Properties["status"] + status, ok := crdProp.Properties["status"] Expect(ok).Should(BeTrue(), "Deployment JSON schema does not have 'status'") specProperties := map[string]string{ diff --git a/pkg/pmem-csi-operator/controller/deployment/deployment_crd.go b/pkg/pmem-csi-operator/controller/deployment/deployment_crd.go deleted file mode 100644 index 22232b9a90..0000000000 --- a/pkg/pmem-csi-operator/controller/deployment/deployment_crd.go +++ /dev/null @@ -1,125 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package deployment - -import ( - "context" - "fmt" - "time" - - pmemcsiv1alpha1 "github.com/intel/pmem-csi/pkg/apis/pmemcsi/v1alpha1" - apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" - "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/rest" - "k8s.io/klog/v2" -) - -func EnsureCRDInstalled(config *rest.Config) error { - aeClientset, err := clientset.NewForConfig(config) - if err != nil { - return err - } - crd := GetDeploymentCRD() - - if _, err := aeClientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(context.Background(), crd, metav1.CreateOptions{}); err != nil { - if errors.IsAlreadyExists(err) { - return nil - } - return err - } else { - /* Wait till the CRD is visible in API server */ - retryCount := 6 - retryDelay := 10 * time.Second - - for retryCount > 0 { - _, err := aeClientset.ApiextensionsV1beta1().CustomResourceDefinitions().Get(context.Background(), - "deployments.pmem-csi.intel.com", - metav1.GetOptions{ - TypeMeta: metav1.TypeMeta{ - Kind: "CustomResourceDefinition", - APIVersion: "apiextensions.k8s.io/v1", - }, - }) - if err != nil { - klog.Warningf("Failed to fetch Deployment CRD: %v. Will retry after %d Seconds", err, retryDelay) - retryCount-- - time.Sleep(retryDelay) - } else { - klog.Info("CRD registered with API Server") - break - } - } - - if retryCount == 0 { - return fmt.Errorf("Failed to retrieve Deployment CRD from API server") - } - } - return nil -} - -// DeleteCRD deletes the PMEM-CSI Deployment CRD. -// Supposed to be called while existing the operator -func DeleteCRD(config *rest.Config) error { - aeClientset, err := clientset.NewForConfig(config) - if err != nil { - return err - } - delOptions := metav1.DeleteOptions{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "apiextensions.k8s.io/v1", - Kind: "CustomResourceDefinition", - }, - } - - if err := aeClientset.ApiextensionsV1beta1().CustomResourceDefinitions().Delete(context.Background(), "deployments.pmem-csi.intel.com", delOptions); err != nil { - if errors.IsNotFound(err) { - return nil - } - return err - } - return nil -} - -func GetDeploymentCRD() *apiextensions.CustomResourceDefinition { - return &apiextensions.CustomResourceDefinition{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "apiextensions.k8s.io/v1beta1", - Kind: "CustomResourceDefinition", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: "deployments.pmem-csi.intel.com", - }, - Spec: apiextensions.CustomResourceDefinitionSpec{ - Group: "pmem-csi.intel.com", - Versions: []apiextensions.CustomResourceDefinitionVersion{ - { - Name: "v1alpha1", - Served: true, - Storage: true, - }, - }, - Subresources: &apiextensions.CustomResourceSubresources{ - Status: &apiextensions.CustomResourceSubresourceStatus{}, - }, - - Names: apiextensions.CustomResourceDefinitionNames{ - Singular: "deployment", - Plural: "deployments", - Kind: "Deployment", - ListKind: "DeploymentList", - }, - - // PMEM-CSI Deployment is a cluster scoped resource - Scope: apiextensions.ClusterScoped, - Validation: &apiextensions.CustomResourceValidation{ - OpenAPIV3Schema: pmemcsiv1alpha1.GetDeploymentCRDSchema(), - }, - }, - } -} diff --git a/pkg/pmem-csi-operator/main.go b/pkg/pmem-csi-operator/main.go index 948c7e36a3..0e24d19ab5 100644 --- a/pkg/pmem-csi-operator/main.go +++ b/pkg/pmem-csi-operator/main.go @@ -19,7 +19,7 @@ import ( api "github.com/intel/pmem-csi/pkg/apis/pmemcsi/v1alpha1" "github.com/intel/pmem-csi/pkg/k8sutil" "github.com/intel/pmem-csi/pkg/pmem-csi-operator/controller" - "github.com/intel/pmem-csi/pkg/pmem-csi-operator/controller/deployment" + _ "github.com/intel/pmem-csi/pkg/pmem-csi-operator/controller/deployment" //"github.com/intel/pmem-csi/pkg/pmem-operator/version" pmemcommon "github.com/intel/pmem-csi/pkg/pmem-common" @@ -68,12 +68,6 @@ func Main() int { return 1 } - klog.Info("Registering Deployment CRD.") - if err := deployment.EnsureCRDInstalled(cfg); err != nil { - pmemcommon.ExitError("Failed to install deployment CRD: ", err) - return 1 - } - // Retrieve namespace to watch for new deployments and to create sub-resources namespace := k8sutil.GetNamespace() @@ -145,10 +139,5 @@ func Main() int { return 0 } - if err := deployment.DeleteCRD(cfg); err != nil { - pmemcommon.ExitError("Failed to delete deployment CRD: ", err) - return 1 - } - return 0 } diff --git a/test/start-operator.sh b/test/start-operator.sh index eccc0b32c4..bfe7e9acae 100755 --- a/test/start-operator.sh +++ b/test/start-operator.sh @@ -75,6 +75,10 @@ function deploy_using_olm() { } function deploy_using_yaml() { + crd=${REPO_DIRECTORY}/deploy/crd/pmem-csi.intel.com_deployments.yaml + echo "Deploying '${crd}'..." + cat ${crd} | ${SSH} kubectl create -f - + DEPLOYMENT_DIRECTORY="${REPO_DIRECTORY}/deploy/operator" deploy="${DEPLOYMENT_DIRECTORY}/pmem-csi-operator.yaml" diff --git a/test/stop-operator.sh b/test/stop-operator.sh index a8f4a58f49..70ebd67769 100755 --- a/test/stop-operator.sh +++ b/test/stop-operator.sh @@ -49,6 +49,9 @@ function delete_operator() { echo "Deleting operator deployment: ${deploy}" cat ${deploy} | ${KUBECTL} delete -f - + + echo "Deleting CRD..." + ${SSH} kubectl delete crd deployments.pmem-csi.intel.com } deploy_method=yaml diff --git a/test/test.make b/test/test.make index e48fe1b9ee..2b3bafd6db 100644 --- a/test/test.make +++ b/test/test.make @@ -134,7 +134,7 @@ RUNTIME_DEPS += LC_ALL=C LANG=C sort -u # (https://github.com/intel/pmem-csi/pull/420#discussion_r346850741). .PHONY: run_tests test: run_tests -RUN_TESTS = TEST_WORK=$(abspath _work) \ +RUN_TESTS = TEST_WORK=$(abspath _work) REPO_ROOT=`pwd` \ env GODEBUG=x509ignoreCN=0 $(TEST_CMD) -timeout 0 $(filter-out %/pmem-device-manager,$(TEST_PKGS)) RUN_TEST_DEPS = _work/pmem-ca/.ca-stamp _work/evil-ca/.ca-stamp check-go-version-$(GO_BINARY)