blob: 01c7da2de2a61fec9a7fe6c04af72ddf22f12240 [file] [log] [blame]
David Bainbridge2f9b76f2019-05-15 13:48:11 -07001# Copyright 2019-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
David Bainbridgee5887072019-11-14 23:01:01 +000014{{- if not .Values.therecanbeonlyone }}
David Bainbridge2f9b76f2019-05-15 13:48:11 -070015{{- $root := . -}}
David Bainbridge03706e62019-10-18 17:59:24 +000016{{- $tag := tpl .Values.images.rw_core.tag . }}
David Bainbridgecd30e542019-05-31 20:52:56 +000017{{- $repository := tpl .Values.images.rw_core.repository . }}
18{{- $registry := tpl .Values.images.rw_core.registry . }}
19{{- $pullpolicy := tpl .Values.images.rw_core.pullPolicy . }}
20{{- $core_timeout := tpl $root.Values.rw_core.core_timeout . }}
21{{- $long_request_timeout := tpl $root.Values.rw_core.timeout_long_request . }}
22{{- $request_timeout := tpl $root.Values.rw_core.timeout_request . }}
David Bainbridge50cb1ef2019-07-23 22:36:17 +000023{{- $set_log_level := tpl .Values.rw_core.log_level . | upper }}
24{{- $log_level := 3 }}
25{{- if eq $set_log_level "DEBUG" }}
26{{- $log_level = 0 }}
27{{- else if eq $set_log_level "INFO" }}
28{{- $log_level = 1 }}
29{{- else if eq $set_log_level "WARN" }}
30{{- $log_level = 2 }}
31{{- else if eq $set_log_level "ERROR" }}
32{{- $log_level = 3 }}
33{{- else if eq $set_log_level "PANIC" }}
34{{- $log_level = 4 }}
35{{- else if eq $set_log_level "FATAL" }}
36{{- $log_level = 5 }}
37{{- else }}
38{{- $log_level = 3 }}
39{{- end }}
David Bainbridge03706e62019-10-18 17:59:24 +000040{{- /*
41 The conversion of the the recplicas.rw_core (number) to a string
42 and then back to an int is a work-a-round required for helm
43 v.2.15. It is currently considered a regression bug in helm
44 (https://github.com/helm/helm/issues/6708). The need for this
45 work-a-round should be re-checked against helm occationally and
46 removed if no longer needed.
47*/ -}}
48{{- range $i, $e := until (int (toString .Values.replicas.rw_core)) }}
Kent Hagerman1b333b92019-07-22 16:57:20 -040049{{- $cluster := add1 $i }}
50{{- range $i, $e := until 2 }}
51{{- $cluster_core_id := add1 $i }}
52---
53apiVersion: v1
54kind: Service
55metadata:
56 name: voltha-rw-core-{{ $cluster }}{{ $cluster_core_id }}
57 serviceAccountName: {{ $root.Values.serviceaccount }}
58spec:
59 serviceAccountName: {{ $root.Values.serviceaccount }}
60 clusterIP: None
61 ports:
62 - name: grpc
63 port: 50057
64 targetPort: 50057
65 selector:
66 app: rw-core
67 affinity-group: {{ quote $cluster }}
68 affinity-group-core-id: {{ quote $cluster_core_id }}
69
David Bainbridge2f9b76f2019-05-15 13:48:11 -070070---
71apiVersion: apps/v1
72kind: Deployment
73metadata:
Kent Hagerman1b333b92019-07-22 16:57:20 -040074 name: voltha-rw-core-{{ $cluster }}{{ $cluster_core_id }}
David Bainbridge2f9b76f2019-05-15 13:48:11 -070075 serviceAccountName: {{ $root.Values.serviceaccount }}
David Bainbridge534a73d2019-08-30 18:57:23 +000076 {{- if or (hasKey $root.Values "extra_deployment_labels") (hasKey $root.Values "rw_core_deployment_labels") }}
77 labels:
78 {{- if hasKey $root.Values "extra_deployment_labels" }}
79 {{- range $key, $val := $root.Values.extra_deployment_labels }}
80 {{ $key }}: {{ $val | quote }}
81 {{- end }}
82 {{- end }}
83 {{- if hasKey $root.Values "rw_core_deployment_labels" }}
84 {{- range $key, $val := $root.Values.rw_core_deployment_labels }}
85 {{ $key }}: {{ $val | quote }}
86 {{- end }}
87 {{- end }}
88 {{- end }}
David Bainbridge2f9b76f2019-05-15 13:48:11 -070089spec:
90 replicas: 1
91 selector:
92 matchLabels:
93 app: rw-core
Kent Hagerman1b333b92019-07-22 16:57:20 -040094 affinity-group: {{ quote $cluster }}
95 affinity-group-core-id: {{ quote $cluster_core_id }}
David Bainbridge2f9b76f2019-05-15 13:48:11 -070096 template:
97 metadata:
98 labels:
99 app: rw-core
Kent Hagerman1b333b92019-07-22 16:57:20 -0400100 affinity-group: {{ quote $cluster }}
101 affinity-group-core-id: {{ quote $cluster_core_id }}
David Bainbridge1f888042019-06-24 18:02:01 +0000102 app.kubernetes.io/name: "read-write-core"
103 app.kubernetes.io/version: {{ quote $root.Chart.AppVersion }}
104 app.kubernetes.io/component: "core"
105 app.kubernetes.io/part-of: "voltha"
106 app.kubernetes.io/managed-by: {{ quote $root.Release.Service }}
107 helm.sh/chart: "{{ $root.Chart.Name }}-{{ $root.Chart.Version }}"
David Bainbridge534a73d2019-08-30 18:57:23 +0000108 {{- if hasKey $root.Values "extra_pod_labels" }}
109 {{- range $key, $val := $root.Values.extra_pod_labels }}
110 {{ $key }}: {{ $val | quote }}
111 {{- end }}
112 {{- end }}
113 {{- if hasKey $root.Values "rw_core_pod_labels" }}
114 {{- range $key, $val := $root.Values.rw_core_pod_labels }}
115 {{ $key }}: {{ $val | quote }}
116 {{- end }}
117 {{- end }}
David Bainbridge2f9b76f2019-05-15 13:48:11 -0700118 annotations:
119 cni: "calico"
120 spec:
121 affinity:
122 podAntiAffinity:
Kent Hagerman1b333b92019-07-22 16:57:20 -0400123 requiredDuringSchedulingIgnoredDuringExecution:
124 - topologyKey: "kubernetes.io/hostname"
David Bainbridge53af8ba2019-05-24 14:41:34 +0000125 labelSelector:
126 matchExpressions:
127 - key: app
128 operator: In
129 values:
Kent Hagerman1b333b92019-07-22 16:57:20 -0400130 - rw-core
131 - key: affinity-group
132 operator: In
133 values:
134 - {{ quote $cluster }}
David Bainbridge2f9b76f2019-05-15 13:48:11 -0700135 serviceAccountName: {{ $root.Values.serviceaccount }}
136 containers:
137 - name: voltha
David Bainbridge03706e62019-10-18 17:59:24 +0000138 image: '{{ $registry }}{{ $repository }}:{{ $tag }}'
David Bainbridgecd30e542019-05-31 20:52:56 +0000139 imagePullPolicy: {{ $pullpolicy }}
David Bainbridge2f9b76f2019-05-15 13:48:11 -0700140 env:
141 - name: NAMESPACE
142 value: {{ quote $root.Release.Namespace }}
143 - name: POD_IP
144 valueFrom:
145 fieldRef:
146 fieldPath: status.podIP
David Bainbridge2f9b76f2019-05-15 13:48:11 -0700147 args:
148 - "/app/rw_core"
149 - "-kv_store_type=etcd"
David Bainbridgecd30e542019-05-31 20:52:56 +0000150 - "-kv_store_host={{ $root.Values.services.etcd.service }}"
151 - "-kv_store_port={{ $root.Values.services.etcd.port }}"
David Bainbridge2f9b76f2019-05-15 13:48:11 -0700152 - "-grpc_host=$(POD_IP)"
153 - "-grpc_port=50057"
154 - "-banner=true"
David Bainbridgecd30e542019-05-31 20:52:56 +0000155 - "-kafka_adapter_host={{ $root.Values.services.kafka.adapter.service }}"
156 - "-kafka_adapter_port={{ $root.Values.services.kafka.adapter.port }}"
157 - "-kafka_cluster_host={{ $root.Values.services.kafka.cluster.port }}"
158 - "-kafka_cluster_port={{ $root.Values.services.kafka.cluster.port }}"
David Bainbridge2f9b76f2019-05-15 13:48:11 -0700159 - "-rw_core_topic=rwcore"
Kent Hagermanb778da82019-07-30 15:14:20 -0400160 - "-core_pair_topic=core-pair-{{ $cluster }}"
David Bainbridge2f9b76f2019-05-15 13:48:11 -0700161 - "-kv_store_data_prefix=service/voltha"
162 - "-in_competing_mode=true"
David Bainbridgecd30e542019-05-31 20:52:56 +0000163 - "-core_timeout={{ $core_timeout }}"
164 - "-timeout_long_request={{ $long_request_timeout }}"
165 - "-timeout_request={{ $request_timeout }}"
David Bainbridge50cb1ef2019-07-23 22:36:17 +0000166 - "-log_level={{ $log_level }}"
David Bainbridgec349f642019-09-24 19:20:47 +0000167 - "-probe_port=8080"
David Bainbridge2f9b76f2019-05-15 13:48:11 -0700168 ports:
169 - containerPort: 50057
170 name: grpc-port
David Bainbridgec349f642019-09-24 19:20:47 +0000171 livenessProbe:
172 httpGet:
173 path: /healthz
174 port: 8080
175 initialDelaySeconds: 3
176 periodSeconds: 3
177 readinessProbe:
178 httpGet:
179 path: /readz
180 port: 8080
181 initialDelaySeconds: 3
182 periodSeconds: 3
David Bainbridgee5887072019-11-14 23:01:01 +0000183{{- end }}
184{{- end }}
185{{- end }}