Files
k3s-ansible/manifests/nginx-test-deployment.yaml
Michael Skrynski e1392b1584 Move test deployment manifests to the nginx-test namespace
- Update ConfigMap `nginx-test-html` to namespace `nginx-test`
- Move Deployment `nginx-test` to `nginx-test` namespace
- Move Service `nginx-test` to `nginx-test` namespace
- Move IngressRoute `nginx-test` to `nginx-test` namespace
2026-03-25 11:54:07 +01:00

253 lines
6.7 KiB
YAML

---
apiVersion: v1
kind: Namespace
metadata:
name: nginx-test
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-test-html
namespace: nginx-test
data:
index.html: |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>K3s Cluster - Nginx Test</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
padding: 40px;
max-width: 800px;
width: 100%;
}
h1 {
color: #333;
margin-bottom: 10px;
font-size: 2.5em;
text-align: center;
}
.subtitle {
color: #666;
text-align: center;
margin-bottom: 40px;
font-size: 1.2em;
}
.info-card {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
border-radius: 15px;
margin: 20px 0;
text-align: center;
}
.pod-name {
font-size: 2em;
font-weight: bold;
margin: 10px 0;
word-break: break-all;
}
.label {
font-size: 1.1em;
opacity: 0.9;
margin-bottom: 10px;
}
.stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin-top: 30px;
}
.stat-box {
background: #f8f9fa;
padding: 20px;
border-radius: 10px;
text-align: center;
}
.stat-label {
color: #666;
font-size: 0.9em;
margin-bottom: 5px;
}
.stat-value {
color: #333;
font-size: 1.3em;
font-weight: bold;
}
.emoji {
font-size: 3em;
margin-bottom: 10px;
}
.footer {
text-align: center;
margin-top: 30px;
color: #666;
font-size: 0.9em;
}
.success {
color: #28a745;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<div class="emoji">🚀</div>
<h1>K3s Cluster Running!</h1>
<p class="subtitle">Raspberry Pi Kubernetes Cluster</p>
<div class="info-card">
<div class="label">You are connected to pod:</div>
<div class="pod-name" id="podName">Loading...</div>
</div>
<div class="stats">
<div class="stat-box">
<div class="stat-label">Cluster Status</div>
<div class="stat-value success">✓ Operational</div>
</div>
<div class="stat-box">
<div class="stat-label">Ingress</div>
<div class="stat-value">Traefik</div>
</div>
<div class="stat-box">
<div class="stat-label">Load Balancer</div>
<div class="stat-value">Active</div>
</div>
</div>
<div class="footer">
<p>Deployed with Ansible on Raspberry Pi CM4/CM5</p>
<p style="margin-top: 10px;">Refresh the page to see different pods serve your request</p>
</div>
</div>
<script>
// Get hostname from browser (which is the pod name in Kubernetes)
fetch('/hostname.txt')
.then(response => response.text())
.then(data => {
document.getElementById('podName').textContent = data.trim();
})
.catch(() => {
// Fallback if hostname.txt doesn't exist
document.getElementById('podName').textContent = 'Pod ID: ' + Math.random().toString(36).substring(7);
});
</script>
</body>
</html>
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-test
namespace: nginx-test
labels:
app: nginx-test
spec:
replicas: 15
selector:
matchLabels:
app: nginx-test
template:
metadata:
labels:
app: nginx-test
spec:
containers:
- name: nginx
image: nginx:alpine
ports:
- containerPort: 80
name: http
resources:
requests:
memory: "64Mi"
cpu: "100m"
limits:
memory: "128Mi"
cpu: "200m"
volumeMounts:
- name: html
mountPath: /usr/share/nginx/html/index.html
subPath: index.html
- name: hostname
mountPath: /usr/share/nginx/html/hostname.txt
subPath: hostname
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 10
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 5
volumes:
- name: html
configMap:
name: nginx-test-html
- name: hostname
downwardAPI:
items:
- path: hostname
fieldRef:
fieldPath: metadata.name
---
apiVersion: v1
kind: Service
metadata:
name: nginx-test
namespace: nginx-test
labels:
app: nginx-test
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
selector:
app: nginx-test
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: nginx-test
namespace: nginx-test
spec:
entryPoints:
- websecure
routes:
- match: Host(`test.zlor.fi`)
kind: Rule
priority: 100
services:
- name: nginx-test
port: 80
tls:
certResolver: letsencrypt-cloudflare