Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ArjunDandagi/cc51dbd8088d067c98c453083489083a to your computer and use it in GitHub Desktop.

Select an option

Save ArjunDandagi/cc51dbd8088d067c98c453083489083a to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-reverseproxy-config
data:
nginx.conf: |
events {}
http {
server {
listen 80;
# ================= HOMEPAGE =================
location = / {
default_type text/html;
return 200 '
<html>
<head>
<title>K8s Observability Gateway</title>
<style>
body { font-family: Arial; padding: 40px; background:#111; color:#eee; }
h1 { color:#00d4ff; }
ul { line-height: 2; }
a { color:#00ff99; text-decoration:none; font-size:18px; }
a:hover { text-decoration:underline; }
</style>
</head>
<body>
<h1>Cluster Services</h1>
<ul>
<li><a href="/grafana/">Grafana</a></li>
<li><a href="/prometheus/">Prometheus</a></li>
<li><a href="/kiali/">Kiali</a></li>
<li><a href="/jaeger/">Jaeger</a></li>
<li><a href="/zipkin/">Zipkin</a></li>
</ul>
</body>
</html>';
}
# ================= GRAFANA =================
location /grafana/ {
proxy_pass http://grafana:3000/;
proxy_redirect ~^/(.*)$ /grafana/$1;
sub_filter_once off;
sub_filter 'href="/' 'href="/grafana/';
sub_filter 'src="/' 'src="/grafana/';
}
# ================= PROMETHEUS =================
location /prometheus/ {
proxy_pass http://prometheus:9090/;
proxy_redirect ~^/(.*)$ /prometheus/$1;
sub_filter_once off;
sub_filter 'href="/' 'href="/prometheus/';
sub_filter 'src="/' 'src="/prometheus/';
}
# ================= KIALI =================
location /kiali/ {
proxy_pass http://kiali:20001/;
proxy_redirect ~^/(.*)$ /kiali/$1;
sub_filter_once off;
sub_filter 'href="/' 'href="/kiali/';
sub_filter 'src="/' 'src="/kiali/';
}
# ================= JAEGER =================
location /jaeger/ {
proxy_pass http://tracing:80/;
proxy_redirect ~^/(.*)$ /jaeger/$1;
sub_filter_once off;
sub_filter 'href="/' 'href="/jaeger/';
sub_filter 'src="/' 'src="/jaeger/';
}
# ================= ZIPKIN =================
location /zipkin/ {
proxy_pass http://zipkin:9411/;
proxy_redirect ~^/(.*)$ /zipkin/$1;
sub_filter_once off;
sub_filter 'href="/' 'href="/zipkin/';
sub_filter 'src="/' 'src="/zipkin/';
}
}
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-reverseproxy
spec:
replicas: 1
selector:
matchLabels:
app: nginx-reverseproxy
template:
metadata:
labels:
app: nginx-reverseproxy
spec:
containers:
- name: nginx
image: nginx:stable
ports:
- containerPort: 80
volumeMounts:
- name: config
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
volumes:
- name: config
configMap:
name: nginx-reverseproxy-config
---
apiVersion: v1
kind: Service
metadata:
name: nginx-reverseproxy
spec:
type: NodePort
selector:
app: nginx-reverseproxy
ports:
- port: 80
targetPort: 80
nodePort: 30080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment