Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #832 from pohly/operator-fixes
Browse files Browse the repository at this point in the history
even more operator fixes
  • Loading branch information
pohly authored Dec 17, 2020
2 parents 3d8385f + 95e00fc commit 955281d
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 106 deletions.
38 changes: 26 additions & 12 deletions deploy/crd/pmem-csi.intel.com_deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ spec:
type: object
type: object
deviceMode:
description: DeviceMode to use to manage PMEM devices. One of lvm,
direct
description: DeviceMode to use to manage PMEM devices.
enum:
- lvm
- direct
type: string
image:
description: PMEM-CSI driver container image
Expand All @@ -106,7 +108,7 @@ spec:
by the operator.
type: object
logLevel:
description: LogLevel number for the log verbosity kubebuilder:default=3
description: LogLevel number for the log verbosity
type: integer
nodeControllerCert:
description: NodeControllerCert encoded certificate signed by a CA
Expand Down Expand Up @@ -158,9 +160,11 @@ spec:
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
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
Expand All @@ -187,6 +191,7 @@ spec:
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
Expand All @@ -213,6 +218,7 @@ spec:
lastUpdated:
description: LastUpdated time of the driver status
format: date-time
nullable: true
type: string
reason:
description: Reason represents the human readable text that
Expand All @@ -233,6 +239,7 @@ spec:
lastUpdated:
description: LastUpdated time of the deployment status
format: date-time
nullable: true
type: string
phase:
description: Phase indicates the state of the deployment
Expand Down Expand Up @@ -315,8 +322,10 @@ spec:
type: object
type: object
deviceMode:
description: DeviceMode to use to manage PMEM devices. One of lvm,
direct
description: DeviceMode to use to manage PMEM devices.
enum:
- lvm
- direct
type: string
image:
description: PMEM-CSI driver container image
Expand All @@ -334,7 +343,7 @@ spec:
by the operator.
type: object
logLevel:
description: LogLevel number for the log verbosity kubebuilder:default=3
description: LogLevel number for the log verbosity
type: integer
nodeControllerCert:
description: NodeControllerCert encoded certificate signed by a CA
Expand Down Expand Up @@ -414,9 +423,11 @@ spec:
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
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
Expand Down Expand Up @@ -470,6 +481,7 @@ spec:
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
Expand All @@ -496,6 +508,7 @@ spec:
lastUpdated:
description: LastUpdated time of the driver status
format: date-time
nullable: true
type: string
reason:
description: Reason represents the human readable text that
Expand All @@ -516,6 +529,7 @@ spec:
lastUpdated:
description: LastUpdated time of the deployment status
format: date-time
nullable: true
type: string
phase:
description: Phase indicates the state of the deployment
Expand Down
28 changes: 22 additions & 6 deletions deploy/crd/pmem-csi.intel.com_deployments_webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ spec:
type: object
type: object
deviceMode:
description: DeviceMode to use to manage PMEM devices. One of lvm, direct
description: DeviceMode to use to manage PMEM devices.
enum:
- lvm
- direct
type: string
image:
description: PMEM-CSI driver container image
Expand All @@ -104,7 +107,7 @@ spec:
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
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
Expand Down Expand Up @@ -145,7 +148,9 @@ spec:
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
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
Expand All @@ -169,6 +174,7 @@ spec:
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
Expand All @@ -193,6 +199,7 @@ spec:
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.
Expand All @@ -209,6 +216,7 @@ spec:
lastUpdated:
description: LastUpdated time of the deployment status
format: date-time
nullable: true
type: string
phase:
description: Phase indicates the state of the deployment
Expand Down Expand Up @@ -280,7 +288,10 @@ spec:
type: object
type: object
deviceMode:
description: DeviceMode to use to manage PMEM devices. One of lvm, direct
description: DeviceMode to use to manage PMEM devices.
enum:
- lvm
- direct
type: string
image:
description: PMEM-CSI driver container image
Expand All @@ -297,7 +308,7 @@ spec:
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
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
Expand Down Expand Up @@ -360,7 +371,9 @@ spec:
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
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
Expand Down Expand Up @@ -406,6 +419,7 @@ spec:
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
Expand All @@ -430,6 +444,7 @@ spec:
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.
Expand All @@ -446,6 +461,7 @@ spec:
lastUpdated:
description: LastUpdated time of the deployment status
format: date-time
nullable: true
type: string
phase:
description: Phase indicates the state of the deployment
Expand Down
4 changes: 4 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,10 @@ The current API for PMEM-CSI `Deployment` resources is:

