Initial MEP server code
[ealt-edge.git] / mep / mepserver / kong-k8s.yaml
1 # Copyright 2020 Huawei Technologies Co., Ltd.
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.
14
15
16 # kong deployment
17 ---
18 apiVersion: apps/v1
19 kind: Deployment
20 metadata:
21   labels:
22     app: apigw-kong
23   name: apigw-kong
24   namespace: mep
25 spec:
26   replicas: 1
27   selector:
28     matchLabels:
29       app: apigw-kong
30   template:
31     metadata:
32       labels:
33         app: apigw-kong
34     spec:
35       initContainers:
36         - name: check-db-ready
37           image: postgres:9.6
38           command: ['sh', '-c', 'until pg_isready -h postgres-db -p 5432;
39                    do echo waiting for database; sleep 2; done;']
40       containers:
41         - name: kong-proxy
42           image: kong:1.5.1-alpine
43           env:
44             - name: KONG_DATABASE
45               value: "postgres"
46             - name: KONG_NGINX_WORKER_PROCESSES
47               value: "1"
48             - name: KONG_ADMIN_ACCESS_LOG
49               value: /dev/stdout
50             - name: KONG_ADMIN_ERROR_LOG
51               value: /dev/stderr
52             - name: KONG_ADMIN_ACCESS_LOG
53               value: /dev/stdout
54             - name: KONG_ADMIN_ERROR_LOG
55               value: /dev/stderr
56             - name: KONG_ADMIN_LISTEN
57               value: 127.0.0.1:8444 ssl
58             - name: KONG_PROXY_LISTEN
59               value: 0.0.0.0:8000, 0.0.0.0:8443 ssl http2
60             - name: KONG_ADMIN_LISTEN
61               value: 0.0.0.0:8001
62             - name: KONG_PG_DATABASE
63               value: kong
64             - name: KONG_PG_HOST
65               value: postgres-db
66             - name: KONG_PG_USER
67               value: kong
68             - name: KONG_PG_PASSWORD
69               value: kong
70           ports:
71             - containerPort: 8000
72               name: proxy
73               protocol: TCP
74             - containerPort: 8443
75               name: proxy-ssl
76               protocol: TCP
77             - containerPort: 8001
78               name: admin-api
79               protocol: TCP
80             - containerPort: 8444
81               name: admin-api-ssl
82               protocol: TCP
83           volumeMounts:
84             - name: kongssl
85               mountPath: "/run/kongssl"
86               readOnly: true
87           volumes:
88             - name: kongssl
89               secret:
90                 secretName: kongssl-secret
91
92
93 # kong service
94 ---
95 apiVersion: v1
96 kind: Service
97 metadata:
98   name: kong-service
99   namespace: mep
100 spec:
101   selector:
102     app: apigw-kong
103   type: NodePort
104   ports:
105     - port: 8000
106       name: proxy
107     - port: 8443
108       name: proxy-ssl
109     - port: 8001
110       name: admin-api
111     - port: 8444
112       name: admin-api-ssl