Skip to content

Instantly share code, notes, and snippets.

@tonidy
Created September 13, 2025 07:12
Show Gist options
  • Save tonidy/ac86f22a318f548a1ef3dbf20c24aa90 to your computer and use it in GitHub Desktop.
Save tonidy/ac86f22a318f548a1ef3dbf20c24aa90 to your computer and use it in GitHub Desktop.
NGINX + index.html custom + Service + HTTPRoute
# 1) Buat NGINX + index.html custom + Service + HTTPRoute
cat <<'EOF' | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-index
namespace: default
data:
index.html: |
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Nginx over Cilium Gateway</title>
<style>
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; margin: 0; padding: 48px; background: #0b1220; color: #e5e7eb;}
.card { max-width: 720px; margin: auto; background: #111827; border-radius: 16px; padding: 32px; box-shadow: 0 10px 30px rgba(0,0,0,.25);}
h1 { margin: 0 0 8px; font-size: 28px; }
p { margin: 8px 0; color: #9ca3af; }
code { background:#0f172a; padding:2px 6px; border-radius:6px; }
</style>
</head>
<body>
<div class="card">
<h1>It works! 🚀</h1>
<p>Served by <strong>nginx</strong> behind <strong>Cilium Gateway API</strong> (NodePort mode).</p>
<p>Path: <code>/nginx</code></p>
</div>
</body>
</html>
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-gw
namespace: default
spec:
replicas: 1
selector:
matchLabels: { app: nginx-gw }
template:
metadata:
labels: { app: nginx-gw }
spec:
containers:
- name: nginx
image: nginx:1.25-alpine
ports:
- containerPort: 80
volumeMounts:
- name: web
mountPath: /usr/share/nginx/html/index.html
subPath: index.html
volumes:
- name: web
configMap:
name: nginx-index
items:
- key: index.html
path: index.html
---
apiVersion: v1
kind: Service
metadata:
name: nginx-gw
namespace: default
spec:
selector: { app: nginx-gw }
ports:
- name: http
port: 80
targetPort: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: nginx
namespace: default
spec:
parentRefs:
- name: web
namespace: default # sesuaikan kalau Gateway kamu beda namespace
rules:
- matches:
- path:
type: PathPrefix
value: /nginx
backendRefs:
- name: nginx-gw
port: 80
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment