diff --git a/api/v1beta1/grafana.go b/api/v1beta1/grafana.go index b531196..217685f 100644 --- a/api/v1beta1/grafana.go +++ b/api/v1beta1/grafana.go @@ -5,6 +5,7 @@ type Grafana struct { Admin *Admin `json:"admin,omitempty"` Datasources []*Datasource `json:"datasources,omitempty"` DashboardProviders []*Provider `json:"dashboardproviders,omitempty"` + Storage *StorageSpec `json:"storage,omitempty"` } type Admin struct { ExistingSecret string `json:"existingSecret,omitempty" yaml:"existingSecret,omitempty"` diff --git a/api/v1beta1/logging-operator.go b/api/v1beta1/logging-operator.go index bca2029..28a690e 100644 --- a/api/v1beta1/logging-operator.go +++ b/api/v1beta1/logging-operator.go @@ -1,5 +1,6 @@ package v1beta1 type LoggingOperator struct { - Deploy bool `json:"deploy,omitempty"` + Deploy bool `json:"deploy,omitempty"` + FluentdPVC *StorageSpec `json:"fluentdStorage,omitempty" yaml:"fluentdStorage,omitempty"` } diff --git a/internal/bundle/application/applications/grafana/helm.go b/internal/bundle/application/applications/grafana/helm.go index 7bf2059..8755bde 100644 --- a/internal/bundle/application/applications/grafana/helm.go +++ b/internal/bundle/application/applications/grafana/helm.go @@ -84,6 +84,15 @@ func (g *Grafana) SpecToHelmValues(toolset *toolsetsv1beta1.ToolsetSpec) interfa values.Grafana.Admin.UserKey = toolset.Grafana.Admin.UserKey values.Grafana.Admin.PasswordKey = toolset.Grafana.Admin.PasswordKey } + if toolset.Grafana.Storage != nil { + values.Grafana.Persistence.Enabled = true + values.Grafana.Persistence.Size = toolset.Grafana.Storage.Size + values.Grafana.Persistence.StorageClassName = toolset.Grafana.Storage.StorageClass + + if toolset.Grafana.Storage.AccessModes != nil { + values.Grafana.Persistence.AccessModes = toolset.Grafana.Storage.AccessModes + } + } return values } diff --git a/internal/bundle/application/applications/grafana/helm/default.go b/internal/bundle/application/applications/grafana/helm/default.go index f6aab85..475f0a5 100644 --- a/internal/bundle/application/applications/grafana/helm/default.go +++ b/internal/bundle/application/applications/grafana/helm/default.go @@ -2,6 +2,8 @@ package helm import prometheusoperator "github.com/caos/boom/internal/bundle/application/applications/prometheusoperator/helm" +import "github.com/caos/boom/internal/bundle/application/applications/grafanastandalone" + func DefaultValues(imageTags map[string]string) *Values { grafana := &GrafanaValues{ FullnameOverride: "grafana", @@ -24,6 +26,18 @@ func DefaultValues(imageTags map[string]string) *Values { ServiceMonitor: &ServiceMonitor{ SelfMonitor: false, }, + Persistence: &Persistence{ + Type: "pvc", + Enabled: false, + AccessModes: []string{"ReadWriteOnce"}, + Size: "10Gi", + Finalizers: []string{"kubernetes.io/pvc-protection"}, + }, + TestFramework: &grafanastandalone.TestFramework{ + Enabled: false, + Image: "dduportal/bats", + Tag: imageTags["dduportal/bats"], + }, Plugins: []string{"grafana-piechart-panel"}, } diff --git a/internal/bundle/application/applications/grafana/helm/values.go b/internal/bundle/application/applications/grafana/helm/values.go index 730ecbd..a2a5553 100644 --- a/internal/bundle/application/applications/grafana/helm/values.go +++ b/internal/bundle/application/applications/grafana/helm/values.go @@ -61,20 +61,31 @@ type Admin struct { PasswordKey string `yaml:"passwordKey"` } +type Persistence struct { + Type string `yaml:"type"` + Enabled bool `yaml:"enabled"` + AccessModes []string `yaml:"accessModes"` + Size string `yaml:"size"` + StorageClassName string `yaml:"storageClassName"` + Finalizers []string `yaml:"finalizers"` +} + type GrafanaValues struct { - FullnameOverride string `yaml:"fullnameOverride,omitempty"` - Enabled bool `yaml:"enabled"` - DefaultDashboardsEnabled bool `yaml:"defaultDashboardsEnabled"` - AdminPassword string `yaml:"adminPassword"` - Admin *Admin `yaml:"admin"` - Ingress *Ingress `yaml:"ingress"` - Sidecar *Sidecar `yaml:"sidecar"` - ExtraConfigmapMounts []interface{} `yaml:"extraConfigmapMounts"` - AdditionalDataSources []*grafanastandalone.Datasource `yaml:"additionalDataSources"` - ServiceMonitor *ServiceMonitor `yaml:"serviceMonitor"` - DashboardProviders *DashboardProviders `yaml:"dashboardProviders,omitempty"` - DashboardsConfigMaps map[string]string `yaml:"dashboardsConfigMaps,omitempty"` - Plugins []string `yaml:"plugins,omitempty"` + FullnameOverride string `yaml:"fullnameOverride,omitempty"` + Enabled bool `yaml:"enabled"` + DefaultDashboardsEnabled bool `yaml:"defaultDashboardsEnabled"` + AdminPassword string `yaml:"adminPassword"` + Admin *Admin `yaml:"admin"` + Ingress *Ingress `yaml:"ingress"` + Sidecar *Sidecar `yaml:"sidecar"` + ExtraConfigmapMounts []interface{} `yaml:"extraConfigmapMounts"` + AdditionalDataSources []*grafanastandalone.Datasource `yaml:"additionalDataSources"` + ServiceMonitor *ServiceMonitor `yaml:"serviceMonitor"` + DashboardProviders *DashboardProviders `yaml:"dashboardProviders,omitempty"` + DashboardsConfigMaps map[string]string `yaml:"dashboardsConfigMaps,omitempty"` + Persistence *Persistence `yaml:"persistence,omitempty"` + TestFramework *grafanastandalone.TestFramework `yaml:"testFramework,omitempty"` + Plugins []string `yaml:"plugins,omitempty"` } type Rules struct { diff --git a/internal/bundle/application/applications/loggingoperator/logging/logging.go b/internal/bundle/application/applications/loggingoperator/logging/logging.go index ef820d9..574fd4a 100644 --- a/internal/bundle/application/applications/loggingoperator/logging/logging.go +++ b/internal/bundle/application/applications/loggingoperator/logging/logging.go @@ -1,9 +1,18 @@ package logging +type Storage struct { + StorageClassName string + AccessModes []string + Storage string +} + type Config struct { Name string Namespace string ControlNamespace string + Replicas int + FluentdPVC *Storage + FluentbitPVC *Storage } type Requests struct { Storage string `yaml:"storage,omitempty"` @@ -11,15 +20,26 @@ type Requests struct { type Resources struct { Requests *Requests `yaml:"requests,omitempty"` } -type FluentdPvcSpec struct { +type PvcSpec struct { AccessModes []string `yaml:"accessModes,omitempty"` Resources *Resources `yaml:"resources,omitempty"` StorageClassName string `yaml:"storageClassName,omitempty"` } +type Pvc struct { + PvcSpec *PvcSpec `yaml:"spec,omitempty"` +} +type KubernetesStorage struct { + Pvc *Pvc `yaml:"pvc,omitempty"` +} +type Scaling struct { + Replicas int `yaml:"replicas"` +} type Fluentd struct { - Metrics *Metrics `yaml:"metrics,omitempty"` - FluentdPvcSpec *FluentdPvcSpec `yaml:"fluentdPvcSpec,omitempty"` - LogLevel string `yaml:"logLevel,omitempty"` + Metrics *Metrics `yaml:"metrics,omitempty"` + BufferStorageVolume *KubernetesStorage `yaml:"bufferStorageVolume,omitempty"` + LogLevel string `yaml:"logLevel,omitempty"` + DisablePvc bool `yaml:"disablePvc"` + Scaling *Scaling `yaml:"scaling,omitempty"` } type Metrics struct { Port int `yaml:"port"` @@ -35,14 +55,17 @@ type Image struct { } type Fluentbit struct { - Metrics *Metrics `yaml:"metrics,omitempty"` - FilterKubernetes *FilterKubernetes `yaml:"filterKubernetes,omitempty"` - Image *Image `yaml:"image,omitempty"` + Metrics *Metrics `yaml:"metrics,omitempty"` + FilterKubernetes *FilterKubernetes `yaml:"filterKubernetes,omitempty"` + Image *Image `yaml:"image,omitempty"` + BufferStorageVolume *KubernetesStorage `yaml:"bufferStorageVolume,omitempty"` } type Spec struct { - Fluentd *Fluentd `yaml:"fluentd"` - Fluentbit *Fluentbit `yaml:"fluentbit"` - ControlNamespace string `yaml:"controlNamespace"` + Fluentd *Fluentd `yaml:"fluentd"` + Fluentbit *Fluentbit `yaml:"fluentbit"` + ControlNamespace string `yaml:"controlNamespace"` + EnableRecreateWorkloadOnImmutableFieldChange bool `yaml:"enableRecreateWorkloadOnImmutableFieldChange"` + FlowConfigCheckDisabled bool `yaml:"flowConfigCheckDisabled"` } type Metadata struct { Name string `yaml:"name"` @@ -56,7 +79,7 @@ type Logging struct { } func New(conf *Config) *Logging { - return &Logging{ + values := &Logging{ APIVersion: "logging.banzaicloud.io/v1beta1", Kind: "Logging", Metadata: &Metadata{ @@ -64,11 +87,14 @@ func New(conf *Config) *Logging { Namespace: conf.Namespace, }, Spec: &Spec{ - ControlNamespace: conf.ControlNamespace, + FlowConfigCheckDisabled: true, + EnableRecreateWorkloadOnImmutableFieldChange: true, + ControlNamespace: conf.ControlNamespace, Fluentd: &Fluentd{ Metrics: &Metrics{ Port: 8080, }, + DisablePvc: true, }, Fluentbit: &Fluentbit{ Metrics: &Metrics{ @@ -82,4 +108,32 @@ func New(conf *Config) *Logging { }, }, } + if conf.FluentdPVC != nil { + values.Spec.Fluentd.BufferStorageVolume = &KubernetesStorage{ + Pvc: &Pvc{ + PvcSpec: &PvcSpec{ + StorageClassName: conf.FluentdPVC.StorageClassName, + Resources: &Resources{ + Requests: &Requests{ + Storage: conf.FluentdPVC.Storage, + }, + }, + }, + }, + } + values.Spec.Fluentd.DisablePvc = false + + if conf.FluentdPVC.AccessModes != nil { + values.Spec.Fluentd.BufferStorageVolume.Pvc.PvcSpec.AccessModes = conf.FluentdPVC.AccessModes + } else { + values.Spec.Fluentd.BufferStorageVolume.Pvc.PvcSpec.AccessModes = []string{"ReadWriteOnce"} + } + } + + if conf.Replicas != 0 { + values.Spec.Fluentd.Scaling = &Scaling{ + Replicas: conf.Replicas, + } + } + return values } diff --git a/internal/bundle/application/applications/loki/logs/logs.go b/internal/bundle/application/applications/loki/logs/logs.go index 29653ec..37809d0 100644 --- a/internal/bundle/application/applications/loki/logs/logs.go +++ b/internal/bundle/application/applications/loki/logs/logs.go @@ -31,19 +31,28 @@ func GetAllResources(toolsetCRDSpec *toolsetsv1beta1.ToolsetSpec) []interface{} } //logging resource so that fluentd and fluentbit are deployed - ret = append(ret, getLogging()) + ret = append(ret, getLogging(toolsetCRDSpec)) } return ret } -func getLogging() *logging.Logging { +func getLogging(toolsetCRDSpec *toolsetsv1beta1.ToolsetSpec) *logging.Logging { conf := &logging.Config{ Name: "logging", Namespace: "caos-system", ControlNamespace: "caos-system", } + if toolsetCRDSpec.LoggingOperator.FluentdPVC != nil { + conf.FluentdPVC = &logging.Storage{ + StorageClassName: toolsetCRDSpec.LoggingOperator.FluentdPVC.StorageClass, + Storage: toolsetCRDSpec.LoggingOperator.FluentdPVC.Size, + } + if toolsetCRDSpec.LoggingOperator.FluentdPVC.AccessModes != nil { + conf.FluentdPVC.AccessModes = toolsetCRDSpec.LoggingOperator.FluentdPVC.AccessModes + } + } return logging.New(conf) }