diff --git a/charts/logging-operator/crds/logging.banzaicloud.io_loggings.yaml b/charts/logging-operator/crds/logging.banzaicloud.io_loggings.yaml index 433bb8527..b660972b4 100644 --- a/charts/logging-operator/crds/logging.banzaicloud.io_loggings.yaml +++ b/charts/logging-operator/crds/logging.banzaicloud.io_loggings.yaml @@ -13020,6 +13020,13 @@ spec: timeout: type: string type: object + bufferVolumeMetricsImage: + properties: + repository: + type: string + tag: + type: string + type: object bufferVolumeMetricsService: properties: metadata: @@ -16664,6 +16671,13 @@ spec: type: object type: array type: object + configReloadImage: + properties: + repository: + type: string + tag: + type: string + type: object globalOptions: properties: log_level: @@ -16938,6 +16952,13 @@ spec: timeout: type: string type: object + metricsExporterImage: + properties: + repository: + type: string + tag: + type: string + type: object metricsService: properties: metadata: @@ -20962,6 +20983,13 @@ spec: type: array type: object type: object + syslogNGImage: + properties: + repository: + type: string + tag: + type: string + type: object tls: properties: enabled: diff --git a/charts/logging-operator/crds/logging.banzaicloud.io_syslogngconfigs.yaml b/charts/logging-operator/crds/logging.banzaicloud.io_syslogngconfigs.yaml index 136469b0a..a2700ef3c 100644 --- a/charts/logging-operator/crds/logging.banzaicloud.io_syslogngconfigs.yaml +++ b/charts/logging-operator/crds/logging.banzaicloud.io_syslogngconfigs.yaml @@ -280,6 +280,13 @@ spec: timeout: type: string type: object + bufferVolumeMetricsImage: + properties: + repository: + type: string + tag: + type: string + type: object bufferVolumeMetricsService: properties: metadata: @@ -3924,6 +3931,13 @@ spec: type: object type: array type: object + configReloadImage: + properties: + repository: + type: string + tag: + type: string + type: object globalOptions: properties: log_level: @@ -4198,6 +4212,13 @@ spec: timeout: type: string type: object + metricsExporterImage: + properties: + repository: + type: string + tag: + type: string + type: object metricsService: properties: metadata: @@ -8222,6 +8243,13 @@ spec: type: array type: object type: object + syslogNGImage: + properties: + repository: + type: string + tag: + type: string + type: object tls: properties: enabled: diff --git a/config/crd/bases/logging.banzaicloud.io_loggings.yaml b/config/crd/bases/logging.banzaicloud.io_loggings.yaml index 433bb8527..b660972b4 100644 --- a/config/crd/bases/logging.banzaicloud.io_loggings.yaml +++ b/config/crd/bases/logging.banzaicloud.io_loggings.yaml @@ -13020,6 +13020,13 @@ spec: timeout: type: string type: object + bufferVolumeMetricsImage: + properties: + repository: + type: string + tag: + type: string + type: object bufferVolumeMetricsService: properties: metadata: @@ -16664,6 +16671,13 @@ spec: type: object type: array type: object + configReloadImage: + properties: + repository: + type: string + tag: + type: string + type: object globalOptions: properties: log_level: @@ -16938,6 +16952,13 @@ spec: timeout: type: string type: object + metricsExporterImage: + properties: + repository: + type: string + tag: + type: string + type: object metricsService: properties: metadata: @@ -20962,6 +20983,13 @@ spec: type: array type: object type: object + syslogNGImage: + properties: + repository: + type: string + tag: + type: string + type: object tls: properties: enabled: diff --git a/config/crd/bases/logging.banzaicloud.io_syslogngconfigs.yaml b/config/crd/bases/logging.banzaicloud.io_syslogngconfigs.yaml index 136469b0a..a2700ef3c 100644 --- a/config/crd/bases/logging.banzaicloud.io_syslogngconfigs.yaml +++ b/config/crd/bases/logging.banzaicloud.io_syslogngconfigs.yaml @@ -280,6 +280,13 @@ spec: timeout: type: string type: object + bufferVolumeMetricsImage: + properties: + repository: + type: string + tag: + type: string + type: object bufferVolumeMetricsService: properties: metadata: @@ -3924,6 +3931,13 @@ spec: type: object type: array type: object + configReloadImage: + properties: + repository: + type: string + tag: + type: string + type: object globalOptions: properties: log_level: @@ -4198,6 +4212,13 @@ spec: timeout: type: string type: object + metricsExporterImage: + properties: + repository: + type: string + tag: + type: string + type: object metricsService: properties: metadata: @@ -8222,6 +8243,13 @@ spec: type: array type: object type: object + syslogNGImage: + properties: + repository: + type: string + tag: + type: string + type: object tls: properties: enabled: diff --git a/docs/configuration/crds/v1beta1/common_types.md b/docs/configuration/crds/v1beta1/common_types.md index ba9fd788c..5f9ab5a2a 100644 --- a/docs/configuration/crds/v1beta1/common_types.md +++ b/docs/configuration/crds/v1beta1/common_types.md @@ -4,6 +4,17 @@ weight: 200 generated_file: true --- +## BasicImageSpec + +BasicImageSpec struct hold basic information about image specification + +### repository (string, optional) {#basicimagespec-repository} + + +### tag (string, optional) {#basicimagespec-tag} + + + ## ImageSpec ImageSpec struct hold information about image specification diff --git a/docs/configuration/crds/v1beta1/syslogng_types.md b/docs/configuration/crds/v1beta1/syslogng_types.md index 1c9d7a387..5635bb7ba 100644 --- a/docs/configuration/crds/v1beta1/syslogng_types.md +++ b/docs/configuration/crds/v1beta1/syslogng_types.md @@ -11,6 +11,9 @@ SyslogNGSpec defines the desired state of SyslogNG ### bufferVolumeMetrics (*BufferMetrics, optional) {#syslogngspec-buffervolumemetrics} +### bufferVolumeMetricsImage (*BasicImageSpec, optional) {#syslogngspec-buffervolumemetricsimage} + + ### bufferVolumeMetricsService (*typeoverride.Service, optional) {#syslogngspec-buffervolumemetricsservice} @@ -22,6 +25,9 @@ Overrides the default logging level configCheck setup. This field is not used di ### configCheckPod (*typeoverride.PodSpec, optional) {#syslogngspec-configcheckpod} +### configReloadImage (*BasicImageSpec, optional) {#syslogngspec-configreloadimage} + + ### globalOptions (*GlobalOptions, optional) {#syslogngspec-globaloptions} @@ -42,6 +48,9 @@ Available in Logging operator version 4.5 and later. Set the maximum number of c ### metrics (*Metrics, optional) {#syslogngspec-metrics} +### metricsExporterImage (*BasicImageSpec, optional) {#syslogngspec-metricsexporterimage} + + ### metricsService (*typeoverride.Service, optional) {#syslogngspec-metricsservice} @@ -70,6 +79,9 @@ Available in Logging operator version 4.5 and later. Create [custom log metrics ### statefulSet (*typeoverride.StatefulSet, optional) {#syslogngspec-statefulset} +### syslogNGImage (*BasicImageSpec, optional) {#syslogngspec-syslogngimage} + + ### tls (SyslogNGTLS, optional) {#syslogngspec-tls} diff --git a/pkg/resources/syslogng/configcheck.go b/pkg/resources/syslogng/configcheck.go index 82a737036..02df3379e 100644 --- a/pkg/resources/syslogng/configcheck.go +++ b/pkg/resources/syslogng/configcheck.go @@ -235,7 +235,7 @@ func (r *Reconciler) newCheckPod(hashKey string) (*corev1.Pod, error) { Containers: []corev1.Container{ { Name: "syslog-ng", - Image: v1beta1.RepositoryWithTag(syslogngImageRepository, syslogngImageTag), + Image: r.syslogNGSpec.SyslogNGImage.RepositoryWithTag(), ImagePullPolicy: corev1.PullIfNotPresent, Command: containerCommand, Args: containerArgs, diff --git a/pkg/resources/syslogng/statefulset.go b/pkg/resources/syslogng/statefulset.go index c4b44c481..d7ef00e2c 100644 --- a/pkg/resources/syslogng/statefulset.go +++ b/pkg/resources/syslogng/statefulset.go @@ -101,7 +101,7 @@ func (r *Reconciler) statefulset() (runtime.Object, reconciler.DesiredState, err func syslogNGContainer(spec *v1beta1.SyslogNGSpec) corev1.Container { return corev1.Container{ Name: ContainerName, - Image: v1beta1.RepositoryWithTag(syslogngImageRepository, syslogngImageTag), + Image: spec.SyslogNGImage.RepositoryWithTag(), ImagePullPolicy: corev1.PullIfNotPresent, Ports: []corev1.ContainerPort{{ Name: "syslog-ng-tcp", @@ -232,7 +232,7 @@ func (r *Reconciler) syslogNGMetricsSidecarContainer() *corev1.Container { return &corev1.Container{ Name: "exporter", ImagePullPolicy: corev1.PullIfNotPresent, - Image: v1beta1.RepositoryWithTag(prometheusExporterImageRepository, prometheusExporterImageTag), + Image: r.syslogNGSpec.MetricsExporterImage.RepositoryWithTag(), Ports: []corev1.ContainerPort{ { Name: metricsPortName, @@ -269,7 +269,7 @@ func (r *Reconciler) bufferMetricsSidecarContainer() *corev1.Container { return &corev1.Container{ Name: "buffer-metrics-sidecar", - Image: v1beta1.RepositoryWithTag(bufferVolumeImageRepository, bufferVolumeImageTag), + Image: r.syslogNGSpec.BufferVolumeMetricsImage.RepositoryWithTag(), ImagePullPolicy: corev1.PullIfNotPresent, Args: []string{ "--port", "7358", @@ -366,7 +366,7 @@ func configReloadContainer(spec *v1beta1.SyslogNGSpec) corev1.Container { // TODO: ADD TLS reload watch container := corev1.Container{ Name: "config-reloader", - Image: v1beta1.RepositoryWithTag(configReloaderImageRepository, configReloaderImageTag), + Image: spec.ConfigReloadImage.RepositoryWithTag(), ImagePullPolicy: corev1.PullIfNotPresent, Args: []string{ "-cfgjson", diff --git a/pkg/resources/syslogng/syslogng.go b/pkg/resources/syslogng/syslogng.go index 7c8f5ca89..374e153d7 100644 --- a/pkg/resources/syslogng/syslogng.go +++ b/pkg/resources/syslogng/syslogng.go @@ -36,36 +36,28 @@ import ( ) const ( - ServiceName = "syslog-ng" - ServicePort = 601 - configSecretName = "syslog-ng" - configKey = "syslog-ng.conf" - StatefulSetName = "syslog-ng" - outputSecretName = "syslog-ng-output" - OutputSecretPath = "/etc/syslog-ng/secret" - BufferPath = "/buffers" - serviceAccountName = "syslog-ng" - roleBindingName = "syslog-ng" - roleName = "syslog-ng" - clusterRoleBindingName = "syslog-ng" - clusterRoleName = "syslog-ng" - ContainerName = "syslog-ng" - defaultBufferVolumeMetricsPort = 9200 - syslogngImageRepository = "ghcr.io/axoflow/axosyslog" - syslogngImageTag = "4.8.1-1" - prometheusExporterImageRepository = "ghcr.io/axoflow/axosyslog-metrics-exporter" - prometheusExporterImageTag = "0.0.7" - bufferVolumeImageRepository = "ghcr.io/kube-logging/node-exporter" - bufferVolumeImageTag = "v0.8.0" - configReloaderImageRepository = "ghcr.io/kube-logging/syslogng-reload" - configReloaderImageTag = "v1.5.0" - socketVolumeName = "socket" - socketPath = "/tmp/syslog-ng/syslog-ng.ctl" - configDir = "/etc/syslog-ng/config" - configVolumeName = "config" - tlsVolumeName = "tls" - metricsPortNumber = 9577 - metricsPortName = "exporter" + ServiceName = "syslog-ng" + ServicePort = 601 + configSecretName = "syslog-ng" + configKey = "syslog-ng.conf" + StatefulSetName = "syslog-ng" + outputSecretName = "syslog-ng-output" + OutputSecretPath = "/etc/syslog-ng/secret" + BufferPath = "/buffers" + serviceAccountName = "syslog-ng" + roleBindingName = "syslog-ng" + roleName = "syslog-ng" + clusterRoleBindingName = "syslog-ng" + clusterRoleName = "syslog-ng" + ContainerName = "syslog-ng" + defaultBufferVolumeMetricsPort = 9200 + socketVolumeName = "socket" + socketPath = "/tmp/syslog-ng/syslog-ng.ctl" + configDir = "/etc/syslog-ng/config" + configVolumeName = "config" + tlsVolumeName = "tls" + metricsPortNumber = 9577 + metricsPortName = "exporter" ) // Reconciler holds info what resource to reconcile diff --git a/pkg/sdk/logging/api/v1beta1/common_types.go b/pkg/sdk/logging/api/v1beta1/common_types.go index 79f6af81e..251fdf642 100644 --- a/pkg/sdk/logging/api/v1beta1/common_types.go +++ b/pkg/sdk/logging/api/v1beta1/common_types.go @@ -33,6 +33,16 @@ const ( HostPath = "/opt/logging-operator/%s/%s" ) +// BasicImageSpec struct hold basic information about image specification +type BasicImageSpec struct { + Repository string `json:"repository,omitempty"` + Tag string `json:"tag,omitempty"` +} + +func (s BasicImageSpec) RepositoryWithTag() string { + return RepositoryWithTag(s.Repository, s.Tag) +} + // ImageSpec struct hold information about image specification type ImageSpec struct { Repository string `json:"repository,omitempty"` diff --git a/pkg/sdk/logging/api/v1beta1/syslogng_types.go b/pkg/sdk/logging/api/v1beta1/syslogng_types.go index 7ff1381fe..b57a4bd9c 100644 --- a/pkg/sdk/logging/api/v1beta1/syslogng_types.go +++ b/pkg/sdk/logging/api/v1beta1/syslogng_types.go @@ -29,10 +29,25 @@ type _hugoSyslogNGSpec interface{} //nolint:deadcode,unused // +description:"SyslogNGSpec defines the desired state of SyslogNG" type _metaSyslogNGSpec interface{} //nolint:deadcode,unused +const ( + defaultSyslogngImageRepository = "ghcr.io/axoflow/axosyslog" + defaultSyslogngImageTag = "4.8.1-1" + configReloaderImageRepository = "ghcr.io/kube-logging/syslogng-reload" + configReloaderImageTag = "v1.5.0" + prometheusExporterImageRepository = "ghcr.io/axoflow/axosyslog-metrics-exporter" + prometheusExporterImageTag = "0.0.7" + bufferVolumeImageRepository = "ghcr.io/kube-logging/node-exporter" + bufferVolumeImageTag = "v0.8.0" +) + // +kubebuilder:object:generate=true // SyslogNGSpec defines the desired state of SyslogNG type SyslogNGSpec struct { + SyslogNGImage *BasicImageSpec `json:"syslogNGImage,omitempty"` + ConfigReloadImage *BasicImageSpec `json:"configReloadImage,omitempty"` + MetricsExporterImage *BasicImageSpec `json:"metricsExporterImage,omitempty"` + BufferVolumeMetricsImage *BasicImageSpec `json:"bufferVolumeMetricsImage,omitempty"` TLS SyslogNGTLS `json:"tls,omitempty"` ReadinessDefaultCheck ReadinessDefaultCheck `json:"readinessDefaultCheck,omitempty"` SkipRBACCreate bool `json:"skipRBACCreate,omitempty"` @@ -122,5 +137,29 @@ func (s *SyslogNGSpec) SetDefaults() { s.Metrics.Interval = "15s" } } + if s.SyslogNGImage == nil { + s.SyslogNGImage = &BasicImageSpec{ + Repository: defaultSyslogngImageRepository, + Tag: defaultSyslogngImageTag, + } + } + if s.ConfigReloadImage == nil { + s.ConfigReloadImage = &BasicImageSpec{ + Repository: configReloaderImageRepository, + Tag: configReloaderImageTag, + } + } + if s.MetricsExporterImage == nil { + s.MetricsExporterImage = &BasicImageSpec{ + Repository: prometheusExporterImageRepository, + Tag: prometheusExporterImageTag, + } + } + if s.BufferVolumeMetricsImage == nil { + s.BufferVolumeMetricsImage = &BasicImageSpec{ + Repository: bufferVolumeImageRepository, + Tag: bufferVolumeImageTag, + } + } } } diff --git a/pkg/sdk/logging/api/v1beta1/zz_generated.deepcopy.go b/pkg/sdk/logging/api/v1beta1/zz_generated.deepcopy.go index f79257568..d0728217a 100644 --- a/pkg/sdk/logging/api/v1beta1/zz_generated.deepcopy.go +++ b/pkg/sdk/logging/api/v1beta1/zz_generated.deepcopy.go @@ -34,6 +34,21 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BasicImageSpec) DeepCopyInto(out *BasicImageSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BasicImageSpec. +func (in *BasicImageSpec) DeepCopy() *BasicImageSpec { + if in == nil { + return nil + } + out := new(BasicImageSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BufferMetrics) DeepCopyInto(out *BufferMetrics) { *out = *in @@ -3534,6 +3549,26 @@ func (in *SyslogNGOutputStatus) DeepCopy() *SyslogNGOutputStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SyslogNGSpec) DeepCopyInto(out *SyslogNGSpec) { *out = *in + if in.SyslogNGImage != nil { + in, out := &in.SyslogNGImage, &out.SyslogNGImage + *out = new(BasicImageSpec) + **out = **in + } + if in.ConfigReloadImage != nil { + in, out := &in.ConfigReloadImage, &out.ConfigReloadImage + *out = new(BasicImageSpec) + **out = **in + } + if in.MetricsExporterImage != nil { + in, out := &in.MetricsExporterImage, &out.MetricsExporterImage + *out = new(BasicImageSpec) + **out = **in + } + if in.BufferVolumeMetricsImage != nil { + in, out := &in.BufferVolumeMetricsImage, &out.BufferVolumeMetricsImage + *out = new(BasicImageSpec) + **out = **in + } out.TLS = in.TLS out.ReadinessDefaultCheck = in.ReadinessDefaultCheck if in.StatefulSetOverrides != nil {