Andy Bavier | f15d53a | 2018-03-07 17:34:30 -0700 | [diff] [blame] | 1 | {{/* vim: set filetype=mustache: */}} |
| 2 | {{/* |
| 3 | Copyright 2018-present Open Networking Foundation |
| 4 | |
| 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | you may not use this file except in compliance with the License. |
| 7 | You may obtain a copy of the License at |
| 8 | |
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | Unless required by applicable law or agreed to in writing, software |
| 12 | distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | See the License for the specific language governing permissions and |
| 15 | limitations under the License. |
| 16 | */}} |
| 17 | {{/* |
| 18 | Expand the name of the chart. |
| 19 | */}} |
| 20 | {{- define "onos.name" -}} |
| 21 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} |
| 22 | {{- end -}} |
| 23 | |
| 24 | {{/* |
| 25 | Create a default fully qualified app name. |
| 26 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 27 | If release name contains chart name it will be used as a full name. |
| 28 | */}} |
| 29 | {{- define "onos.fullname" -}} |
| 30 | {{- if .Values.fullnameOverride -}} |
| 31 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} |
| 32 | {{- else -}} |
| 33 | {{- $name := default .Chart.Name .Values.nameOverride -}} |
| 34 | {{- if contains $name .Release.Name -}} |
| 35 | {{- .Release.Name | trunc 63 | trimSuffix "-" -}} |
| 36 | {{- else -}} |
| 37 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} |
| 38 | {{- end -}} |
| 39 | {{- end -}} |
| 40 | {{- end -}} |
| 41 | |
| 42 | {{/* |
| 43 | Create chart name and version as used by the chart label. |
| 44 | */}} |
| 45 | {{- define "onos.chart" -}} |
| 46 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} |
| 47 | {{- end -}} |
Matteo Scandolo | 55ff150 | 2018-09-06 15:15:01 -0700 | [diff] [blame] | 48 | |
| 49 | {{- define "onos.logCfg" -}} |
| 50 | ################################################################################ |
| 51 | # |
| 52 | # Licensed to the Apache Software Foundation (ASF) under one or more |
| 53 | # contributor license agreements. See the NOTICE file distributed with |
| 54 | # this work for additional information regarding copyright ownership. |
| 55 | # The ASF licenses this file to You under the Apache License, Version 2.0 |
| 56 | # (the "License"); you may not use this file except in compliance with |
| 57 | # the License. You may obtain a copy of the License at |
| 58 | # |
| 59 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 60 | # |
| 61 | # Unless required by applicable law or agreed to in writing, software |
| 62 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 63 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 64 | # See the License for the specific language governing permissions and |
| 65 | # limitations under the License. |
| 66 | # |
| 67 | ################################################################################ |
| 68 | |
Daniele Moro | 0904738 | 2020-01-31 16:10:57 -0800 | [diff] [blame] | 69 | # Colors for log level rendering |
| 70 | color.fatal = bright red |
| 71 | color.error = bright red |
| 72 | color.warn = bright yellow |
| 73 | color.info = bright green |
| 74 | color.debug = cyan |
| 75 | color.trace = cyan |
Matteo Scandolo | 55ff150 | 2018-09-06 15:15:01 -0700 | [diff] [blame] | 76 | |
Daniele Moro | 0904738 | 2020-01-31 16:10:57 -0800 | [diff] [blame] | 77 | # Common pattern layout for appenders |
| 78 | log4j2.pattern = %d{ISO8601} | %-5p | %-16t | %-32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n |
| 79 | log4j2.out.pattern = \u001b[90m%d{HH:mm:ss\.SSS}\u001b[0m %highlight{%-5level}{FATAL=${color.fatal}, ERROR=${color.error}, WARN=${color.warn}, INFO=${color.info}, DEBUG=${color.debug}, TRACE=${color.trace}} \u001b[90m[%c{1}]\u001b[0m %msg%n%throwable |
Matteo Scandolo | 55ff150 | 2018-09-06 15:15:01 -0700 | [diff] [blame] | 80 | |
Daniele Moro | 0904738 | 2020-01-31 16:10:57 -0800 | [diff] [blame] | 81 | # Root logger configuration |
| 82 | log4j2.rootLogger.level = INFO |
| 83 | # uncomment to use asynchronous loggers, which require mvn:com.lmax/disruptor/3.3.2 library |
| 84 | #log4j2.rootLogger.type = asyncRoot |
| 85 | #log4j2.rootLogger.includeLocation = false |
| 86 | log4j2.rootLogger.appenderRef.RollingFile.ref = RollingFile |
| 87 | log4j2.rootLogger.appenderRef.Kafka.ref = Kafka |
| 88 | log4j2.rootLogger.appenderRef.PaxOsgi.ref = PaxOsgi |
| 89 | log4j2.rootLogger.appenderRef.Console.ref = Console |
| 90 | log4j2.rootLogger.appenderRef.Console.filter.regex.type = RegexFilter |
| 91 | log4j2.rootLogger.appenderRef.Console.filter.regex.regex = .*Audit.* |
| 92 | log4j2.rootLogger.appenderRef.Console.filter.regex.onMatch = DENY |
| 93 | log4j2.rootLogger.appenderRef.Console.filter.regex.onMismatch = ACCEPT |
| 94 | #log4j2.rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter |
| 95 | #log4j2.rootLogger.appenderRef.Console.filter.threshold.level = ${karaf.log.console:-OFF} |
Matteo Scandolo | 55ff150 | 2018-09-06 15:15:01 -0700 | [diff] [blame] | 96 | |
Daniele Moro | 0904738 | 2020-01-31 16:10:57 -0800 | [diff] [blame] | 97 | # Specific Loggers configuration |
Zack Williams | 7a506d2 | 2018-09-24 17:00:13 -0700 | [diff] [blame] | 98 | |
Daniele Moro | 0904738 | 2020-01-31 16:10:57 -0800 | [diff] [blame] | 99 | ## SSHD logger |
| 100 | log4j2.logger.sshd.name = org.apache.sshd |
| 101 | log4j2.logger.sshd.level = INFO |
| 102 | |
| 103 | ## Spifly logger |
| 104 | log4j2.logger.spifly.name = org.apache.aries.spifly |
| 105 | log4j2.logger.spifly.level = WARN |
| 106 | |
| 107 | ## Kafka logger to avoid recursive logging |
| 108 | log4j2.logger.apacheKafka.name = org.apache.kafka |
| 109 | log4j2.logger.apacheKafka.level = INFO |
| 110 | |
| 111 | # Appenders configuration |
| 112 | |
| 113 | ## Console appender not used by default (see log4j2.rootLogger.appenderRefs) |
| 114 | log4j2.appender.console.type = Console |
| 115 | log4j2.appender.console.name = Console |
| 116 | log4j2.appender.console.layout.type = PatternLayout |
| 117 | log4j2.appender.console.layout.pattern = ${log4j2.out.pattern} |
| 118 | |
| 119 | ## Rolling file appender |
| 120 | log4j2.appender.rolling.type = RollingRandomAccessFile |
| 121 | log4j2.appender.rolling.name = RollingFile |
| 122 | log4j2.appender.rolling.filter.regex.type = RegexFilter |
| 123 | log4j2.appender.rolling.filter.regex.regex = .*AuditLog.* |
| 124 | log4j2.appender.rolling.filter.regex.onMatch = DENY |
| 125 | log4j2.appender.rolling.filter.regex.onMismatch = ACCEPT |
| 126 | log4j2.appender.rolling.fileName = ${karaf.data}/log/karaf.log |
| 127 | log4j2.appender.rolling.filePattern = ${karaf.data}/log/karaf.log.%i |
| 128 | # uncomment to not force a disk flush |
| 129 | #log4j2.appender.rolling.immediateFlush = false |
| 130 | log4j2.appender.rolling.append = true |
| 131 | log4j2.appender.rolling.layout.type = PatternLayout |
| 132 | log4j2.appender.rolling.layout.pattern = ${log4j2.pattern} |
| 133 | log4j2.appender.rolling.rolling.type = DefaultRolloverStrategy |
| 134 | log4j2.appender.rolling.rolling.max = 10 |
| 135 | log4j2.appender.rolling.policies.type = Policies |
| 136 | log4j2.appender.rolling.policies.size.type = SizeBasedTriggeringPolicy |
| 137 | log4j2.appender.rolling.policies.size.size = 10MB |
| 138 | |
| 139 | ## OSGi appender |
| 140 | log4j2.appender.osgi.type = PaxOsgi |
| 141 | log4j2.appender.osgi.name = PaxOsgi |
| 142 | log4j2.appender.osgi.filter = * |
| 143 | |
| 144 | ## Kafka appender |
| 145 | log4j2.appender.kafka.type = Kafka |
| 146 | log4j2.appender.kafka.name = Kafka |
| 147 | log4j2.appender.kafka.property.type = Property |
| 148 | log4j2.appender.kafka.property.name = bootstrap.servers |
| 149 | log4j2.appender.kafka.property.value = {{- join "," .Values.kafka_logging.brokers }} |
| 150 | log4j2.appender.kafka.topic = onos.log |
| 151 | # Async send, no need to wait for Kafka ack for each record |
| 152 | log4j2.appender.kafka.syncSend = false |
| 153 | log4j2.kafka.pattern = {"@timestamp":"%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}","levelname":"%p","threadName":"%t","category":"%c{1}","bundle.id":"%X{bundle.id}","bundle.name":"%X{bundle.name}","bundle.version":"%X{bundle.version}","message":"%m"}%n |
| 154 | log4j2.appender.kafka.layout.type = PatternLayout |
| 155 | log4j2.appender.kafka.layout.pattern = ${log4j2.kafka.pattern} |
Matteo Scandolo | 55ff150 | 2018-09-06 15:15:01 -0700 | [diff] [blame] | 156 | |
| 157 | # Application logs |
Matteo Scandolo | 02112a9 | 2018-09-06 15:26:59 -0700 | [diff] [blame] | 158 | {{ .Values.application_logs }} |
Daniele Moro | 0904738 | 2020-01-31 16:10:57 -0800 | [diff] [blame] | 159 | |
Hyunsun Moon | 90c6050 | 2019-10-19 14:46:41 -0600 | [diff] [blame] | 160 | {{- end -}} |
Matteo Scandolo | 02112a9 | 2018-09-06 15:26:59 -0700 | [diff] [blame] | 161 | |
Hyunsun Moon | 90c6050 | 2019-10-19 14:46:41 -0600 | [diff] [blame] | 162 | {{/* |
| 163 | Render a Service. |
| 164 | */}} |
| 165 | {{- define "onos.service" -}} |
| 166 | {{- $name := index . 0 -}} |
| 167 | {{- $spec := index . 1 -}} |
| 168 | {{- $context := index . 2 -}} |
| 169 | {{- $namespace := $context.Release.Namespace }} |
| 170 | {{- $serviceName := printf "%s-%s" (include "onos.fullname" $context) $name }} |
| 171 | --- |
| 172 | apiVersion: v1 |
| 173 | kind: Service |
| 174 | metadata: |
| 175 | name: {{ $serviceName }} |
| 176 | namespace: {{ $namespace }} |
| 177 | labels: |
| 178 | app: {{ template "onos.name" $context }} |
| 179 | chart: {{ template "onos.chart" $context }} |
| 180 | release: {{ $context.Release.Name }} |
| 181 | heritage: {{ $context.Release.Service }} |
| 182 | spec: |
| 183 | type: {{ $spec.type }} |
| 184 | ports: |
| 185 | - name: {{ $name }} |
| 186 | port: {{ $spec.port }} |
| 187 | {{- if and $spec.type (eq (printf "%s" $spec.type) "NodePort") }} |
| 188 | nodePort: {{ $spec.nodePort }} |
| 189 | {{- end }} |
| 190 | selector: |
| 191 | app: {{ template "onos.name" $context }} |
| 192 | release: {{ $context.Release.Name }} |
Zack Williams | 7a506d2 | 2018-09-24 17:00:13 -0700 | [diff] [blame] | 193 | {{- end -}} |