Skip to content

Commit 00dedb2

Browse files
jshum2479rjeberhard
authored andcommitted
Add support for persisting log files in WKO.
1 parent 0067876 commit 00dedb2

File tree

5 files changed

+58
-5
lines changed

5 files changed

+58
-5
lines changed

deployment/scripts/logstash.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ java.util.logging.ConsoleHandler.level=INFO
55
java.util.logging.ConsoleHandler.formatter=oracle.kubernetes.operator.logging.OperatorLoggingFormatter
66
java.util.logging.FileHandler.level=INFO
77
java.util.logging.FileHandler.formatter=oracle.kubernetes.operator.logging.OperatorLoggingFormatter
8-
java.util.logging.FileHandler.pattern=/logs/operator%g.log
8+
java.util.logging.FileHandler.pattern=LOGGING_DIR/operator%g.log
99
java.util.logging.FileHandler.limit=JAVA_LOGGING_MAXSIZE
1010
java.util.logging.FileHandler.count=JAVA_LOGGING_COUNT

deployment/scripts/operator.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ fi
7070

7171
sed -i -e "s|JAVA_LOGGING_MAXSIZE|${JAVA_LOGGING_MAXSIZE:-20000000}|g" $LOGGING_CONFIG
7272
sed -i -e "s|JAVA_LOGGING_COUNT|${JAVA_LOGGING_COUNT:-10}|g" $LOGGING_CONFIG
73+
sed -i -e "s|LOGGING_DIR|${OPERATOR_LOGDIR:-/logs}|g" $LOGGING_CONFIG
7374

7475
if [ "${MOCK_WLS}" == 'true' ]; then
7576
MOCKING_WLS="-DmockWLS=true"
7677
fi
7778

7879
LOGGING="-Djava.util.logging.config.file=${LOGGING_CONFIG}"
79-
mkdir -m 777 -p /logs
80+
mkdir -m 777 -p ${OPERATOR_LOGDIR:-/logs}
8081
# assumption is that we have mounted a volume on /logs which is also visible to
8182
# the logstash container/pod.
8283

deployment/scripts/webhook.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ fi
6666

6767
sed -i -e "s|JAVA_LOGGING_MAXSIZE|${JAVA_LOGGING_MAXSIZE:-20000000}|g" $LOGGING_CONFIG
6868
sed -i -e "s|JAVA_LOGGING_COUNT|${JAVA_LOGGING_COUNT:-10}|g" $LOGGING_CONFIG
69+
sed -i -e "s|LOGGING_DIR|${OPERATOR_LOGDIR:-/logs}|g" $LOGGING_CONFIG
6970

7071
LOGGING="-Djava.util.logging.config.file=${LOGGING_CONFIG}"
7172
# assumption is that we have mounted a volume on /logs which is also visible to
7273
# the logstash container/pod.
73-
mkdir -m 777 -p /logs
74+
mkdir -m 777 -p ${OPERATOR_LOGDIR:-/logs}
7475

7576
# Container memory optimization flags
7677
HEAP="-XshowSettings:vm"

