diff --git a/deploy/bindata_generated.go b/deploy/bindata_generated.go index b8b2651e6a..ecf2686ab8 100644 --- a/deploy/bindata_generated.go +++ b/deploy/bindata_generated.go @@ -100,7 +100,7 @@ func deployKubernetes117DirectPmemCsiYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "deploy/kubernetes-1.17/direct/pmem-csi.yaml", size: 10899, mode: os.FileMode(420), modTime: time.Unix(1608283266, 0)} + info := bindataFileInfo{name: "deploy/kubernetes-1.17/direct/pmem-csi.yaml", size: 10899, mode: os.FileMode(436), modTime: time.Unix(1609165078, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -120,7 +120,7 @@ func deployKubernetes117LvmPmemCsiYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "deploy/kubernetes-1.17/lvm/pmem-csi.yaml", size: 10848, mode: os.FileMode(420), modTime: time.Unix(1608283267, 0)} + info := bindataFileInfo{name: "deploy/kubernetes-1.17/lvm/pmem-csi.yaml", size: 10848, mode: os.FileMode(436), modTime: time.Unix(1609165081, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -140,7 +140,7 @@ func deployKubernetes118DirectPmemCsiYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "deploy/kubernetes-1.18/direct/pmem-csi.yaml", size: 10899, mode: os.FileMode(420), modTime: time.Unix(1608283271, 0)} + info := bindataFileInfo{name: "deploy/kubernetes-1.18/direct/pmem-csi.yaml", size: 10899, mode: os.FileMode(436), modTime: time.Unix(1609165089, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -160,7 +160,7 @@ func deployKubernetes118LvmPmemCsiYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "deploy/kubernetes-1.18/lvm/pmem-csi.yaml", size: 10848, mode: os.FileMode(420), modTime: time.Unix(1608283273, 0)} + info := bindataFileInfo{name: "deploy/kubernetes-1.18/lvm/pmem-csi.yaml", size: 10848, mode: os.FileMode(436), modTime: time.Unix(1609165092, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -180,7 +180,7 @@ func deployKubernetes119AlphaDirectPmemCsiYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "deploy/kubernetes-1.19-alpha/direct/pmem-csi.yaml", size: 11216, mode: os.FileMode(420), modTime: time.Unix(1608283282, 0)} + info := bindataFileInfo{name: "deploy/kubernetes-1.19-alpha/direct/pmem-csi.yaml", size: 11216, mode: os.FileMode(436), modTime: time.Unix(1609165110, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -200,7 +200,7 @@ func deployKubernetes119AlphaLvmPmemCsiYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "deploy/kubernetes-1.19-alpha/lvm/pmem-csi.yaml", size: 11165, mode: os.FileMode(420), modTime: time.Unix(1608283284, 0)} + info := bindataFileInfo{name: "deploy/kubernetes-1.19-alpha/lvm/pmem-csi.yaml", size: 11165, mode: os.FileMode(436), modTime: time.Unix(1609165113, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -220,7 +220,7 @@ func deployKubernetes119DirectPmemCsiYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "deploy/kubernetes-1.19/direct/pmem-csi.yaml", size: 10899, mode: os.FileMode(420), modTime: time.Unix(1608283277, 0)} + info := bindataFileInfo{name: "deploy/kubernetes-1.19/direct/pmem-csi.yaml", size: 10899, mode: os.FileMode(436), modTime: time.Unix(1609165099, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -240,7 +240,7 @@ func deployKubernetes119FakePmemCsiYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "deploy/kubernetes-1.19/fake/pmem-csi.yaml", size: 10897, mode: os.FileMode(420), modTime: time.Unix(1608283294, 0)} + info := bindataFileInfo{name: "deploy/kubernetes-1.19/fake/pmem-csi.yaml", size: 10897, mode: os.FileMode(436), modTime: time.Unix(1609165133, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -260,7 +260,7 @@ func deployKubernetes119LvmPmemCsiYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "deploy/kubernetes-1.19/lvm/pmem-csi.yaml", size: 10848, mode: os.FileMode(420), modTime: time.Unix(1608283278, 0)} + info := bindataFileInfo{name: "deploy/kubernetes-1.19/lvm/pmem-csi.yaml", size: 10848, mode: os.FileMode(436), modTime: time.Unix(1609165102, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/deploy/common/pmem-csi.intel.com_v1beta1_deployment_cr.yaml b/deploy/common/pmem-csi.intel.com_v1beta1_pmemcsideployment_cr.yaml similarity index 92% rename from deploy/common/pmem-csi.intel.com_v1beta1_deployment_cr.yaml rename to deploy/common/pmem-csi.intel.com_v1beta1_pmemcsideployment_cr.yaml index bf1cfa2ebd..bec9b30be6 100644 --- a/deploy/common/pmem-csi.intel.com_v1beta1_deployment_cr.yaml +++ b/deploy/common/pmem-csi.intel.com_v1beta1_pmemcsideployment_cr.yaml @@ -1,5 +1,5 @@ apiVersion: pmem-csi.intel.com/v1beta1 -kind: Deployment +kind: PmemCSIDeployment metadata: name: pmem-csi.intel.com spec: diff --git a/deploy/crd/pmem-csi.intel.com_deployments_webhook.yaml b/deploy/crd/pmem-csi.intel.com_deployments_webhook.yaml index a5739300c6..0a03721855 100644 --- a/deploy/crd/pmem-csi.intel.com_deployments_webhook.yaml +++ b/deploy/crd/pmem-csi.intel.com_deployments_webhook.yaml @@ -1,4 +1,6 @@ # This file was generated by controller-gen v0.3.0 via 'make operator-generate-crd' +# This file was generated by controller-gen v0.3.0 via 'make operator-generate-crd' +# This file was generated by controller-gen v0.3.0 via 'make operator-generate-crd' apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: diff --git a/deploy/crd/pmem-csi.intel.com_deployments.yaml b/deploy/crd/pmem-csi.intel.com_pmemcsideployments.yaml similarity index 57% rename from deploy/crd/pmem-csi.intel.com_deployments.yaml rename to deploy/crd/pmem-csi.intel.com_pmemcsideployments.yaml index 80df4d13e2..c78dcdb934 100644 --- a/deploy/crd/pmem-csi.intel.com_deployments.yaml +++ b/deploy/crd/pmem-csi.intel.com_pmemcsideployments.yaml @@ -7,251 +7,18 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.3.0 creationTimestamp: null - name: deployments.pmem-csi.intel.com + name: pmemcsideployments.pmem-csi.intel.com spec: group: pmem-csi.intel.com names: - kind: Deployment - listKind: DeploymentList - plural: deployments - singular: deployment + kind: PmemCSIDeployment + listKind: PmemCSIDeploymentList + plural: pmemcsideployments + shortNames: + - pcd + singular: pmemcsideployment scope: Cluster versions: - - additionalPrinterColumns: - - jsonPath: .spec.deviceMode - name: DeviceMode - type: string - - jsonPath: .spec.nodeSelector - name: NodeSelector - type: string - - jsonPath: .spec.image - name: Image - type: string - - jsonPath: .status.phase - name: Status - type: string - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1alpha1 - schema: - 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. - enum: - - 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 - 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. Unset (= - zero) selects the default of 100%. This is only valid for driver - in LVM mode. - maximum: 100 - minimum: 0 - 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: - conditions: - description: Conditions - items: - properties: - lastUpdateTime: - description: Last time the condition was probed. - format: date-time - nullable: true - type: string - reason: - description: Message human readable text that explain why this - condition is in this state - type: string - status: - description: Status of the condition, one of True, False, Unknown. - type: string - type: - description: Type of condition. - type: string - required: - - status - - type - type: object - type: array - driverComponents: - items: - properties: - component: - description: 'DriverComponent represents type of the driver: - controller or node' - type: string - lastUpdated: - description: LastUpdated time of the driver status - format: date-time - nullable: true - type: string - reason: - description: Reason represents the human readable text that - explains why the driver is in this state. - type: string - status: - description: Status represents the state of the component; one - of `Ready` or `NotReady`. Component becomes `Ready` if all - the instances(Pods) of the driver component are in running - state. Otherwise, `NotReady`. - type: string - required: - - component - - reason - - status - type: object - type: array - lastUpdated: - description: LastUpdated time of the deployment status - format: date-time - nullable: true - type: string - phase: - description: Phase indicates the state of the deployment - type: string - reason: - type: string - type: object - type: object - served: true - storage: false - subresources: - status: {} - additionalPrinterColumns: - jsonPath: .spec.deviceMode name: DeviceMode @@ -271,7 +38,7 @@ spec: name: v1beta1 schema: openAPIV3Schema: - description: Deployment is the Schema for the deployments API + description: PmemCSIDeployment is the Schema for the deployments API properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation diff --git a/deploy/crd/pmem-csi.intel.com_pmemcsideployments_webhook.yaml b/deploy/crd/pmem-csi.intel.com_pmemcsideployments_webhook.yaml new file mode 100644 index 0000000000..36a44d4dc3 --- /dev/null +++ b/deploy/crd/pmem-csi.intel.com_pmemcsideployments_webhook.yaml @@ -0,0 +1,289 @@ +# This file was generated by controller-gen v0.3.0 via 'make operator-generate-crd' +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: pmem-csi/pmem-csi-operator-selfsigned + controller-gen.kubebuilder.io/version: v0.3.0 + creationTimestamp: null + name: pmemcsideployments.pmem-csi.intel.com +spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + name: pmem-csi-operator-service + namespace: pmem-csi + path: /convert + port: 9443 + conversionReviewVersions: + - v1beta1 + - v1alpha1 + group: pmem-csi.intel.com + names: + kind: PmemCSIDeployment + listKind: PmemCSIDeploymentList + plural: pmemcsideployments + shortNames: + - pcd + singular: pmemcsideployment + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .spec.deviceMode + name: DeviceMode + type: string + - jsonPath: .spec.nodeSelector + name: NodeSelector + type: string + - jsonPath: .spec.image + name: Image + type: string + - jsonPath: .status.phase + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1beta1 + schema: + openAPIV3Schema: + description: PmemCSIDeployment 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 + controllerDriverResources: + description: ControllerDriverResources Compute resources required by driver container running on master node + 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. + enum: + - 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 + logFormat: + description: LogFormat + enum: + - text + - json + type: string + logLevel: + description: LogLevel number for the log verbosity + 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 + nodeDriverResources: + description: NodeDriverResources Compute resources required by driver container running on worker nodes + 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 + nodeRegistrarImage: + description: NodeRegistrarImage CSI node driver registrar sidecar image + type: string + nodeRegistrarResources: + description: NodeRegistrarResources Compute resources required by node registrar sidecar container + 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. Unset (= zero) selects the default of 100%. This is only valid for driver in LVM mode. + maximum: 100 + minimum: 0 + type: integer + provisionerImage: + description: ProvisionerImage CSI provisioner sidecar image + type: string + provisionerResources: + description: ProvisionerResources Compute resources required by provisioner sidecar container + 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 + 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: + conditions: + description: Conditions + items: + properties: + lastUpdateTime: + description: Last time the condition was probed. + format: date-time + nullable: true + type: string + reason: + description: Message human readable text that explain why this condition is in this state + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type of condition. + type: string + required: + - status + - type + type: object + type: array + driverComponents: + items: + properties: + component: + description: 'DriverComponent represents type of the driver: controller or node' + type: string + lastUpdated: + description: LastUpdated time of the driver status + format: date-time + nullable: true + type: string + reason: + description: Reason represents the human readable text that explains why the driver is in this state. + type: string + status: + description: Status represents the state of the component; one of `Ready` or `NotReady`. Component becomes `Ready` if all the instances(Pods) of the driver component are in running state. Otherwise, `NotReady`. + type: string + required: + - component + - reason + - status + type: object + type: array + lastUpdated: + description: LastUpdated time of the deployment status + format: date-time + nullable: true + type: string + phase: + description: Phase indicates the state of the deployment + type: string + reason: + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/deploy/kustomize/crd/kustomization.yaml b/deploy/kustomize/crd/kustomization.yaml index 70d7bfab11..2665785aaf 100644 --- a/deploy/kustomize/crd/kustomization.yaml +++ b/deploy/kustomize/crd/kustomization.yaml @@ -1,13 +1,13 @@ # Kustomize generated CRD by patching with webhook # conversion client configuration resources: -- ../../crd/pmem-csi.intel.com_deployments.yaml # This file is generated by `make operator-generate-crd` +- ../../crd/pmem-csi.intel.com_pmemcsideployments.yaml # This file is generated by `make operator-generate-crd` patchesJSON6902: - target: group: "apiextensions.k8s.io" version: v1 kind: CustomResourceDefinition - name: deployments.pmem-csi.intel.com + name: pmemcsideployments.pmem-csi.intel.com path: ../patches/crd-conversion-webhook-patch.yaml diff --git a/deploy/kustomize/olm-catalog/kustomization.yaml b/deploy/kustomize/olm-catalog/kustomization.yaml index 9bff5576eb..f52b67ac69 100644 --- a/deploy/kustomize/olm-catalog/kustomization.yaml +++ b/deploy/kustomize/olm-catalog/kustomization.yaml @@ -3,8 +3,9 @@ bases: resources: - ../../common/pmem-csi.intel.com_v1alpha1_deployment_cr.yaml -- ../../common/pmem-csi.intel.com_v1beta1_deployment_cr.yaml +- ../../common/pmem-csi.intel.com_v1beta1_pmemcsideployment_cr.yaml - ../../crd/pmem-csi.intel.com_deployments.yaml +- ../../crd/pmem-csi.intel.com_pmemcsideployments.yaml images: - name: intel/pmem-csi-driver diff --git a/deploy/kustomize/operator-webhook/kustomization.yaml b/deploy/kustomize/operator-webhook/kustomization.yaml index a10ea73f54..71371b6257 100644 --- a/deploy/kustomize/operator-webhook/kustomization.yaml +++ b/deploy/kustomize/operator-webhook/kustomization.yaml @@ -5,8 +5,6 @@ resources: - webhook-certificate.yaml - webhook-service.yaml -namespace: pmem-csi - patchesJson6902: - target: group: apps diff --git a/deploy/kustomize/operator-webhook/webhook-certificate.yaml b/deploy/kustomize/operator-webhook/webhook-certificate.yaml index 0750a71542..b74a1d6196 100644 --- a/deploy/kustomize/operator-webhook/webhook-certificate.yaml +++ b/deploy/kustomize/operator-webhook/webhook-certificate.yaml @@ -5,6 +5,7 @@ apiVersion: cert-manager.io/v1 kind: Issuer metadata: name: self-signed-issuer + namespace: pmem-csi spec: selfSigned: {} --- @@ -12,6 +13,7 @@ apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: pmem-csi-operator-selfsigned # the name used for 'cert-manager.io.inject-ca-from' CRD annotation + namespace: pmem-csi spec: dnsNames: # dnsNames must match be: <.namespace>.svc[.domain] diff --git a/deploy/kustomize/operator-webhook/webhook-service.yaml b/deploy/kustomize/operator-webhook/webhook-service.yaml index 0243b691d4..06652233a5 100644 --- a/deploy/kustomize/operator-webhook/webhook-service.yaml +++ b/deploy/kustomize/operator-webhook/webhook-service.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: name: pmem-csi-operator-service # name referenced in webhook-certificate.yaml for dnsNames - namespace: default + namespace: pmem-csi spec: ports: - port: 9443 diff --git a/deploy/kustomize/operator/operator.yaml b/deploy/kustomize/operator/operator.yaml index 35149ca792..bfdd5c9586 100644 --- a/deploy/kustomize/operator/operator.yaml +++ b/deploy/kustomize/operator/operator.yaml @@ -72,9 +72,9 @@ rules: - apiGroups: - pmem-csi.intel.com resources: - - deployments - - deployments/status - - deployments/finalizers + - pmemcsideployments + - pmemcsideployments/status + - pmemcsideployments/finalizers verbs: - '*' --- diff --git a/deploy/operator/pmem-csi-operator-webhook.yaml b/deploy/operator/pmem-csi-operator-webhook.yaml index ab1ba7e8ea..3360155381 100644 --- a/deploy/operator/pmem-csi-operator-webhook.yaml +++ b/deploy/operator/pmem-csi-operator-webhook.yaml @@ -13,6 +13,19 @@ metadata: --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role +metadata: + name: pmem-csi-operator-event + namespace: default +rules: +- apiGroups: + - "" + resources: + - events + verbs: + - '*' +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role metadata: creationTimestamp: null name: pmem-csi-operator @@ -53,19 +66,6 @@ rules: - get --- apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: pmem-csi-operator-event - namespace: pmem-csi -rules: -- apiGroups: - - "" - resources: - - events - verbs: - - '*' ---- -apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: pmem-csi-operator @@ -86,21 +86,21 @@ rules: - apiGroups: - pmem-csi.intel.com resources: - - deployments - - deployments/status - - deployments/finalizers + - pmemcsideployments + - pmemcsideployments/status + - pmemcsideployments/finalizers verbs: - '*' --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: pmem-csi-operator - namespace: pmem-csi + name: pmem-csi-operator-event + namespace: default roleRef: apiGroup: rbac.authorization.k8s.io kind: Role - name: pmem-csi-operator + name: pmem-csi-operator-event subjects: - kind: ServiceAccount name: pmem-csi-operator @@ -109,12 +109,12 @@ subjects: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: pmem-csi-operator-event + name: pmem-csi-operator namespace: pmem-csi roleRef: apiGroup: rbac.authorization.k8s.io kind: Role - name: pmem-csi-operator-event + name: pmem-csi-operator subjects: - kind: ServiceAccount name: pmem-csi-operator diff --git a/deploy/operator/pmem-csi-operator.yaml b/deploy/operator/pmem-csi-operator.yaml index a601c04351..830d21eb42 100644 --- a/deploy/operator/pmem-csi-operator.yaml +++ b/deploy/operator/pmem-csi-operator.yaml @@ -86,9 +86,9 @@ rules: - apiGroups: - pmem-csi.intel.com resources: - - deployments - - deployments/status - - deployments/finalizers + - pmemcsideployments + - pmemcsideployments/status + - pmemcsideployments/finalizers verbs: - '*' --- diff --git a/operator/operator.make b/operator/operator.make index ef5fe97ad7..cb01fd4ade 100644 --- a/operator/operator.make +++ b/operator/operator.make @@ -73,8 +73,8 @@ operator-generate-crd: controller-gen # Kustomize CRD by applying conversion webhook configuration patch operator-kustomize-crd: _work/kustomize - @_work/kustomize build --load_restrictor=none $(CRD_KUSTOMIZE_DIR) -o $(CRD_DIR)/pmem-csi.intel.com_deployments_webhook.yaml - @$(PATCH_CRD_ANNOTATION) $(CRD_DIR)/pmem-csi.intel.com_deployments_webhook.yaml + @_work/kustomize build --load_restrictor=none $(CRD_KUSTOMIZE_DIR) -o $(CRD_DIR)/pmem-csi.intel.com_pmemcsideployments_webhook.yaml + @$(PATCH_CRD_ANNOTATION) $(CRD_DIR)/pmem-csi.intel.com_pmemcsideployments_webhook.yaml # Generate packagemanifests using operator-sdk. operator-generate-catalog: _work/bin/operator-sdk-$(OPERATOR_SDK_VERSION) _work/kustomize operator-generate-crd diff --git a/pkg/apis/pmemcsi/v1alpha1/deployment_conversion.go b/pkg/apis/pmemcsi/v1alpha1/deployment_conversion.go index 357261bb18..26117336c3 100644 --- a/pkg/apis/pmemcsi/v1alpha1/deployment_conversion.go +++ b/pkg/apis/pmemcsi/v1alpha1/deployment_conversion.go @@ -28,7 +28,7 @@ var _ conversion.Convertible = &Deployment{} // ConvertTo converts to Hub(v1beta1) type func (d *Deployment) ConvertTo(dst conversion.Hub) error { in := d.DeepCopy() - out := dst.(*v1beta1.Deployment) + out := dst.(*v1beta1.PmemCSIDeployment) // Use v1alpha1 `spec.{node,controller}Resources` for setting pmem-driver // container resources, other container resources are set to default. @@ -84,7 +84,7 @@ func (d *Deployment) ConvertTo(dst conversion.Hub) error { // ConvertFrom converts from Hub type to current type func (d *Deployment) ConvertFrom(src conversion.Hub) error { - in := src.(*v1beta1.Deployment).DeepCopy() + in := src.(*v1beta1.PmemCSIDeployment).DeepCopy() out := d // Use v1beta1 `spec.{node,controller}DriverResources` as setting the diff --git a/pkg/apis/pmemcsi/v1beta1/deployment_conversion.go b/pkg/apis/pmemcsi/v1beta1/deployment_conversion.go index 807b62c275..1e2f8c5f9d 100644 --- a/pkg/apis/pmemcsi/v1beta1/deployment_conversion.go +++ b/pkg/apis/pmemcsi/v1beta1/deployment_conversion.go @@ -20,8 +20,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/conversion" ) -var _ conversion.Hub = &Deployment{} +var _ conversion.Hub = &PmemCSIDeployment{} // Hub marks this(v1beta1) type as a conversion hub. // Conversion hub is the version that all other CRD versions get converted into. -func (*Deployment) Hub() {} +func (*PmemCSIDeployment) Hub() {} diff --git a/pkg/apis/pmemcsi/v1beta1/deployment_types.go b/pkg/apis/pmemcsi/v1beta1/deployment_types.go index 016f7b6bbd..e561d8b365 100644 --- a/pkg/apis/pmemcsi/v1beta1/deployment_types.go +++ b/pkg/apis/pmemcsi/v1beta1/deployment_types.go @@ -198,16 +198,16 @@ type DeploymentStatus struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// Deployment is the Schema for the deployments API +// PmemCSIDeployment is the Schema for the deployments API // +kubebuilder:subresource:status -// +kubebuilder:resource:path=deployments,scope=Cluster +// +kubebuilder:resource:path=pmemcsideployments,scope=Cluster,shortName=pcd,singular=pmemcsideployment // +kubebuilder:printcolumn:name="DeviceMode",type=string,JSONPath=`.spec.deviceMode` // +kubebuilder:printcolumn:name="NodeSelector",type=string,JSONPath=`.spec.nodeSelector` // +kubebuilder:printcolumn:name="Image",type=string,JSONPath=`.spec.image` // +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.phase` // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` // +kubebuilder:storageversion -type Deployment struct { +type PmemCSIDeployment struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -217,15 +217,15 @@ type Deployment struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// DeploymentList contains a list of Deployment -type DeploymentList struct { +// PmemCSIDeploymentList contains a list of Deployment +type PmemCSIDeploymentList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []Deployment `json:"items"` + Items []PmemCSIDeployment `json:"items"` } func init() { - SchemeBuilder.Register(&Deployment{}, &DeploymentList{}) + SchemeBuilder.Register(&PmemCSIDeployment{}, &PmemCSIDeploymentList{}) } const ( @@ -324,7 +324,7 @@ const ( DeploymentPhaseFailed DeploymentPhase = "Failed" ) -func (d *Deployment) SetCondition(t DeploymentConditionType, state corev1.ConditionStatus, reason string) { +func (d *PmemCSIDeployment) SetCondition(t DeploymentConditionType, state corev1.ConditionStatus, reason string) { for _, c := range d.Status.Conditions { if c.Type == t { c.Status = state @@ -341,7 +341,7 @@ func (d *Deployment) SetCondition(t DeploymentConditionType, state corev1.Condit }) } -func (d *Deployment) SetDriverStatus(t DriverType, status, reason string) { +func (d *PmemCSIDeployment) SetDriverStatus(t DriverType, status, reason string) { if d.Status.Components == nil { d.Status.Components = make([]DriverStatus, 2) } @@ -354,7 +354,7 @@ func (d *Deployment) SetDriverStatus(t DriverType, status, reason string) { } // EnsureDefaults make sure that the deployment object has all defaults set properly -func (d *Deployment) EnsureDefaults(operatorImage string) error { +func (d *PmemCSIDeployment) EnsureDefaults(operatorImage string) error { // Validate the given driver mode. // In a realistic case this check might not needed as it should be // handled by JSON schema as we defined deviceMode as enumeration. @@ -463,85 +463,85 @@ func (d *Deployment) EnsureDefaults(operatorImage string) error { // Most objects created for the deployment will use hyphens in the name, sometimes // with an additional suffix like -controller, but others must use the original // name (like the CSIDriver object). -func (d *Deployment) GetHyphenedName() string { +func (d *PmemCSIDeployment) GetHyphenedName() string { return strings.ReplaceAll(d.GetName(), ".", "-") } // RegistrySecretName returns the name of the registry // Secret object used by the deployment -func (d *Deployment) RegistrySecretName() string { +func (d *PmemCSIDeployment) RegistrySecretName() string { return d.GetHyphenedName() + "-registry-secrets" } // NodeSecretName returns the name of the node-controller // Secret object used by the deployment -func (d *Deployment) NodeSecretName() string { +func (d *PmemCSIDeployment) NodeSecretName() string { return d.GetHyphenedName() + "-node-secrets" } // CSIDriverName returns the name of the CSIDriver // object name for the deployment -func (d *Deployment) CSIDriverName() string { +func (d *PmemCSIDeployment) CSIDriverName() string { return d.GetName() } // ControllerServiceName returns the name of the controller // Service object used by the deployment -func (d *Deployment) ControllerServiceName() string { +func (d *PmemCSIDeployment) ControllerServiceName() string { return d.GetHyphenedName() + "-controller" } // MetricsServiceName returns the name of the controller metrics // Service object used by the deployment -func (d *Deployment) MetricsServiceName() string { +func (d *PmemCSIDeployment) MetricsServiceName() string { return d.GetHyphenedName() + "-metrics" } // ServiceAccountName returns the name of the ServiceAccount // object used by the deployment -func (d *Deployment) ServiceAccountName() string { +func (d *PmemCSIDeployment) ServiceAccountName() string { return d.GetHyphenedName() + "-controller" } // ProvisionerRoleName returns the name of the provisioner's // RBAC Role object name used by the deployment -func (d *Deployment) ProvisionerRoleName() string { +func (d *PmemCSIDeployment) ProvisionerRoleName() string { return d.GetHyphenedName() + "-external-provisioner-cfg" } // ProvisionerRoleBindingName returns the name of the provisioner's // RoleBinding object name used by the deployment -func (d *Deployment) ProvisionerRoleBindingName() string { +func (d *PmemCSIDeployment) ProvisionerRoleBindingName() string { return d.GetHyphenedName() + "-csi-provisioner-role-cfg" } // ProvisionerClusterRoleName returns the name of the // provisioner's ClusterRole object name used by the deployment -func (d *Deployment) ProvisionerClusterRoleName() string { +func (d *PmemCSIDeployment) ProvisionerClusterRoleName() string { return d.GetHyphenedName() + "-external-provisioner-runner" } // ProvisionerClusterRoleBindingName returns the name of the // provisioner ClusterRoleBinding object name used by the deployment -func (d *Deployment) ProvisionerClusterRoleBindingName() string { +func (d *PmemCSIDeployment) ProvisionerClusterRoleBindingName() string { return d.GetHyphenedName() + "-csi-provisioner-role" } // NodeDriverName returns the name of the driver // DaemonSet object name used by the deployment -func (d *Deployment) NodeDriverName() string { +func (d *PmemCSIDeployment) NodeDriverName() string { return d.GetHyphenedName() + "-node" } // ControllerDriverName returns the name of the controller // StatefulSet object name used by the deployment -func (d *Deployment) ControllerDriverName() string { +func (d *PmemCSIDeployment) ControllerDriverName() string { return d.GetHyphenedName() + "-controller" } // GetOwnerReference returns self owner reference could be used by other object // to add this deployment to it's owner reference list. -func (d *Deployment) GetOwnerReference() metav1.OwnerReference { +func (d *PmemCSIDeployment) GetOwnerReference() metav1.OwnerReference { blockOwnerDeletion := true isController := true return metav1.OwnerReference{ @@ -559,7 +559,7 @@ func (d *Deployment) GetOwnerReference() metav1.OwnerReference { // - true with nil error if provided certificates are valid. // - false with nil error if no certificates are provided. // - false with appropriate error if invalid/incomplete certificates provided. -func (d *Deployment) HaveCertificatesConfigured() (bool, error) { +func (d *PmemCSIDeployment) HaveCertificatesConfigured() (bool, error) { // Encoded private keys and certificates caCert := d.Spec.CACert registryPrKey := d.Spec.RegistryPrivateKey diff --git a/pkg/apis/pmemcsi/v1beta1/deployment_types_test.go b/pkg/apis/pmemcsi/v1beta1/deployment_types_test.go index 5e839f4a38..5051b52b32 100644 --- a/pkg/apis/pmemcsi/v1beta1/deployment_types_test.go +++ b/pkg/apis/pmemcsi/v1beta1/deployment_types_test.go @@ -35,7 +35,7 @@ var _ = Describe("Operator", func() { Context("API", func() { It("shall set defaults for empty deployment", func() { - d := api.Deployment{} + d := api.PmemCSIDeployment{} err := d.EnsureDefaults("") Expect(err).ShouldNot(HaveOccurred(), "ensure defaults") @@ -80,7 +80,7 @@ var _ = Describe("Operator", func() { }) It("shall be able to set values", func() { - yaml := `kind: Deployment + yaml := `kind: PmemCSIDeployment apiVersion: pmem-csi.intel.com/v1beta1 metadata: name: test-deployment @@ -114,7 +114,7 @@ spec: Expect(err).Should(BeNil(), "Failed to parse deployment") Expect(obj).ShouldNot(BeNil(), "Nil deployment object") - d := obj.(*api.Deployment) + d := obj.(*api.PmemCSIDeployment) err = d.EnsureDefaults("") Expect(err).ShouldNot(HaveOccurred(), "ensure defaults") @@ -148,7 +148,7 @@ spec: It("should have valid json schema", func() { - crdFile := os.Getenv("REPO_ROOT") + "/deploy/crd/pmem-csi.intel.com_deployments.yaml" + crdFile := os.Getenv("REPO_ROOT") + "/deploy/crd/pmem-csi.intel.com_pmemcsideployments.yaml" data, err := ioutil.ReadFile(crdFile) Expect(err).ShouldNot(HaveOccurred(), "load crd data") crd := &apiextensions.CustomResourceDefinition{} diff --git a/pkg/apis/pmemcsi/v1beta1/zz_generated.deepcopy.go b/pkg/apis/pmemcsi/v1beta1/zz_generated.deepcopy.go index b8bfa8155a..7d40cf8e3a 100644 --- a/pkg/apis/pmemcsi/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/pmemcsi/v1beta1/zz_generated.deepcopy.go @@ -9,33 +9,6 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Deployment) DeepCopyInto(out *Deployment) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Deployment. -func (in *Deployment) DeepCopy() *Deployment { - if in == nil { - return nil - } - out := new(Deployment) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Deployment) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DeploymentCondition) DeepCopyInto(out *DeploymentCondition) { *out = *in @@ -52,38 +25,6 @@ func (in *DeploymentCondition) DeepCopy() *DeploymentCondition { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DeploymentList) DeepCopyInto(out *DeploymentList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Deployment, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentList. -func (in *DeploymentList) DeepCopy() *DeploymentList { - if in == nil { - return nil - } - out := new(DeploymentList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DeploymentList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DeploymentSpec) DeepCopyInto(out *DeploymentSpec) { *out = *in @@ -203,3 +144,62 @@ func (in *DriverStatus) DeepCopy() *DriverStatus { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PmemCSIDeployment) DeepCopyInto(out *PmemCSIDeployment) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PmemCSIDeployment. +func (in *PmemCSIDeployment) DeepCopy() *PmemCSIDeployment { + if in == nil { + return nil + } + out := new(PmemCSIDeployment) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PmemCSIDeployment) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PmemCSIDeploymentList) DeepCopyInto(out *PmemCSIDeploymentList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PmemCSIDeployment, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PmemCSIDeploymentList. +func (in *PmemCSIDeploymentList) DeepCopy() *PmemCSIDeploymentList { + if in == nil { + return nil + } + out := new(PmemCSIDeploymentList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PmemCSIDeploymentList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} diff --git a/pkg/deployments/load.go b/pkg/deployments/load.go index 5b531a5398..81a61222e7 100644 --- a/pkg/deployments/load.go +++ b/pkg/deployments/load.go @@ -33,7 +33,7 @@ var nameRegex = regexp.MustCompile(`(name|app|secretName|serviceName|serviceAcco // LoadAndCustomizeObjects reads all objects stored in a pmem-csi.yaml reference file // and updates them on-the-fly according to the deployment spec, namespace and name. func LoadAndCustomizeObjects(kubernetes version.Version, deviceMode api.DeviceMode, - namespace string, deployment api.Deployment) ([]unstructured.Unstructured, error) { + namespace string, deployment api.PmemCSIDeployment) ([]unstructured.Unstructured, error) { // Conceptually this function is similar to calling "kustomize" for // our deployments. But because we controll the input, we can do some @@ -124,7 +124,7 @@ func LoadAndCustomizeObjects(kubernetes version.Version, deviceMode api.DeviceMo return loadObjects(kubernetes, deviceMode, patchYAML, patchUnstructured) } -func patchPodTemplate(obj *unstructured.Unstructured, deployment api.Deployment, resources map[string]*corev1.ResourceRequirements) error { +func patchPodTemplate(obj *unstructured.Unstructured, deployment api.PmemCSIDeployment, resources map[string]*corev1.ResourceRequirements) error { if resources == nil { return nil } diff --git a/pkg/deployments/load_test.go b/pkg/deployments/load_test.go index 3a44dc7904..4c9ed82d4b 100644 --- a/pkg/deployments/load_test.go +++ b/pkg/deployments/load_test.go @@ -46,7 +46,7 @@ func TestLoadObjects(t *testing.T) { // currently run as part of test/e2e/operator API testing, with // the code in controller_driver.go serving as reference. namespace := "kube-system" - deployment := api.Deployment{ + deployment := api.PmemCSIDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: "pmem-csi.example.org", }, diff --git a/pkg/pmem-csi-operator/controller/deployment/controller_driver.go b/pkg/pmem-csi-operator/controller/deployment/controller_driver.go index 7f2874c878..3b707e4414 100644 --- a/pkg/pmem-csi-operator/controller/deployment/controller_driver.go +++ b/pkg/pmem-csi-operator/controller/deployment/controller_driver.go @@ -106,7 +106,7 @@ func AllObjectLists() []*unstructured.UnstructuredList { // pmemCSIDeployment represents the desired state of a PMEM-CSI driver // deployment. type pmemCSIDeployment struct { - *api.Deployment + *api.PmemCSIDeployment // operator's namespace used for creating sub-resources namespace string k8sVersion version.Version @@ -577,7 +577,7 @@ func (d *pmemCSIDeployment) handleEvent(ctx context.Context, metaData metav1.Obj if _, err := d.redeploy(ctx, r, handler); err != nil { return fmt.Errorf("failed to redeploy %s: %v", name, err) } - if err := r.patchDeploymentStatus(d.Deployment, client.MergeFrom(org)); err != nil { + if err := r.patchDeploymentStatus(d.PmemCSIDeployment, client.MergeFrom(org)); err != nil { return fmt.Errorf("failed to update deployment CR status: %v", err) } } diff --git a/pkg/pmem-csi-operator/controller/deployment/deployment_controller.go b/pkg/pmem-csi-operator/controller/deployment/deployment_controller.go index 56e3f7f486..8c90ac6de7 100644 --- a/pkg/pmem-csi-operator/controller/deployment/deployment_controller.go +++ b/pkg/pmem-csi-operator/controller/deployment/deployment_controller.go @@ -110,7 +110,7 @@ func add(ctx context.Context, mgr manager.Manager, r *ReconcileDeployment) error } // Watch for changes to primary resource Deployment - if err := c.Watch(&source.Kind{Type: &api.Deployment{}}, &handler.EnqueueRequestForObject{}, p); err != nil { + if err := c.Watch(&source.Kind{Type: &api.PmemCSIDeployment{}}, &handler.EnqueueRequestForObject{}, p); err != nil { return fmt.Errorf("watch: %v", err) } @@ -168,7 +168,7 @@ func add(ctx context.Context, mgr manager.Manager, r *ReconcileDeployment) error for _, resource := range currentObjects { if err := c.Watch(&source.Kind{Type: resource}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &api.Deployment{}, + OwnerType: &api.PmemCSIDeployment{}, }, sop); err != nil { return fmt.Errorf("create watch: %v", err) } @@ -181,7 +181,7 @@ func add(ctx context.Context, mgr manager.Manager, r *ReconcileDeployment) error var _ reconcile.Reconciler = &ReconcileDeployment{} // ReconcileHook function to be invoked on reconciling a deployment. -type ReconcileHook *func(d *api.Deployment) +type ReconcileHook *func(d *api.PmemCSIDeployment) // ReconcileDeployment reconciles a Deployment object type ReconcileDeployment struct { @@ -197,7 +197,7 @@ type ReconcileDeployment struct { // container image used for deploying the operator containerImage string // known deployments - deployments map[string]*api.Deployment + deployments map[string]*api.PmemCSIDeployment // deploymentsMutex protects concurrent access to deployments deploymentsMutex sync.Mutex // reconcileMutex synchronizes concurrent reconcile calls @@ -246,7 +246,7 @@ func NewReconcileDeployment(ctx context.Context, client client.Client, opts pmem k8sVersion: opts.K8sVersion, namespace: opts.Namespace, containerImage: opts.DriverImage, - deployments: map[string]*api.Deployment{}, + deployments: map[string]*api.PmemCSIDeployment{}, reconcileHooks: map[ReconcileHook]struct{}{}, }, nil } @@ -268,7 +268,7 @@ func (r *ReconcileDeployment) Reconcile(request reconcile.Request) (reconcile.Re ctx := logger.Set(r.ctx, l) // Fetch the Deployment instance - deployment := &api.Deployment{} + deployment := &api.PmemCSIDeployment{} err = r.client.Get(ctx, request.NamespacedName, deployment) if err != nil { l.Error(err, "failed to retrieve CR to reconcile", "deployment", request.Name) @@ -375,7 +375,7 @@ func (r *ReconcileDeployment) Delete(obj runtime.Object) error { } // PatchDeploymentStatus patches the give given deployment CR status -func (r *ReconcileDeployment) patchDeploymentStatus(dep *api.Deployment, patch client.Patch) error { +func (r *ReconcileDeployment) patchDeploymentStatus(dep *api.PmemCSIDeployment, patch client.Patch) error { dep.Status.LastUpdated = metav1.Now() // Passing a copy of CR to patch as the fake client used in tests // will write back the changes to both status and spec. @@ -387,13 +387,13 @@ func (r *ReconcileDeployment) patchDeploymentStatus(dep *api.Deployment, patch c return nil } -func (r *ReconcileDeployment) saveDeployment(d *api.Deployment) { +func (r *ReconcileDeployment) saveDeployment(d *api.PmemCSIDeployment) { r.deploymentsMutex.Lock() defer r.deploymentsMutex.Unlock() r.deployments[d.Name] = d } -func (r *ReconcileDeployment) getDeployment(name string) *api.Deployment { +func (r *ReconcileDeployment) getDeployment(name string) *api.PmemCSIDeployment { r.deploymentsMutex.Lock() defer r.deploymentsMutex.Unlock() return r.deployments[name] diff --git a/pkg/pmem-csi-operator/controller/deployment/deployment_controller_test.go b/pkg/pmem-csi-operator/controller/deployment/deployment_controller_test.go index d234d29c45..ccf261d4bb 100644 --- a/pkg/pmem-csi-operator/controller/deployment/deployment_controller_test.go +++ b/pkg/pmem-csi-operator/controller/deployment/deployment_controller_test.go @@ -57,10 +57,10 @@ type pmemDeployment struct { kubeletDir string } -func getDeployment(d *pmemDeployment) *api.Deployment { - dep := &api.Deployment{ +func getDeployment(d *pmemDeployment) *api.PmemCSIDeployment { + dep := &api.PmemCSIDeployment{ TypeMeta: metav1.TypeMeta{ - Kind: "Deployment", + Kind: "PmemCSIDeployment", APIVersion: api.SchemeGroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ @@ -126,7 +126,7 @@ func getDeployment(d *pmemDeployment) *api.Deployment { } func testDeploymentPhase(t *testing.T, c client.Client, name string, expectedPhase api.DeploymentPhase) { - depObject := &api.Deployment{ + depObject := &api.PmemCSIDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, @@ -179,7 +179,7 @@ func objectKey(name string, namespace ...string) client.ObjectKey { } func deleteDeployment(c client.Client, name, ns string) error { - dep := &api.Deployment{} + dep := &api.PmemCSIDeployment{} key := objectKey(name) if err := c.Get(context.TODO(), key, dep); err != nil { return err @@ -262,7 +262,7 @@ func TestDeploymentController(t *testing.T) { } } - validateEvents := func(tc *testContext, dep *api.Deployment, expectedEvents []string) { + validateEvents := func(tc *testContext, dep *api.PmemCSIDeployment, expectedEvents []string) { require.Eventually(tc.t, func() bool { return len(tc.events) >= len(expectedEvents) }, 30*time.Second, time.Second, "receive all expected events") @@ -276,7 +276,7 @@ func TestDeploymentController(t *testing.T) { } validateConditions := func(tc *testContext, name string, expected map[api.DeploymentConditionType]corev1.ConditionStatus) { - dep := &api.Deployment{ + dep := &api.PmemCSIDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, @@ -290,9 +290,9 @@ func TestDeploymentController(t *testing.T) { } } - validateDriver := func(tc *testContext, dep *api.Deployment, expectedEvents []string, wasUpdated bool) { + validateDriver := func(tc *testContext, dep *api.PmemCSIDeployment, expectedEvents []string, wasUpdated bool) { // We may have to fill in some defaults, so make a copy first. - dep = dep.DeepCopyObject().(*api.Deployment) + dep = dep.DeepCopyObject().(*api.PmemCSIDeployment) if dep.Spec.Image == "" { dep.Spec.Image = testDriverImage } @@ -595,13 +595,13 @@ func TestDeploymentController(t *testing.T) { name: "modified-deployment", } - var updatedDep *api.Deployment + var updatedDep *api.PmemCSIDeployment dep := getDeployment(d) err := tc.c.Create(tc.ctx, dep) require.NoError(t, err, "failed to create deployment") - hook := func(d *api.Deployment) { + hook := func(d *api.PmemCSIDeployment) { updatedDep = d.DeepCopy() updatedDep.Spec.LogLevel++ err := tc.c.Update(tc.ctx, updatedDep) @@ -634,7 +634,7 @@ func TestDeploymentController(t *testing.T) { testIt := func(restart bool) { tc := setup(t) defer teardown(tc) - dep := testcase.Deployment.DeepCopyObject().(*api.Deployment) + dep := testcase.Deployment.DeepCopyObject().(*api.PmemCSIDeployment) // Assumption is that all the testcases are positive cases. conditions := map[api.DeploymentConditionType]corev1.ConditionStatus{ diff --git a/pkg/pmem-csi-operator/controller/deployment/testcases/testcases.go b/pkg/pmem-csi-operator/controller/deployment/testcases/testcases.go index 47f49e7081..c0562b7965 100644 --- a/pkg/pmem-csi-operator/controller/deployment/testcases/testcases.go +++ b/pkg/pmem-csi-operator/controller/deployment/testcases/testcases.go @@ -23,25 +23,25 @@ import ( // change one or more fields in it. type UpdateTest struct { Name string - Deployment api.Deployment - Mutate func(d *api.Deployment) + Deployment api.PmemCSIDeployment + Mutate func(d *api.PmemCSIDeployment) } func UpdateTests() []UpdateTest { - singleMutators := map[string]func(d *api.Deployment){ - "image": func(d *api.Deployment) { + singleMutators := map[string]func(d *api.PmemCSIDeployment){ + "image": func(d *api.PmemCSIDeployment) { d.Spec.Image = "updated-image" }, - "pullPolicy": func(d *api.Deployment) { + "pullPolicy": func(d *api.PmemCSIDeployment) { d.Spec.PullPolicy = corev1.PullNever }, - "provisionerImage": func(d *api.Deployment) { + "provisionerImage": func(d *api.PmemCSIDeployment) { d.Spec.ProvisionerImage = "still-no-such-provisioner-image" }, - "nodeRegistrarImage": func(d *api.Deployment) { + "nodeRegistrarImage": func(d *api.PmemCSIDeployment) { d.Spec.NodeRegistrarImage = "still-no-such-registrar-image" }, - "controllerDriverResources": func(d *api.Deployment) { + "controllerDriverResources": func(d *api.PmemCSIDeployment) { d.Spec.ControllerDriverResources = &corev1.ResourceRequirements{ Limits: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("201m"), @@ -49,7 +49,7 @@ func UpdateTests() []UpdateTest { }, } }, - "nodeDriverResources": func(d *api.Deployment) { + "nodeDriverResources": func(d *api.PmemCSIDeployment) { d.Spec.NodeDriverResources = &corev1.ResourceRequirements{ Limits: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("501m"), @@ -57,7 +57,7 @@ func UpdateTests() []UpdateTest { }, } }, - "provisionerResources": func(d *api.Deployment) { + "provisionerResources": func(d *api.PmemCSIDeployment) { d.Spec.ProvisionerResources = &corev1.ResourceRequirements{ Limits: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("101m"), @@ -65,7 +65,7 @@ func UpdateTests() []UpdateTest { }, } }, - "nodeRegistrarResources": func(d *api.Deployment) { + "nodeRegistrarResources": func(d *api.PmemCSIDeployment) { d.Spec.NodeRegistrarResources = &corev1.ResourceRequirements{ Limits: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("301m"), @@ -73,39 +73,39 @@ func UpdateTests() []UpdateTest { }, } }, - "TLS": func(d *api.Deployment) { + "TLS": func(d *api.PmemCSIDeployment) { SetTLSOrDie(&d.Spec) }, - "logLevel": func(d *api.Deployment) { + "logLevel": func(d *api.PmemCSIDeployment) { d.Spec.LogLevel++ }, - "logFormat": func(d *api.Deployment) { + "logFormat": func(d *api.PmemCSIDeployment) { if d.Spec.LogFormat == api.LogFormatText { d.Spec.LogFormat = api.LogFormatJSON } else { d.Spec.LogFormat = api.LogFormatText } }, - "nodeSelector": func(d *api.Deployment) { + "nodeSelector": func(d *api.PmemCSIDeployment) { d.Spec.NodeSelector = map[string]string{ "still-no-such-label": "still-no-such-value", } }, - "pmemPercentage": func(d *api.Deployment) { + "pmemPercentage": func(d *api.PmemCSIDeployment) { d.Spec.PMEMPercentage++ }, - "labels": func(d *api.Deployment) { + "labels": func(d *api.PmemCSIDeployment) { if d.Spec.Labels == nil { d.Spec.Labels = map[string]string{} } d.Spec.Labels["foo"] = "bar" }, - "kubeletDir": func(d *api.Deployment) { + "kubeletDir": func(d *api.PmemCSIDeployment) { d.Spec.KubeletDir = "/foo/bar" }, } - full := api.Deployment{ + full := api.PmemCSIDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: "pmem-csi-with-values", }, @@ -168,7 +168,7 @@ func UpdateTests() []UpdateTest { } SetTLSOrDie(&full.Spec) - baseDeployments := map[string]api.Deployment{ + baseDeployments := map[string]api.PmemCSIDeployment{ "default deployment": { ObjectMeta: metav1.ObjectMeta{ Name: "pmem-csi-with-defaults", @@ -177,7 +177,7 @@ func UpdateTests() []UpdateTest { "deployment with specific values": full, } - updateAll := func(d *api.Deployment) { + updateAll := func(d *api.PmemCSIDeployment) { for _, mutator := range singleMutators { mutator(d) } diff --git a/pkg/pmem-csi-operator/main.go b/pkg/pmem-csi-operator/main.go index a559017af2..b5b61d41d2 100644 --- a/pkg/pmem-csi-operator/main.go +++ b/pkg/pmem-csi-operator/main.go @@ -127,7 +127,7 @@ func Main() int { // Setup conversion webhooks if *startWebhook { - if err := setupWebhookWithManager(mgr, &api.Deployment{ + if err := setupWebhookWithManager(mgr, &api.PmemCSIDeployment{ ObjectMeta: metav1.ObjectMeta{Name: "pmem-csi-operator"}, }); err != nil { pmemcommon.ExitError("Failed to create webhook(v1alpha1)", err) @@ -143,7 +143,7 @@ func Main() int { return 1 } - list := &api.DeploymentList{} + list := &api.PmemCSIDeploymentList{} if err := mgr.GetClient().List(ctx, list); err != nil { pmemcommon.ExitError("failed to get deployment list: %v", err) return 1 diff --git a/test/e2e/deploy/deploy.go b/test/e2e/deploy/deploy.go index d378278c20..e00bac0ed7 100644 --- a/test/e2e/deploy/deploy.go +++ b/test/e2e/deploy/deploy.go @@ -352,7 +352,7 @@ func RemoveObjects(c *Cluster, deployment *Deployment) error { // restarting things that we want removed. if list, err := c.dc.Resource(DeploymentResource).List(context.Background(), filter); !failure(err) && list != nil { for _, object := range list.Items { - deployment := api.Deployment{} + deployment := api.PmemCSIDeployment{} err := Scheme.Convert(&object, &deployment, nil) framework.ExpectNoError(err, "convert %v to PMEM-CSI deployment", object) del(deployment.ObjectMeta, deployment, func() error { @@ -923,13 +923,13 @@ func EnsureDeploymentNow(f *framework.Framework, deployment *Deployment) { // GetDriverDeployment returns the spec for the driver deployment that is used // for deployments like operator-lvm-production. -func (d *Deployment) GetDriverDeployment() api.Deployment { - return api.Deployment{ +func (d *Deployment) GetDriverDeployment() api.PmemCSIDeployment { + return api.PmemCSIDeployment{ // TypeMeta is needed because // DefaultUnstructuredConverter does not add it for us. Is there a better way? TypeMeta: metav1.TypeMeta{ APIVersion: api.SchemeGroupVersion.String(), - Kind: "Deployment", + Kind: "PmemCSIDeployment", }, ObjectMeta: metav1.ObjectMeta{ Name: "pmem-csi", diff --git a/test/e2e/deploy/operator.go b/test/e2e/deploy/operator.go index 8029aa7dad..66ec145e90 100644 --- a/test/e2e/deploy/operator.go +++ b/test/e2e/deploy/operator.go @@ -32,13 +32,13 @@ var ( AlphaDeploymentResource = schema.GroupVersionResource{ Group: alphaapi.SchemeGroupVersion.Group, Version: alphaapi.SchemeGroupVersion.Version, - Resource: "deployments", + Resource: "pmemcsideployments", } Scheme = runtime.NewScheme() ) func init() { - api.SchemeBuilder.Register(&api.Deployment{}, &api.DeploymentList{}) + api.SchemeBuilder.Register(&api.PmemCSIDeployment{}, &api.PmemCSIDeploymentList{}) err := apis.AddToScheme(Scheme) if err != nil { panic(err) @@ -59,11 +59,11 @@ func deploymentToUnstructured(in interface{}, gvk schema.GroupVersionKind) *unst return &out } -func DeploymentToUnstructured(in *api.Deployment) *unstructured.Unstructured { +func DeploymentToUnstructured(in *api.PmemCSIDeployment) *unstructured.Unstructured { return deploymentToUnstructured(in, schema.GroupVersionKind{ Group: api.SchemeGroupVersion.Group, Version: api.SchemeGroupVersion.Version, - Kind: "Deployment", + Kind: "PmemCSIDeployment", }) } @@ -80,11 +80,11 @@ func deploymentFromUnstructured(in *unstructured.Unstructured, out interface{}) framework.ExpectNoError(err, "convert from unstructured deployment") } -func DeploymentFromUnstructured(in *unstructured.Unstructured) *api.Deployment { +func DeploymentFromUnstructured(in *unstructured.Unstructured) *api.PmemCSIDeployment { if in == nil { return nil } - var out api.Deployment + var out api.PmemCSIDeployment deploymentFromUnstructured(in, &out) return &out } @@ -110,7 +110,7 @@ func createDeploymentCR(f *framework.Framework, dep *unstructured.Unstructured, return out } -func CreateDeploymentCR(f *framework.Framework, dep api.Deployment) api.Deployment { +func CreateDeploymentCR(f *framework.Framework, dep api.PmemCSIDeployment) api.PmemCSIDeployment { in := DeploymentToUnstructured(&dep) out := createDeploymentCR(f, in, DeploymentResource) framework.Logf("Created deployment %q = (%+v)", dep.Name, out) @@ -124,7 +124,7 @@ func CreateAlphaDeploymentCR(f *framework.Framework, dep alphaapi.Deployment) al return *AlphaDeploymentFromUnstructured(out) } -func EnsureDeploymentCR(f *framework.Framework, dep api.Deployment) api.Deployment { +func EnsureDeploymentCR(f *framework.Framework, dep api.PmemCSIDeployment) api.PmemCSIDeployment { var out *unstructured.Unstructured gomega.Eventually(func() error { existingDep, err := f.DynamicClient.Resource(DeploymentResource).Get(context.Background(), dep.Name, metav1.GetOptions{}) @@ -163,7 +163,7 @@ func DeleteDeploymentCR(f *framework.Framework, name string) { framework.Logf("Deleted deployment %q", name) } -func UpdateDeploymentCR(f *framework.Framework, dep api.Deployment) api.Deployment { +func UpdateDeploymentCR(f *framework.Framework, dep api.PmemCSIDeployment) api.PmemCSIDeployment { var out *unstructured.Unstructured gomega.Eventually(func() error { @@ -194,7 +194,7 @@ func getDeploymentCR(f *framework.Framework, name string, res schema.GroupVersio return out } -func GetDeploymentCR(f *framework.Framework, name string) api.Deployment { +func GetDeploymentCR(f *framework.Framework, name string) api.PmemCSIDeployment { out := getDeploymentCR(f, name, DeploymentResource) return *DeploymentFromUnstructured(out) } diff --git a/test/e2e/operator/deployment_api.go b/test/e2e/operator/deployment_api.go index af0810f126..3731cea1c0 100644 --- a/test/e2e/operator/deployment_api.go +++ b/test/e2e/operator/deployment_api.go @@ -51,8 +51,8 @@ import ( // because these tests do not actually need a running driver. const dummyImage = "unexisting/pmem-csi-driver" -func getDeployment(name string) api.Deployment { - return api.Deployment{ +func getDeployment(name string) api.PmemCSIDeployment { + return api.PmemCSIDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, @@ -134,7 +134,7 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { cancel() }) - validateDriver := func(deployment api.Deployment, what ...interface{}) { + validateDriver := func(deployment api.PmemCSIDeployment, what ...interface{}) { framework.Logf("waiting for expected driver deployment %s", deployment.Name) if what == nil { what = []interface{}{"validate driver"} @@ -163,7 +163,7 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { } } - validateEvents := func(dep *api.Deployment, expectedEvents []string, what ...interface{}) { + validateEvents := func(dep *api.PmemCSIDeployment, expectedEvents []string, what ...interface{}) { if what == nil { what = []interface{}{"validate events"} } @@ -200,7 +200,7 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { Context("deployment", func() { - tests := map[string]api.Deployment{ + tests := map[string]api.PmemCSIDeployment{ "with defaults": getDeployment("test-deployment-with-defaults"), "with explicit values": { ObjectMeta: metav1.ObjectMeta{ @@ -274,7 +274,7 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { // Run in-cluster kubectl from master node ssh := os.Getenv("REPO_ROOT") + "/_work/" + os.Getenv("CLUSTER") + "/ssh.0" - out, err := exec.RunCommand(ssh, "kubectl", "get", "deployments.pmem-csi.intel.com", "--no-headers") + out, err := exec.RunCommand(ssh, "kubectl", "get", "pmemcsideployments.pmem-csi.intel.com", "--no-headers") Expect(err).ShouldNot(HaveOccurred(), "kubectl get: %v", out) Expect(out).Should(MatchRegexp(`%s\s+%s\s+.*"?%s"?:"?%s"?.*\s+%s\s+%s\s+[0-9]+(s|m)`, d.Name, d.Spec.DeviceMode, lblKey, lblValue, d.Spec.Image, d.Status.Phase), "fields mismatch") @@ -572,7 +572,7 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { postSwitch := postSwitch It(name, func() { driverName := ctx + "-" + strings.Replace(name, " ", "-", -1) - deployment := api.Deployment{ + deployment := api.PmemCSIDeployment{ ObjectMeta: metav1.ObjectMeta{ Name: driverName, }, @@ -636,7 +636,7 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { testcase := testcase Context(testcase.Name, func() { testIt := func(restart bool) { - deployment := *testcase.Deployment.DeepCopyObject().(*api.Deployment) + deployment := *testcase.Deployment.DeepCopyObject().(*api.PmemCSIDeployment) // Use fake images to prevent pods from actually starting. deployment.Spec.Image = dummyImage @@ -687,65 +687,65 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { Context("recover", func() { Context("deleted sub-resources", func() { - tests := map[string]func(*api.Deployment) apiruntime.Object{ - "registry secret": func(dep *api.Deployment) apiruntime.Object { + tests := map[string]func(*api.PmemCSIDeployment) apiruntime.Object{ + "registry secret": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: dep.RegistrySecretName(), Namespace: d.Namespace, }, } }, - "node secret": func(dep *api.Deployment) apiruntime.Object { + "node secret": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{Name: dep.NodeSecretName(), Namespace: d.Namespace}, } }, - "service account": func(dep *api.Deployment) apiruntime.Object { + "service account": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &corev1.ServiceAccount{ ObjectMeta: metav1.ObjectMeta{Name: dep.ServiceAccountName(), Namespace: d.Namespace}, } }, - "controller service": func(dep *api.Deployment) apiruntime.Object { + "controller service": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &corev1.Service{ ObjectMeta: metav1.ObjectMeta{Name: dep.ControllerServiceName(), Namespace: d.Namespace}, } }, - "metrics service": func(dep *api.Deployment) apiruntime.Object { + "metrics service": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &corev1.Service{ ObjectMeta: metav1.ObjectMeta{Name: dep.MetricsServiceName(), Namespace: d.Namespace}, } }, - "provisioner role": func(dep *api.Deployment) apiruntime.Object { + "provisioner role": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &rbacv1.Role{ ObjectMeta: metav1.ObjectMeta{Name: dep.ProvisionerRoleName(), Namespace: d.Namespace}, } }, - "provisioner role binding": func(dep *api.Deployment) apiruntime.Object { + "provisioner role binding": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &rbacv1.RoleBinding{ ObjectMeta: metav1.ObjectMeta{Name: dep.ProvisionerRoleBindingName(), Namespace: d.Namespace}, } }, - "provisioner cluster role": func(dep *api.Deployment) apiruntime.Object { + "provisioner cluster role": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &rbacv1.ClusterRole{ ObjectMeta: metav1.ObjectMeta{Name: dep.ProvisionerClusterRoleName()}, } }, - "provisioner cluster role binding": func(dep *api.Deployment) apiruntime.Object { + "provisioner cluster role binding": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &rbacv1.ClusterRoleBinding{ ObjectMeta: metav1.ObjectMeta{Name: dep.ProvisionerClusterRoleBindingName()}, } }, - "csi driver": func(dep *api.Deployment) apiruntime.Object { + "csi driver": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &storagev1beta1.CSIDriver{ ObjectMeta: metav1.ObjectMeta{Name: dep.GetName()}, } }, - "controller driver": func(dep *api.Deployment) apiruntime.Object { + "controller driver": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &appsv1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{Name: dep.ControllerDriverName(), Namespace: d.Namespace}, } }, - "node driver": func(dep *api.Deployment) apiruntime.Object { + "node driver": func(dep *api.PmemCSIDeployment) apiruntime.Object { return &appsv1.DaemonSet{ ObjectMeta: metav1.ObjectMeta{Name: dep.NodeDriverName(), Namespace: d.Namespace}, } @@ -781,8 +781,8 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { }) Context("conflicting update", func() { - tests := map[string]func(dep *api.Deployment) apiruntime.Object{ - "controller": func(dep *api.Deployment) apiruntime.Object { + tests := map[string]func(dep *api.PmemCSIDeployment) apiruntime.Object{ + "controller": func(dep *api.PmemCSIDeployment) apiruntime.Object { obj := &appsv1.StatefulSet{} key := runtime.ObjectKey{Name: dep.ControllerDriverName(), Namespace: d.Namespace} EventuallyWithOffset(1, func() error { @@ -797,7 +797,7 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { } return obj }, - "node driver": func(dep *api.Deployment) apiruntime.Object { + "node driver": func(dep *api.PmemCSIDeployment) apiruntime.Object { obj := &appsv1.DaemonSet{} key := runtime.ObjectKey{Name: dep.NodeDriverName(), Namespace: d.Namespace} EventuallyWithOffset(1, func() error { @@ -812,7 +812,7 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { } return obj }, - "metrics service": func(dep *api.Deployment) apiruntime.Object { + "metrics service": func(dep *api.PmemCSIDeployment) apiruntime.Object { obj := &corev1.Service{} key := runtime.ObjectKey{Name: dep.MetricsServiceName(), Namespace: d.Namespace} EventuallyWithOffset(1, func() error { @@ -828,7 +828,7 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { } return obj }, - "controller service": func(dep *api.Deployment) apiruntime.Object { + "controller service": func(dep *api.PmemCSIDeployment) apiruntime.Object { obj := &corev1.Service{} key := runtime.ObjectKey{Name: dep.ControllerServiceName(), Namespace: d.Namespace} EventuallyWithOffset(1, func() error { @@ -874,18 +874,22 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool { "v1alpha1": deploy.AlphaDeploymentResource, "v1beta1": deploy.DeploymentResource, } - for name, gvr := range versions { + for version, gvr := range versions { gvr := gvr - Context(name, func() { + Context(version, func() { toUnstructured := func(in interface{}) *unstructured.Unstructured { var out unstructured.Unstructured err := deploy.Scheme.Convert(in, &out, nil) framework.ExpectNoError(err, "convert to unstructured deployment") - out.SetGroupVersionKind(schema.GroupVersionKind{ + gvk := schema.GroupVersionKind{ Group: gvr.Group, Version: gvr.Version, Kind: "Deployment", - }) + } + if version == "v1beta1" { + gvk.Kind = "PmemCSIDeployment" + } + out.SetGroupVersionKind(gvk) return &out } @@ -1170,7 +1174,7 @@ func startOperator(c *deploy.Cluster, d *deploy.Deployment) { framework.Logf("Operator is restored!") } -func switchDeploymentMode(c *deploy.Cluster, f *framework.Framework, depName, ns string, mode api.DeviceMode) api.Deployment { +func switchDeploymentMode(c *deploy.Cluster, f *framework.Framework, depName, ns string, mode api.DeviceMode) api.PmemCSIDeployment { podNames := []string{} for i := 1; i < c.NumNodes(); i++ { diff --git a/test/e2e/operator/validate/validate.go b/test/e2e/operator/validate/validate.go index dfeecd46c9..14801cdaa2 100644 --- a/test/e2e/operator/validate/validate.go +++ b/test/e2e/operator/validate/validate.go @@ -36,7 +36,7 @@ import ( // objects for a certain deployment spec. deploymentSpec should only have those fields // set which are not the defaults. This call will wait for the expected objects until // the context times out. -func DriverDeploymentEventually(ctx context.Context, client client.Client, k8sver version.Version, namespace string, deployment api.Deployment, initialCreation bool) error { +func DriverDeploymentEventually(ctx context.Context, client client.Client, k8sver version.Version, namespace string, deployment api.PmemCSIDeployment, initialCreation bool) error { ticker := time.NewTicker(1 * time.Second) defer ticker.Stop() @@ -106,7 +106,7 @@ func DriverDeploymentEventually(ctx context.Context, client client.Client, k8sve // // A final error is returned when observing a problem that is not going to go away, // like an unexpected update of an object. -func DriverDeployment(client client.Client, k8sver version.Version, namespace string, deployment api.Deployment, resourceVersions map[string]string) (final bool, finalErr error) { +func DriverDeployment(client client.Client, k8sver version.Version, namespace string, deployment api.PmemCSIDeployment, resourceVersions map[string]string) (final bool, finalErr error) { if deployment.GetUID() == "" { return true, errors.New("deployment not an object that was stored in the API server, no UID") } @@ -495,7 +495,7 @@ func prettyPrintObjectID(object unstructured.Unstructured) string { object.GetNamespace()) } -func listAllDeployedObjects(c client.Client, deployment api.Deployment, namespace string) ([]unstructured.Unstructured, error) { +func listAllDeployedObjects(c client.Client, deployment api.PmemCSIDeployment, namespace string) ([]unstructured.Unstructured, error) { objects := []unstructured.Unstructured{} for _, list := range operatordeployment.AllObjectLists() { diff --git a/test/start-operator.sh b/test/start-operator.sh index 17f44641dc..14c54351ee 100755 --- a/test/start-operator.sh +++ b/test/start-operator.sh @@ -75,8 +75,14 @@ function deploy_using_olm() { } function deploy_using_yaml() { + # v1alpha1 Deployment CRD crd=${REPO_DIRECTORY}/deploy/crd/pmem-csi.intel.com_deployments_webhook.yaml echo "Deploying '${crd}'..." + cat ${crd} | ${SSH} kubectl apply -f - + + # v1beta1 PmemCSIDeploymentCRD with conversion webhook configuration + crd=${REPO_DIRECTORY}/deploy/crd/pmem-csi.intel.com_pmemcsideployments_webhook.yaml + echo "Deploying '${crd}'..." sed -e "s;\(namespace: \)pmem-csi$;\1${TEST_OPERATOR_NAMESPACE};g" \ -e "s;\(cert-manager.io/inject-ca-from: \)pmem-csi;\1${TEST_OPERATOR_NAMESPACE};g" ${crd} | ${SSH} kubectl apply -f - @@ -144,5 +150,5 @@ esac cat <&1 | grep -v NotFound || true echo "Deleting CRD..." - ${KUBECTL} delete crd deployments.pmem-csi.intel.com + ${KUBECTL} delete crd/deployments.pmem-csi.intel.com crd/pmemcsideployments.pmem-csi.intel.com } deploy_method=yaml