blob: 00dedecd53a519ab55f04cce4d958a874384c897 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
apiVersion: v1
kind: Template
metadata:
name: "amp-apicast-wildcard-router"
objects:
- apiVersion: v1
kind: DeploymentConfig
metadata:
name: apicast-router
spec:
replicas: 1
selector:
deploymentconfig: apicast-router
strategy:
type: Rolling
template:
metadata:
labels:
deploymentconfig: apicast-router
spec:
volumes:
- name: apicast-router-config
configMap:
name: apicast-router-config
items:
- key: router.conf
path: router.conf
containers:
- env:
- name: APICAST_CONFIGURATION_LOADER
value: "lazy"
- name: APICAST_CONFIGURATION_CACHE
value: "0"
image: 3scale-amp20/apicast-gateway:1.0-3
imagePullPolicy: IfNotPresent
name: apicast-router
command: ['bin/apicast']
livenessProbe:
tcpSocket:
port: router
initialDelaySeconds: 5
timeoutSeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /status/ready
port: management
initialDelaySeconds: 5
timeoutSeconds: 5
periodSeconds: 30
volumeMounts:
- name: apicast-router-config
mountPath: /opt/app-root/src/sites.d/
readOnly: true
ports:
- containerPort: 8082
name: router
protocol: TCP
- containerPort: 8090
name: management
protocol: TCP
triggers:
- type: ConfigChange
- apiVersion: v1
kind: Service
metadata:
name: apicast-router
spec:
ports:
- name: router
port: 80
protocol: TCP
targetPort: router
selector:
deploymentconfig: apicast-router
- apiVersion: v1
kind: ConfigMap
metadata:
name: apicast-router-config
data:
router.conf: |-
upstream wildcard {
server 0.0.0.1:1;
balancer_by_lua_block {
local round_robin = require 'resty.balancer.round_robin'
local balancer = round_robin.new()
local peers = balancer:peers(ngx.ctx.apicast)
local peer, err = balancer:set_peer(peers)
if not peer then
ngx.status = ngx.HTTP_SERVICE_UNAVAILABLE
ngx.log(ngx.ERR, "failed to set current backend peer: ", err)
ngx.exit(ngx.status)
end
}
keepalive 1024;
}
server {
listen 8082;
server_name ~-(?<apicast>apicast-(staging|production))\.;
access_log /dev/stdout combined;
location / {
access_by_lua_block {
local resolver = require('resty.resolver'):instance()
local servers = resolver:get_servers(ngx.var.apicast, { port = 8080 })
if #servers == 0 then
ngx.status = ngx.HTTP_BAD_GATEWAY
ngx.exit(ngx.HTTP_OK)
end
ngx.ctx.apicast = servers
}
proxy_http_version 1.1;
proxy_pass $scheme://wildcard;
proxy_set_header Host $host;
proxy_set_header Connection "";
}
}
- apiVersion: v1
kind: Route
metadata:
name: apicast-wildcard-router
labels:
app: apicast-wildcard-router
spec:
host: apicast-${TENANT_NAME}.${WILDCARD_DOMAIN}
to:
kind: Service
name: apicast-router
port:
targetPort: router
wildcardPolicy: Subdomain
tls:
termination: edge
insecureEdgeTerminationPolicy: Allow
parameters:
- name: AMP_RELEASE
description: "AMP release tag."
value: 2.0.0-CR2-redhat-1
required: true
- name: WILDCARD_DOMAIN
description: Root domain for the wildcard routes. Eg. example.com will generate 3scale-admin.example.com.
required: true
- name: TENANT_NAME
description: "Domain name under the root that Admin UI will be available with -admin suffix."
required: true
value: "3scale"
|