Skip to content
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
13 changes: 9 additions & 4 deletions api/v1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ type AdminAuth struct {
}

type LogCollection struct {
Enabled bool `json:"enabled,omitempty"`
// +kubebuilder:default:=false
Enabled bool `json:"enabled,omitempty"`
// +kubebuilder:default:="fluent/fluent-bit:3.2.5"
Image string `json:"image,omitempty"`
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
Files LogFilesConfig `json:"files,omitempty"`
Outputs string `json:"outputs,omitempty"`
// +kubebuilder:default:={"requests":{"cpu":"100m","memory":"200Mi"},"limits":{"cpu":"200m","memory":"500Mi"}}
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
// +kubebuilder:default:={errorLogs: true, accessLogs: true, requestLogs: true, crashLogs: true, auditLogs: true}
Files LogFilesConfig `json:"files,omitempty"`
// +kubebuilder:default:="[OUTPUT]\n name loki\n match *\n host loki.default.svc.cluster.local\n port 3100\n labels job=fluent-bit\n http_user admin\n http_passwd admin"
Outputs string `json:"outputs,omitempty"`
}

type LogFilesConfig struct {
Expand Down
48 changes: 48 additions & 0 deletions config/crd/bases/marklogic.progress.com_marklogicclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4639,8 +4639,15 @@ spec:
memory: 200Mi
properties:
enabled:
default: false
type: boolean
files:
default:
accessLogs: true
auditLogs: true
crashLogs: true
errorLogs: true
requestLogs: true
properties:
accessLogs:
type: boolean
Expand All @@ -4654,6 +4661,7 @@ spec:
type: boolean
type: object
image:
default: fluent/fluent-bit:3.2.5
type: string
imagePullSecrets:
items:
Expand All @@ -4674,8 +4682,24 @@ spec:
x-kubernetes-map-type: atomic
type: array
outputs:
default: |-
[OUTPUT]
name loki
match *
host loki.default.svc.cluster.local
port 3100
labels job=fluent-bit
http_user admin
http_passwd admin
type: string
resources:
default:
limits:
cpu: 200m
memory: 500Mi
requests:
cpu: 100m
memory: 200Mi
description: ResourceRequirements describes the compute resource
requirements.
properties:
Expand Down Expand Up @@ -9367,8 +9391,15 @@ spec:
logCollection:
properties:
enabled:
default: false
type: boolean
files:
default:
accessLogs: true
auditLogs: true
crashLogs: true
errorLogs: true
requestLogs: true
properties:
accessLogs:
type: boolean
Expand All @@ -9382,6 +9413,7 @@ spec:
type: boolean
type: object
image:
default: fluent/fluent-bit:3.2.5
type: string
imagePullSecrets:
items:
Expand All @@ -9402,8 +9434,24 @@ spec:
x-kubernetes-map-type: atomic
type: array
outputs:
default: |-
[OUTPUT]
name loki
match *
host loki.default.svc.cluster.local
port 3100
labels job=fluent-bit
http_user admin
http_passwd admin
type: string
resources:
default:
limits:
cpu: 200m
memory: 500Mi
requests:
cpu: 100m
memory: 200Mi
description: ResourceRequirements describes the compute
resource requirements.
properties:
Expand Down
24 changes: 24 additions & 0 deletions config/crd/bases/marklogic.progress.com_marklogicgroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3382,8 +3382,15 @@ spec:
memory: 200Mi
properties:
enabled:
default: false
type: boolean
files:
default:
accessLogs: true
auditLogs: true
crashLogs: true
errorLogs: true
requestLogs: true
properties:
accessLogs:
type: boolean
Expand All @@ -3397,6 +3404,7 @@ spec:
type: boolean
type: object
image:
default: fluent/fluent-bit:3.2.5
type: string
imagePullSecrets:
items:
Expand All @@ -3417,8 +3425,24 @@ spec:
x-kubernetes-map-type: atomic
type: array
outputs:
default: |-
[OUTPUT]
name loki
match *
host loki.default.svc.cluster.local
port 3100
labels job=fluent-bit
http_user admin
http_passwd admin
type: string
resources:
default:
limits:
cpu: 200m
memory: 500Mi
requests:
cpu: 100m
memory: 200Mi
description: ResourceRequirements describes the compute resource
requirements.
properties:
Expand Down
52 changes: 0 additions & 52 deletions pkg/k8sutil/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

var CustomLabels = map[string]string{}
var CustomAnnotations = map[string]string{}

// generateTypeMeta generates the TyeMeta
func generateTypeMeta(resourceKind string, apiVersion string) metav1.TypeMeta {
return metav1.TypeMeta{
Expand Down Expand Up @@ -49,15 +46,6 @@ func LabelSelectors(labels map[string]string) *metav1.LabelSelector {
return &metav1.LabelSelector{MatchLabels: labels}
}

func SetCommonLabels(labels map[string]string) {
CustomLabels = labels
}

func SetCommonAnnotations(annotations map[string]string) {
delete(annotations, "kubectl.kubernetes.io/last-applied-configuration")
CustomAnnotations = annotations
}

func getSelectorLabels(name string) map[string]string {
selectorLabels := map[string]string{
"app.kubernetes.io/name": "marklogic",
Expand All @@ -78,46 +66,6 @@ func getHAProxySelectorLabels(name string) map[string]string {
return selectorLabels
}

func getHAProxyLabels(name string) map[string]string {
defaultHaproxyLabels := getHAProxySelectorLabels(name)
mergedLabels := map[string]string{}
if len(CustomLabels) > 0 {
for k, v := range defaultHaproxyLabels {
mergedLabels[k] = v
}
for k, v := range CustomLabels {
if _, ok := defaultHaproxyLabels[k]; !ok {
mergedLabels[k] = v
}
}
} else {
return defaultHaproxyLabels
}
return mergedLabels
}

func getCommonLabels(name string) map[string]string {
defaultLabels := getSelectorLabels(name)
mergedLabels := map[string]string{}
if len(CustomLabels) > 0 {
for k, v := range defaultLabels {
mergedLabels[k] = v
}
for k, v := range CustomLabels {
if _, ok := defaultLabels[k]; !ok {
mergedLabels[k] = v
}
}
} else {
return defaultLabels
}
return mergedLabels
}

func getCommonAnnotations() map[string]string {
return CustomAnnotations
}

func getFluentBitLabels(name string) map[string]string {
return map[string]string{
"app.kubernetes.io/name": "fluent-bit",
Expand Down
4 changes: 2 additions & 2 deletions pkg/k8sutil/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func (oc *OperatorContext) ReconcileConfigMap() result.ReconcileResult {
cr := oc.MarklogicGroup

logger.Info("Reconciling MarkLogic ConfigMap")
labels := getCommonLabels(cr.Spec.Name)
annotations := getCommonAnnotations()
labels := oc.GetOperatorLabels(cr.Spec.Name)
annotations := oc.GetOperatorAnnotations()
configMapName := cr.Spec.Name + "-scripts"
objectMeta := generateObjectMeta(configMapName, cr.Namespace, labels, annotations)
nsName := types.NamespacedName{Name: objectMeta.Name, Namespace: objectMeta.Namespace}
Expand Down
Loading