Files
wifi-densepose/k8s/service.yaml
2025-06-07 11:44:19 +00:00

225 lines
4.1 KiB
YAML

apiVersion: v1
kind: Service
metadata:
name: wifi-densepose-service
namespace: wifi-densepose
labels:
app: wifi-densepose
component: api
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
prometheus.io/path: "/metrics"
spec:
type: ClusterIP
ports:
- port: 8000
targetPort: 8000
protocol: TCP
name: http
- port: 8080
targetPort: 8080
protocol: TCP
name: metrics
selector:
app: wifi-densepose
component: api
sessionAffinity: None
---
apiVersion: v1
kind: Service
metadata:
name: postgres-service
namespace: wifi-densepose
labels:
app: wifi-densepose
component: postgres
spec:
type: ClusterIP
ports:
- port: 5432
targetPort: 5432
protocol: TCP
name: postgres
selector:
app: wifi-densepose
component: postgres
sessionAffinity: None
---
apiVersion: v1
kind: Service
metadata:
name: redis-service
namespace: wifi-densepose
labels:
app: wifi-densepose
component: redis
spec:
type: ClusterIP
ports:
- port: 6379
targetPort: 6379
protocol: TCP
name: redis
selector:
app: wifi-densepose
component: redis
sessionAffinity: None
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
namespace: wifi-densepose
labels:
app: wifi-densepose
component: nginx
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
- port: 443
targetPort: 443
protocol: TCP
name: https
selector:
app: wifi-densepose
component: nginx
sessionAffinity: None
loadBalancerSourceRanges:
- 0.0.0.0/0
---
# Headless service for StatefulSet (if needed for database clustering)
apiVersion: v1
kind: Service
metadata:
name: postgres-headless
namespace: wifi-densepose
labels:
app: wifi-densepose
component: postgres
spec:
type: ClusterIP
clusterIP: None
ports:
- port: 5432
targetPort: 5432
protocol: TCP
name: postgres
selector:
app: wifi-densepose
component: postgres
---
# Internal service for monitoring
apiVersion: v1
kind: Service
metadata:
name: wifi-densepose-internal
namespace: wifi-densepose
labels:
app: wifi-densepose
component: internal
spec:
type: ClusterIP
ports:
- port: 8080
targetPort: 8080
protocol: TCP
name: metrics
- port: 8000
targetPort: 8000
protocol: TCP
name: health
selector:
app: wifi-densepose
component: api
sessionAffinity: None
---
# Service for WebSocket connections
apiVersion: v1
kind: Service
metadata:
name: wifi-densepose-websocket
namespace: wifi-densepose
labels:
app: wifi-densepose
component: websocket
annotations:
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "tcp"
service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "3600"
spec:
type: LoadBalancer
ports:
- port: 8000
targetPort: 8000
protocol: TCP
name: websocket
selector:
app: wifi-densepose
component: api
sessionAffinity: ClientIP
sessionAffinityConfig:
clientIP:
timeoutSeconds: 3600
---
# Service Monitor for Prometheus (if using Prometheus Operator)
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: wifi-densepose-monitor
namespace: wifi-densepose
labels:
app: wifi-densepose
component: monitoring
spec:
selector:
matchLabels:
app: wifi-densepose
component: api
endpoints:
- port: metrics
interval: 30s
path: /metrics
scheme: http
- port: http
interval: 60s
path: /health
scheme: http
namespaceSelector:
matchNames:
- wifi-densepose
---
# Pod Monitor for additional pod-level metrics
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: wifi-densepose-pod-monitor
namespace: wifi-densepose
labels:
app: wifi-densepose
component: monitoring
spec:
selector:
matchLabels:
app: wifi-densepose
podMetricsEndpoints:
- port: metrics
interval: 30s
path: /metrics
- port: http
interval: 60s
path: /api/v1/status
namespaceSelector:
matchNames:
- wifi-densepose