Below specification fields are valid in all API versions unless noted otherwise in the description.

The default values are used by the operator when no value is set for a
field explicitly. Those defaults can change over time and are not part
of the API specification.

|Field | Type | Description | Default Value |
|---|---|---|---|
| image | string | PMEM-CSI docker image name used for the deployment | the same image as the operator<sup>1</sup> |
Expand Down
22 changes: 17 additions & 5 deletions pkg/apis/pmemcsi/v1alpha1/deployment_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,21 @@ func (d *Deployment) ConvertTo(dst conversion.Hub) error {

// no change in other fields
out.ObjectMeta = in.ObjectMeta
out.Spec.LogLevel = in.Spec.LogLevel
out.Spec.Image = in.Spec.Image
out.Spec.CACert = in.Spec.CACert
out.Spec.PullPolicy = in.Spec.PullPolicy
out.Spec.ProvisionerImage = in.Spec.ProvisionerImage
out.Spec.NodeRegistrarImage = in.Spec.NodeRegistrarImage
out.Spec.DeviceMode = v1beta1.DeviceMode(string(in.Spec.DeviceMode))
out.Spec.LogLevel = in.Spec.LogLevel
out.Spec.RegistryCert = in.Spec.RegistryCert
out.Spec.RegistryPrivateKey = in.Spec.RegistryPrivateKey
out.Spec.NodeControllerCert = in.Spec.NodeControllerCert
out.Spec.NodeControllerPrivateKey = in.Spec.NodeControllerPrivateKey
out.Spec.CACert = in.Spec.CACert
out.Spec.NodeSelector = in.Spec.NodeSelector
out.Spec.PMEMPercentage = in.Spec.PMEMPercentage
out.Spec.Labels = in.Spec.Labels
out.Spec.KubeletDir = in.Spec.KubeletDir

out.Status.Components = nil
for _, s := range in.Status.Components {
Expand All @@ -71,7 +77,7 @@ func (d *Deployment) ConvertTo(dst conversion.Hub) error {

// +kubebuilder:docs-gen:collapse=rote conversion

klog.Infof("Coverted Object: %+v", *out)
klog.Infof("Converted Object: %+v", *out)

return nil
}
Expand All @@ -88,15 +94,21 @@ func (d *Deployment) ConvertFrom(src conversion.Hub) error {

// no change in other fields
out.ObjectMeta = in.ObjectMeta
out.Spec.LogLevel = in.Spec.LogLevel
out.Spec.Image = in.Spec.Image
out.Spec.CACert = in.Spec.CACert
out.Spec.PullPolicy = in.Spec.PullPolicy
out.Spec.ProvisionerImage = in.Spec.ProvisionerImage
out.Spec.NodeRegistrarImage = in.Spec.NodeRegistrarImage
out.Spec.DeviceMode = DeviceMode(string(in.Spec.DeviceMode))
out.Spec.LogLevel = in.Spec.LogLevel
out.Spec.RegistryCert = in.Spec.RegistryCert
out.Spec.RegistryPrivateKey = in.Spec.RegistryPrivateKey
out.Spec.NodeControllerCert = in.Spec.NodeControllerCert
out.Spec.NodeControllerPrivateKey = in.Spec.NodeControllerPrivateKey
out.Spec.CACert = in.Spec.CACert
out.Spec.NodeSelector = in.Spec.NodeSelector
out.Spec.PMEMPercentage = in.Spec.PMEMPercentage
out.Spec.Labels = in.Spec.Labels
out.Spec.KubeletDir = in.Spec.KubeletDir

out.Status.Components = nil
for _, s := range in.Status.Components {
Expand Down
28 changes: 9 additions & 19 deletions pkg/apis/pmemcsi/v1alpha1/deployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ const (
DeviceModeFake DeviceMode = "fake"
)

// NOTE(avalluri): Due to below errors we stop setting
// few CRD schema fields by prefixing those lines a '-'.
// Once the below issues go fixed replace those '-' with '+'
// Setting default(+kubebuilder:default=value) for v1beta1 CRD fails, only supports since v1 CRD.
// Related issue : https://github.com/kubernetes-sigs/controller-tools/issues/478
// Fails setting min/max for integers: https://github.com/helm/helm/issues/5806

// +k8s:deepcopy-gen=true
// DeploymentSpec defines the desired state of Deployment
type DeploymentSpec struct {
Expand All @@ -74,12 +67,10 @@ type DeploymentSpec struct {
ControllerResources *corev1.ResourceRequirements `json:"controllerResources,omitempty"`
// NodeResources Compute resources required by Node driver
NodeResources *corev1.ResourceRequirements `json:"nodeResources,omitempty"`
// DeviceMode to use to manage PMEM devices. One of lvm, direct
// +kubebuilder:default:lvm
// DeviceMode to use to manage PMEM devices.
// +kubebuilder:validation:Enum=lvm;direct
DeviceMode DeviceMode `json:"deviceMode,omitempty"`
// LogLevel number for the log verbosity
// +kubebuilder:validation:Required
// kubebuilder:default=3
LogLevel uint16 `json:"logLevel,omitempty"`
// RegistryCert encoded certificate signed by a CA for registry server authentication
// If not provided, provisioned one by the operator using self-signed CA
Expand All @@ -99,12 +90,10 @@ type DeploymentSpec struct {
// NodeSelector node labels to use for selection of driver node
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// PMEMPercentage represents the percentage of space to be used by the driver in each PMEM region
// on every node.
// on every node. Unset (= zero) selects the default of 100%.
// This is only valid for driver in LVM mode.
// +kubebuilder:validation:Required
// -kubebuilder:validation:Minimum=1
// -kubebuilder:validation:Maximum=100
// -kubebuilder:default=100
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=100
PMEMPercentage uint16 `json:"pmemPercentage,omitempty"`
// Labels contains additional labels for all objects created by the operator.
Labels map[string]string `json:"labels,omitempty"`
Expand Down Expand Up @@ -133,10 +122,9 @@ type DeploymentCondition struct {
// Status of the condition, one of True, False, Unknown.
Status corev1.ConditionStatus `json:"status"`
// Message human readable text that explain why this condition is in this state
// +optional
Reason string `json:"reason,omitempty"`
// Last time the condition was probed.
// +optional
// +nullable
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
}

Expand Down Expand Up @@ -169,6 +157,7 @@ type DriverStatus struct {
// driver is in this state.
Reason string `json:"reason"`
// LastUpdated time of the driver status
// +nullable
LastUpdated metav1.Time `json:"lastUpdated,omitempty"`
}

Expand All @@ -186,6 +175,7 @@ type DeploymentStatus struct {
Conditions []DeploymentCondition `json:"conditions,omitempty"`
Components []DriverStatus `json:"driverComponents,omitempty"`
// LastUpdated time of the deployment status
// +nullable
LastUpdated metav1.Time `json:"lastUpdated,omitempty"`
}

Expand Down Expand Up @@ -231,7 +221,7 @@ const (

const (
// DefaultLogLevel default logging level used for the driver
DefaultLogLevel = uint16(5)
DefaultLogLevel = uint16(3)
// DefaultImagePullPolicy default image pull policy for all the images used by the deployment
DefaultImagePullPolicy = corev1.PullIfNotPresent

Expand Down
Loading

0 comments on commit 955281d

Please sign in to comment.