Skip to content

Commit

Permalink
logrotate: add logrotate functionality for csi
Browse files Browse the repository at this point in the history
1) Make main container and csi addons container
   log to a file(dependency on klog)

2) Add a log-rotate sidecar container,
   so it can rotate the logs

3) Added other volume and volumemounts as needed

4) Added the privileged option for controllerplugin

5) Add resources to the logrotate container

6) make the api change in the merge function

Signed-off-by: parth-gr <partharora1010@gmail.com>
  • Loading branch information
parth-gr committed Aug 16, 2024
1 parent 6612ef4 commit 6e1a6a9
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 15 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/driver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ const (
MonthlyPeriod PeriodicityType = "monthly"
)

// +kubebuilder:validation:XValidation:message="Either maxLogSize or periodicity must be set",rule="(has(self.maxLogSize)) || (has(self.periodicity))"
type LogRotationSpec struct {
// MaxFiles is the number of logrtoate files
// Default to 7
//+kubebuilder:validation:Optional
MaxFiles int `json:"maxFiles,omitempty"`

Expand All @@ -48,6 +50,7 @@ type LogRotationSpec struct {
Periodicity PeriodicityType `json:"periodicity,omitempty"`

// LogHostPath is the prefix directory path for the csi log files
// Default to /var/lib/cephcsi
//+kubebuilder:validation:Optional
LogHostPath string `json:"logHostPath,omitempty"`
}
Expand Down
12 changes: 9 additions & 3 deletions config/crd/bases/csi.ceph.io_drivers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3542,11 +3542,14 @@ spec:
description: log rotation for csi pods
properties:
logHostPath:
description: LogHostPath is the prefix directory path for
the csi log files
description: |-
LogHostPath is the prefix directory path for the csi log files
Default to /var/lib/cephcsi
type: string
maxFiles:
description: MaxFiles is the number of logrtoate files
description: |-
MaxFiles is the number of logrtoate files
Default to 7
type: integer
maxLogSize:
anyOf:
Expand All @@ -3565,6 +3568,9 @@ spec:
- monthly
type: string
type: object
x-kubernetes-validations:
- message: Either maxLogSize or periodicity must be set
rule: (has(self.maxLogSize)) || (has(self.periodicity))
verbosity:
description: |-
Log verbosity level for driver pods,
Expand Down
12 changes: 9 additions & 3 deletions config/crd/bases/csi.ceph.io_operatorconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3581,11 +3581,14 @@ spec:
description: log rotation for csi pods
properties:
logHostPath:
description: LogHostPath is the prefix directory path
for the csi log files
description: |-
LogHostPath is the prefix directory path for the csi log files
Default to /var/lib/cephcsi
type: string
maxFiles:
description: MaxFiles is the number of logrtoate files
description: |-
MaxFiles is the number of logrtoate files
Default to 7
type: integer
maxLogSize:
anyOf:
Expand All @@ -3605,6 +3608,9 @@ spec:
- monthly
type: string
type: object
x-kubernetes-validations:
- message: Either maxLogSize or periodicity must be set
rule: (has(self.maxLogSize)) || (has(self.periodicity))
verbosity:
description: |-
Log verbosity level for driver pods,
Expand Down
6 changes: 4 additions & 2 deletions internal/controller/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ var imageDefaults = map[string]string{
}

const (
defaultGRrpcTimeout = 150
defaultKubeletDirPath = "/var/lib/kubelet"
defaultGRrpcTimeout = 150
defaultKubeletDirPath = "/var/lib/kubelet"
defaultLogHostPath = "/var/lib/cephcsi"
defaultLogRotateMaxFiles = 7
)

var defaultLeaderElection = csiv1a1.LeaderElectionSpec{
Expand Down
Loading

0 comments on commit 6e1a6a9

Please sign in to comment.