Skip to content
This repository has been archived by the owner on Jun 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #42 from caos/pvcs
Browse files Browse the repository at this point in the history
Pvcs
  • Loading branch information
stebenz authored Jan 29, 2020
2 parents 3fb5a12 + 1482e69 commit b585652
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 28 deletions.
1 change: 1 addition & 0 deletions api/v1beta1/grafana.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
3 changes: 2 additions & 1 deletion api/v1beta1/logging-operator.go
Original file line number Diff line number Diff line change
@@ -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"`
}
9 changes: 9 additions & 0 deletions internal/bundle/application/applications/grafana/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 14 additions & 0 deletions internal/bundle/application/applications/grafana/helm/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"},
}

Expand Down
37 changes: 24 additions & 13 deletions internal/bundle/application/applications/grafana/helm/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
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"`
}
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"`
Expand All @@ -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"`
Expand All @@ -56,19 +79,22 @@ type Logging struct {
}

func New(conf *Config) *Logging {
return &Logging{
values := &Logging{
APIVersion: "logging.banzaicloud.io/v1beta1",
Kind: "Logging",
Metadata: &Metadata{
Name: conf.Name,
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{
Expand All @@ -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
}
13 changes: 11 additions & 2 deletions internal/bundle/application/applications/loki/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit b585652

Please sign in to comment.