Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Start adding to helm chart
  • Loading branch information
HoustonPutman committed Nov 14, 2023
commit 81ce16745fe911df6388b4ffc1acdf16d627e932
13 changes: 12 additions & 1 deletion helm/solr-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ Determine whether to use ClusterRoles or Roles
{{- end -}}
{{- end -}}

{{- define "solr-operator.volumeMounts" -}}
{{- include "solr-operator.mTLS.volumeMounts" . }}
{{- include "solr-operator.logging.volumeMounts" . }}
{{- end -}}

{{- define "solr-operator.volumes" -}}
{{- include "solr-operator.mTLS.volumes" . }}
{{- include "solr-operator.logging.volumes" . }}
{{- end -}}


{{/*
mTLS vars
*/}}
Expand Down Expand Up @@ -136,4 +147,4 @@ rootSolrCert.pem
path: {{ include "solr-operator.mTLS.caCertName" . }}
optional: false
{{- end -}}
{{- end -}}
{{- end -}}
79 changes: 79 additions & 0 deletions helm/solr-operator/templates/_log_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{{/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/}}

{{/* vim: set filetype=mustache: */}}


{{/*
log file
*/}}

{{- define "solr-operator.logging.fileMountDir" -}}
/var/logs/operator
{{- end -}}

{{- define "solr-operator.logging.file" -}}
{{- if .Values.logging.file.enabled -}}
{{ include "solr-operator.logging.fileMountDir" . }}/{{ .Values.logging.file.path }}
{{- end -}}
{{- end -}}


{{/*
log file
*/}}
{{- define "solr-operator.logging.volumes" -}}
{{- if .Values.logging.file.enabled -}}
- {{ .Values.logging.file.volume | toYaml | nindent 2 }}
{{ include "solr-operator.logging.rotation.volume" . }}
{{- end -}}
{{- end -}}

{{/*
log volume mounts
*/}}
{{- define "solr-operator.logging.volumeMounts" -}}
{{- if .Values.logging.file.enabled -}}
- name: {{ .Values.logging.file.volume.name }}
mountPath: {{ include "solr-operator.logging.fileMountDir" . }}
readOnly: false
{{ include "solr-operator.logging.rotation.volumeMount" . }}
{{- end -}}
{{- end -}}

{{/*
log rotation
*/}}
{{- define "solr-operator.logging.rotation.configMapName" -}}
log-rotate-conf
{{- end -}}

{{- define "solr-operator.logging.rotation.volumeMount" -}}
{{- if .Values.logging.file.enabled | and .Values.logging.file.rotation.enabled -}}
- name: {{ include "solr-operator.logging.rotation.configMapName" . }}
mountPath: /etc/logrotate.d/
readOnly: true
{{- end -}}

{{- end -}}
{{- define "solr-operator.logging.rotation.volume" -}}
{{- if .Values.logging.file.enabled | and .Values.logging.file.rotation.enabled -}}
- name: {{ include "solr-operator.logging.rotation.configMapName" . }}
configMap:
name: {{ include "solr-operator.logging.rotation.configMapName" . }}
{{- end -}}
{{- end -}}
17 changes: 13 additions & 4 deletions helm/solr-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ spec:
{{- if .Values.watchNamespaces }}
- --watch-namespaces={{- include "solr-operator.watchNamespaces" . -}}
{{- end }}
{{- with ( include "solr-operator.logging.file" .) }}
{{- if . }}
- --log-file={{- . -}}
{{- end }}
{{- end }}
{{- if .Values.mTLS.clientCertSecret }}
- --tls-client-cert-path={{- include "solr-operator.mTLS.clientCertDirectory" . -}}/tls.crt
- --tls-client-cert-key-path={{- include "solr-operator.mTLS.clientCertDirectory" . -}}/tls.key
Expand Down Expand Up @@ -106,19 +111,23 @@ spec:

resources:
{{- toYaml .Values.resources | nindent 10 }}
{{- if (include "solr-operator.mTLS.volumeMounts" .) }}
{{- with include "solr-operator.volumeMounts" . }}
{{- if . }}
volumeMounts:
{{- include "solr-operator.mTLS.volumeMounts" . | nindent 10 }}
{{- . | nindent 10 }}
{{- end }}
{{- end }}

{{- if .Values.metrics.enable }}
ports:
- containerPort: 8080
name: metrics
{{- end }}
{{- if (include "solr-operator.mTLS.volumes" .) }}
{{- with include "solr-operator.volumes" . }}
{{- if . }}
volumes:
{{- include "solr-operator.mTLS.volumes" . | nindent 8 }}
{{- . | nindent 8 }}
{{- end }}
{{- end }}

{{- if .Values.sidecarContainers }}
Expand Down
33 changes: 33 additions & 0 deletions helm/solr-operator/templates/log_rotation_configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

{{- if .Values.logging.file.enabled | and .Values.logging.file.rotation.enabled }}
---
# config for doing log rotation in the Solr Operator pod
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "solr-operator.logging.rotation.configMapName" . }}
namespace: {{ .Release.Namespace }}
data:
solr-operator: |
{{ include "solr-operator.logging.file" . }} {
rotate {{ .Values.logging.file.rotation.numOldFilesToKeep | default 0 }}
size {{ .Values.logging.file.rotation.maxFileSize | default "10m"}}
nocompress
missingok
notifempty
}
{{- end }}
25 changes: 25 additions & 0 deletions helm/solr-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,28 @@ mTLS:
# Enable metrics for the Solr Operator
metrics:
enable: true

# Logging settings for the Solr Operator
logging:
# Log to a file in addition to stdErr
file:
# Whether to enable logging to a file
enabled: true
# The path of the log file within the volume
path: "operator.log"

# The volume that will be used to store the log file(s)
volume:
name: logs
emptyDir:
sizeLimit: 100Mi

# The log rotation policy
rotation:
enabled: true
numOldFilesToKeep: 3
maxFileSize: 20M
emptyDir:
sizeLimit: 100Mi


1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func main() {
if version.VersionSuffix != "" {
fullVersion += "-" + version.VersionSuffix
}
setupLog.Info("Writing logs to file", "path", logFile)
setupLog.Info(fmt.Sprintf("solr-operator Version: %v", fullVersion))
setupLog.Info(fmt.Sprintf("solr-operator Git SHA: %s", version.GitSHA))
setupLog.Info(fmt.Sprintf("solr-operator Build Time: %s", version.BuildTime))
Expand Down