Skip to content

Commit

Permalink
logrotate: add design and api for logrotate
Browse files Browse the repository at this point in the history
design and api for the csi pods logrotate

Signed-off-by: parth-gr <[email protected]>
  • Loading branch information
parth-gr committed Jul 16, 2024
1 parent 9812beb commit 01f2d51
Show file tree
Hide file tree
Showing 6 changed files with 433 additions and 25 deletions.
34 changes: 29 additions & 5 deletions api/v1alpha1/driver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,26 @@ type LogSpec struct {
// Log level for driver pods,
// Supported values from 0 to 5. 0 for general useful logs (the default), 5 for trace level verbosity.
// Default to 0
LogLevel int `json:"logLevel,omitempty"`
MaxFiles int `json:"maxFiles,omitempty"`
LogLevel int `json:"logLevel,omitempty"`
// log rotation for csi pods
// +optional
LogRotator *LogRotator `json:"logRotator,omitempty"`
}

type LogRotator struct {
// MaxFiles is the number of logrtoate files
// +optional
MaxFiles int `json:"maxFiles,omitempty"`
// MaxLogSize is the maximum size of the log file per csi pods
// +optional
MaxLogSize resource.Quantity `json:"maxLogSize,omitempty"`
// Periodicity is the periodicity of the log rotation.
// +kubebuilder:validation:Enum=hourly;daily;weekly;monthly
// +optional
Periodicity string `json:"periodicity,omitempty"`
// LogHostPath is the prefix directory path for the csi log files
// +optional
LogHostPath string `json:"logHostPath,omitempty"`
}

type SnapshotPolicyType string
Expand Down Expand Up @@ -72,9 +89,10 @@ type PodCommonSpec struct {
}

type NodePluginResourcesSpec struct {
Registrar *corev1.ResourceRequirements `json:"registrar,omitempty"`
Liveness *corev1.ResourceRequirements `json:"liveness,omitempty"`
Plugin *corev1.ResourceRequirements `json:"plugin,omitempty"`
Registrar *corev1.ResourceRequirements `json:"registrar,omitempty"`
Liveness *corev1.ResourceRequirements `json:"liveness,omitempty"`
Plugin *corev1.ResourceRequirements `json:"plugin,omitempty"`
LogRotator *corev1.ResourceRequirements `json:"logRotator,omitempty"`
}

type NodePluginSpec struct {
Expand Down Expand Up @@ -108,6 +126,7 @@ type ControllerPluginResourcesSpec struct {
OMapGenerator *corev1.ResourceRequirements `json:"omapGenerator,omitempty"`
Liveness *corev1.ResourceRequirements `json:"liveness,omitempty"`
Plugin *corev1.ResourceRequirements `json:"plugin,omitempty"`
LogRotator *corev1.ResourceRequirements `json:"logRotator,omitempty"`
}

type ControllerPluginSpec struct {
Expand All @@ -119,6 +138,11 @@ type ControllerPluginSpec struct {

// Resource requirements for controller plugin's containers
Resources ControllerPluginResourcesSpec `json:"resources,omitempty"`

// To enable logrotation for csi pods,
// Some platforms require provisioner pods to run privileged,
// For example, OpenShift with SELinux restrictions requires the pod to be privileged to write to hostPath.
Privileged bool `json:"privileged,omitempty"`
}

type LivenessSpec struct {
Expand Down
32 changes: 31 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

153 changes: 145 additions & 8 deletions config/crd/bases/csi.ceph.io_drivers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,12 @@ spec:
type: object
type: array
type: object
privileged:
description: |-
To enable logrotation for csi pods,
Some platforms require provisioner pods to run privileged,
For example, OpenShift with SELinux restrictions requires the pod to be privileged to write to hostPath.
type: boolean
replicas:
description: Set replicas for controller plugin's deployment.
Defaults to 2
Expand Down Expand Up @@ -1096,6 +1102,62 @@ spec:
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: |-
Name must match the name of one entry in pod.spec.resourceClaims of
the Pod where this field is used. It makes that resource available
inside a container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
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-resources-containers/
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. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
logRotator:
description: ResourceRequirements describes the compute resource
requirements.
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.
This is an alpha field and requires enabling the
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
Expand Down Expand Up @@ -1528,14 +1590,33 @@ spec:
Supported values from 0 to 5. 0 for general useful logs (the default), 5 for trace level verbosity.
Default to 0
type: integer
maxFiles:
type: integer
maxLogSize:
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
logRotator:
description: log rotation for csi pods
properties:
logHostPath:
description: LogHostPath is the prefix directory path for
the csi log files
type: string
maxFiles:
description: MaxFiles is the number of logrtoate files
type: integer
maxLogSize:
anyOf:
- type: integer
- type: string
description: MaxLogSize is the maximum size of the log file
per csi pods
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
periodicity:
description: Periodicity is the periodicity of the log rotation.
enum:
- hourly
- daily
- weekly
- monthly
type: string
type: object
type: object
nodePlugin:
description: Driver's plugin configuration
Expand Down Expand Up @@ -2523,6 +2604,62 @@ spec:
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: |-
Name must match the name of one entry in pod.spec.resourceClaims of
the Pod where this field is used. It makes that resource available
inside a container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
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-resources-containers/
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. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
logRotator:
description: ResourceRequirements describes the compute resource
requirements.
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.
This is an alpha field and requires enabling the
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
Expand Down
Loading

0 comments on commit 01f2d51

Please sign in to comment.