kubernetes/charts/weblogic-operator/templates/_operator-dep.tpl

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
{{- define "operator.operatorDeployment" }}
5+
56
---
67
{{- if not .webhookOnly }}
78
apiVersion: "apps/v1"
@@ -91,6 +92,13 @@ spec:
9192
value: {{ .javaLoggingFileCount | default 10 | quote }}
9293
- name: "JVM_OPTIONS"
9394
value: {{ .jvmOptions | default "-XshowSettings:vm -XX:MaxRAMPercentage=70" | quote }}
95+
{{- if and .operatorLogDir .operatorLogMount }}
96+
{{- if not (hasPrefix (toString .operatorLogMount) (toString .operatorLogDir)) }}
97+
{{- fail (printf "Error: Invalid Configuration: operatorLogDir %s must start with operatorlogMount %s" .operatorLogDir .operatorLogMount) }}
98+
{{- end }}
99+
- name: "OPERATOR_LOGDIR"
100+
value: {{ .operatorLogDir | quote }}
101+
{{- end }}
94102
{{- if .remoteDebugNodePortEnabled }}
95103
- name: "REMOTE_DEBUG_PORT"
96104
value: {{ .internalDebugHttpPort | quote }}
@@ -133,10 +141,16 @@ spec:
133141
- name: "weblogic-operator-secrets-volume"
134142
mountPath: "/deployment/secrets"
135143
readOnly: true
136-
{{- if .elkIntegrationEnabled }}
144+
{{- if and .elkIntegrationEnabled .operatorLogPVC }}
145+
{{- fail "Error: elkIntegrationEnabled and opeatorLogPVC cannot be set at the same time."}}
146+
{{- else if .elkIntegrationEnabled }}
137147
- mountPath: "/logs"
138148
name: "log-dir"
139149
readOnly: false
150+
{{- else if .operatorLogPVC }}
151+
- mountPath: {{ .operatorLogMount | quote }}
152+
name: "log-dir"
153+
readOnly: false
140154
{{- end }}
141155
{{- if not .remoteDebugNodePortEnabled }}
142156
livenessProbe:
@@ -207,6 +221,13 @@ spec:
207221
secret:
208222
secretName: "logstash-certs-secret"
209223
optional: true
224+
{{- else if .operatorLogPVC }}
225+
{{- if not (and .operatorLogMount .operatorLogDir) }}
226+
{{- fail "Must provide operatorLogMount and operatorLogDir when using operatorLogPVC" }}
227+
{{- end }}
228+
- name: "log-dir"
229+
persistentVolumeClaim:
230+
claimName: {{ .operatorLogPVC }}
210231
{{- end }}
211232
{{- end }}
212233
---
@@ -318,6 +339,13 @@ spec:
318339
value: {{ int64 .javaLoggingFileSizeLimit | default 20000000 | quote }}
319340
- name: "JAVA_LOGGING_COUNT"
320341
value: {{ .javaLoggingFileCount | default 10 | quote }}
342+
{{- if and .operatorLogDir .operatorLogMount }}
343+
{{- if not (hasPrefix (toString .operatorLogMount) (toString .operatorLogDir)) }}
344+
{{- fail (printf "Error: Invalid Configuration: operatorLogDir %s must start with operatorlogMount %s" .operatorLogDir .operatorLogMount) }}
345+
{{- end }}
346+
- name: "OPERATOR_LOGDIR"
347+
value: {{ .operatorLogDir | quote }}
348+
{{- end }}
321349
{{- if .remoteDebugNodePortEnabled }}
322350
- name: "REMOTE_DEBUG_PORT"
323351
value: {{ .webhookDebugHttpPort | quote }}
@@ -354,10 +382,16 @@ spec:
354382
- name: "weblogic-webhook-secrets-volume"
355383
mountPath: "/deployment/secrets"
356384
readOnly: true
357-
{{- if .elkIntegrationEnabled }}
385+
{{- if and .elkIntegrationEnabled .operatorLogPVC }}
386+
{{- fail "Error: elkIntegrationEnabled and opeatorLogPVC cannot be set at the same time."}}
387+
{{- else if .elkIntegrationEnabled }}
358388
- mountPath: "/logs"
359389
name: "log-dir"
360390
readOnly: false
391+
{{- else if .operatorLogPVC }}
392+
- mountPath: {{ .operatorLogMount | quote }}
393+
name: "log-dir"
394+
readOnly: false
361395
{{- end }}
362396
{{- if not .remoteDebugNodePortEnabled }}
363397
livenessProbe:
@@ -423,6 +457,13 @@ spec:
423457
secret:
424458
secretName: "logstash-certs-secret"
425459
optional: true
460+
{{- else if .operatorLogPVC }}
461+
{{- if not (and .operatorLogMount .operatorLogDir) }}
462+
{{- fail "Must provide operatorLogMount and operatorLogDir when using operatorLogPVC" }}
463+
{{- end }}
464+
- name: "log-dir"
465+
persistentVolumeClaim:
466+
claimName: {{ .operatorLogPVC }}
426467
{{- end }}
427468
{{- end }}
428469
{{- end }}

kubernetes/charts/weblogic-operator/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,13 @@ clusterSizePaddingValidationEnabled: true
278278
# that will be allocated.
279279
#jvmOptions: -XshowSettings:vm -XX:MaxRAMPercentage=70
280280

281+
# operatorLogPVC specifies the PVC name for persistent storage for operator log files. You must also specify
282+
# operatorLogDir and operatorLogMount
283+
#operatorLogPVC:
284+
285+
# operatorLogDir specifies the operator logging directory. The operator will create the directory but the default uid
286+
# (oracle:1000) must have permission to do so. It must be prefixed by operatorLogMount.
287+
#operatorLogDir:
288+
289+
# operatorLogMount specifies the operator logging volumeMount. The operator will mount this path with the operatorLogPVC
290+
#operatorLogMount:

0 commit comments

Comments
 (0)