-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapisix-dashboard-embed.yaml
More file actions
130 lines (127 loc) · 3.93 KB
/
Copy pathapisix-dashboard-embed.yaml
File metadata and controls
130 lines (127 loc) · 3.93 KB
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
# Grafana-embeddable front for the APISIX dashboard.
#
# WHY THIS EXISTS
# The apisix-dashboard app (3.0.0) hard-codes restrictive security headers:
# X-Frame-Options: deny
# Content-Security-Policy: default-src 'self'
# These block its own "embed Grafana URL" feature from loading
# https://monitor.wisefood.gr in an iframe. The headers cannot be changed in the
# app, and we are deliberately NOT enabling ingress-nginx configuration-snippets
# (cluster-wide raw-config injection) nor editing the live cluster ingress.
#
# Instead this adds a small nginx reverse-proxy in front of the dashboard that
# rewrites those two headers, and a replacement ingress for apisix.wisefood.gr
# that routes to the proxy. Everything here is scoped to the `apisix` namespace.
#
# APPLY (your call — nothing here is applied automatically):
# kubectl apply -f apisix-dashboard-embed.yaml
# This REPLACES the existing apisix-dashboard ingress object (same name/host).
# Grafana must already allow embedding (allow_embedding=true, cookie_samesite=none
# — see grafana-config.yaml).
#
# ROLLBACK:
# kubectl delete -f apisix-dashboard-embed.yaml
# then re-apply your original apisix-dashboard ingress.
---
apiVersion: v1
kind: ConfigMap
metadata:
name: apisix-dashboard-proxy
namespace: apisix
data:
default.conf: |
server {
listen 8080;
server_name _;
location / {
proxy_pass http://apisix-dashboard.apisix.svc.cluster.local:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Drop the dashboard app's restrictive headers...
proxy_hide_header X-Frame-Options;
proxy_hide_header Content-Security-Policy;
# ...and replace with a policy that permits framing Grafana only.
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; frame-src 'self' https://monitor.wisefood.gr; frame-ancestors 'self'" always;
}
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: apisix-dashboard-proxy
namespace: apisix
labels:
app.kubernetes.io/name: apisix-dashboard-proxy
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: apisix-dashboard-proxy
template:
metadata:
labels:
app.kubernetes.io/name: apisix-dashboard-proxy
spec:
containers:
- name: nginx
image: nginx:1.27-alpine
ports:
- name: http
containerPort: 8080
volumeMounts:
- name: conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
readOnly: true
readinessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 3
periodSeconds: 10
volumes:
- name: conf
configMap:
name: apisix-dashboard-proxy
---
apiVersion: v1
kind: Service
metadata:
name: apisix-dashboard-proxy
namespace: apisix
spec:
selector:
app.kubernetes.io/name: apisix-dashboard-proxy
ports:
- name: http
port: 80
targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: apisix-dashboard
namespace: apisix
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/proxy-body-size: 50m
spec:
ingressClassName: nginx
tls:
- hosts:
- apisix.wisefood.gr
secretName: apisix-dashboard-tls
rules:
- host: apisix.wisefood.gr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: apisix-dashboard-proxy
port:
number: 80