Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logrotate: add design and api for logrotate #37

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 38 additions & 5 deletions api/v1alpha1/driver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,35 @@ 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
LogRotation *LogRotationSpec `json:"logRotation,omitempty"`
}

type PeriodicityType string

const (
HourlyPeriod PeriodicityType = "hourly"
DailyPeriod PeriodicityType = "daily"
WeeklyPeriod PeriodicityType = "weekly"
MonthlyPeriod PeriodicityType = "monthly"
)

type LogRotationSpec 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 PeriodicityType `json:"periodicity,omitempty"`
// LogHostPath is the prefix directory path for the csi log files
// +optional
LogHostPath string `json:"logHostPath,omitempty"`
nb-ohad marked this conversation as resolved.
Show resolved Hide resolved
}

type SnapshotPolicyType string
Expand Down Expand Up @@ -72,9 +98,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 +135,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 +147,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 controller plugin to run privileged,
// For example, OpenShift with SELinux restrictions requires the pod to be privileged to write to hostPath.
Privileged bool `json:"privileged,omitempty"`
nb-ohad marked this conversation as resolved.
Show resolved Hide resolved
}

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 controller plugin 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
logRotation:
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