kube/camtiler/application.yml

731 lines
19 KiB
YAML
Raw Normal View History

---
2022-08-16 09:40:54 +00:00
apiVersion: apps/v1
kind: Deployment
metadata:
2022-12-12 18:37:03 +00:00
name: camera-tiler
2022-08-16 09:40:54 +00:00
annotations:
keel.sh/policy: force
keel.sh/trigger: poll
spec:
revisionHistoryLimit: 0
2022-08-28 21:00:46 +00:00
replicas: 2
2022-08-16 09:40:54 +00:00
selector:
2022-12-12 18:37:03 +00:00
matchLabels: &selectorLabels
2022-09-11 13:24:35 +00:00
app.kubernetes.io/name: camtiler
2022-12-12 18:37:03 +00:00
component: camera-tiler
2022-08-16 09:40:54 +00:00
template:
metadata:
2022-12-12 18:37:03 +00:00
labels: *selectorLabels
2022-08-16 09:40:54 +00:00
spec:
2022-12-12 18:37:03 +00:00
serviceAccountName: camera-tiler
2022-08-16 09:40:54 +00:00
containers:
2022-12-12 18:37:03 +00:00
- name: camera-tiler
2022-08-16 09:40:54 +00:00
image: harbor.k-space.ee/k-space/camera-tiler:latest
securityContext:
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
2022-09-11 13:24:35 +00:00
ports:
2022-09-12 04:27:32 +00:00
- containerPort: 5001
2022-09-11 13:24:35 +00:00
name: "http"
2022-12-12 18:37:03 +00:00
resources:
requests:
memory: "200Mi"
cpu: "100m"
limits:
memory: "500Mi"
cpu: "1"
2022-08-16 09:40:54 +00:00
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: logmower-frontend
2022-08-16 09:40:54 +00:00
spec:
selector:
matchLabels:
app: logmower-frontend
2022-08-16 09:40:54 +00:00
template:
metadata:
labels:
app: logmower-frontend
2022-08-16 09:40:54 +00:00
spec:
containers:
- name: logmower-frontend
image: harbor.k-space.ee/k-space/logmower-frontend
ports:
- containerPort: 8080
name: http
2022-08-16 09:40:54 +00:00
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: logmower-eventsource
2022-08-16 09:40:54 +00:00
spec:
selector:
matchLabels:
app: logmower-eventsource
2022-08-16 09:40:54 +00:00
template:
metadata:
labels:
app: logmower-eventsource
2022-08-16 09:40:54 +00:00
spec:
containers:
- name: logmower-eventsource
image: harbor.k-space.ee/k-space/logmower-eventsource
ports:
- containerPort: 3002
name: nodejs
2022-08-16 09:40:54 +00:00
env:
- name: MONGODB_HOST
2022-08-16 09:40:54 +00:00
valueFrom:
secretKeyRef:
name: mongodb-application-readonly
2022-08-16 09:40:54 +00:00
key: connectionString.standard
- name: BACKEND
value: 'camtiler'
- name: BACKEND_BROKER_URL
value: 'http://camera-event-broker'
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: camera-event-broker
spec:
selector:
matchLabels:
app: camera-event-broker
template:
metadata:
labels:
app: camera-event-broker
spec:
containers:
- name: camera-event-broker
2022-12-13 10:51:52 +00:00
image: harbor.k-space.ee/k-space/camera-event-broker
ports:
- containerPort: 3000
env:
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: minio-secrets
key: MINIO_ROOT_PASSWORD
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: minio-secrets
key: MINIO_ROOT_USER
2022-08-16 09:40:54 +00:00
- name: MINIO_BUCKET
value: 'application'
2022-08-16 09:40:54 +00:00
- name: MINIO_HOSTNAME
value: 'cams-s3.k-space.ee'
2022-08-16 09:40:54 +00:00
- name: MINIO_PORT
value: '443'
- name: MINIO_SCHEMA
value: 'https'
2022-08-16 09:40:54 +00:00
---
apiVersion: v1
kind: Service
metadata:
name: logmower-frontend
2022-08-16 09:40:54 +00:00
spec:
type: ClusterIP
selector:
app: logmower-frontend
2022-08-16 09:40:54 +00:00
ports:
- protocol: TCP
port: 8080
2022-08-16 09:40:54 +00:00
---
apiVersion: v1
kind: Service
metadata:
name: logmower-eventsource
2022-08-16 09:40:54 +00:00
spec:
type: ClusterIP
selector:
app: logmower-eventsource
2022-08-16 09:40:54 +00:00
ports:
- protocol: TCP
port: 3002
2022-08-16 09:40:54 +00:00
---
apiVersion: v1
kind: Service
metadata:
name: camera-event-broker
spec:
type: ClusterIP
selector:
app: camera-event-broker
ports:
- protocol: TCP
port: 80
targetPort: 3000
---
apiVersion: v1
kind: Service
2022-08-16 09:40:54 +00:00
metadata:
2022-12-12 18:37:03 +00:00
name: camera-tiler
2022-08-16 09:40:54 +00:00
labels:
2022-12-12 18:37:03 +00:00
app.kubernetes.io/name: camtiler
component: camera-tiler
2022-08-16 09:40:54 +00:00
spec:
type: ClusterIP
selector:
2022-09-11 13:24:35 +00:00
app.kubernetes.io/name: camtiler
2022-12-12 18:37:03 +00:00
component: camera-tiler
2022-08-16 09:40:54 +00:00
ports:
- protocol: TCP
port: 5001
2022-08-16 09:40:54 +00:00
---
apiVersion: v1
kind: ServiceAccount
metadata:
2022-12-12 18:37:03 +00:00
name: camera-tiler
2022-08-16 09:40:54 +00:00
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
2022-12-12 18:37:03 +00:00
name: camera-tiler
2022-08-16 09:40:54 +00:00
rules:
- apiGroups:
- ""
resources:
- services
verbs:
- list
2022-08-16 09:40:54 +00:00
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
2022-12-12 18:37:03 +00:00
name: camera-tiler
2022-08-16 09:40:54 +00:00
subjects:
- kind: ServiceAccount
2022-12-12 18:37:03 +00:00
name: camera-tiler
apiGroup: ""
2022-08-16 09:40:54 +00:00
roleRef:
kind: Role
2022-12-12 18:37:03 +00:00
name: camera-tiler
2022-08-16 09:40:54 +00:00
apiGroup: ""
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: camtiler
annotations:
kubernetes.io/ingress.class: traefik
# This tells Traefik this Ingress object is associated with the
# https:// entrypoint
# Global http:// to https:// redirect is enabled in
# ../traefik/values.yml using `globalArguments`
traefik.ingress.kubernetes.io/router.entrypoints: websecure
# Following enables Authelia intercepting middleware
# which makes sure user is authenticated and then
# proceeds to inject Remote-User header for the application
traefik.ingress.kubernetes.io/router.middlewares: traefik-sso@kubernetescrd
traefik.ingress.kubernetes.io/router.tls: "true"
# Following tells external-dns to add CNAME entry which makes
# cams.k-space.ee point to same IP address as traefik.k-space.ee
# The A record for traefik.k-space.ee is created via annotation
# added in ../traefik/ingress.yml
external-dns.alpha.kubernetes.io/target: traefik.k-space.ee
spec:
rules:
- host: cams.k-space.ee
http:
paths:
- pathType: Prefix
path: "/tiled"
backend:
service:
2022-12-12 18:37:03 +00:00
name: camera-tiler
port:
number: 5001
- pathType: Prefix
path: "/events"
backend:
service:
name: logmower-eventsource
port:
number: 3002
- pathType: Prefix
path: "/"
backend:
service:
name: logmower-frontend
port:
number: 8080
2022-08-16 09:40:54 +00:00
tls:
- hosts:
- "*.k-space.ee"
2022-08-16 09:40:54 +00:00
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: camera-motion-detect
spec:
podSelector:
matchLabels:
2022-12-12 18:37:03 +00:00
component: camera-motion-detect
2022-08-16 09:40:54 +00:00
policyTypes:
- Ingress
- Egress
2022-08-16 09:40:54 +00:00
ingress:
- from:
- podSelector:
matchLabels:
2022-12-12 18:37:03 +00:00
app.kubernetes.io/name: camtiler
component: camera-tiler
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: prometheus-operator
podSelector:
matchLabels:
app.kubernetes.io/name: prometheus
2022-08-16 09:40:54 +00:00
egress:
- to:
- ipBlock:
# Permit access to cameras outside the cluster
cidr: 100.102.0.0/16
- to:
- podSelector:
matchLabels:
app: mongodb-svc
2022-08-16 09:40:54 +00:00
ports:
- port: 27017
2022-08-16 09:40:54 +00:00
- to:
- podSelector:
matchLabels:
2022-12-12 18:37:03 +00:00
app.kubernetes.io/name: minio
2022-08-16 09:40:54 +00:00
ports:
- port: 9000
2022-08-16 09:40:54 +00:00
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: camera-tiler
spec:
podSelector:
matchLabels:
2022-12-12 18:37:03 +00:00
app.kubernetes.io/name: camtiler
component: camera-tiler
2022-08-16 09:40:54 +00:00
policyTypes:
- Ingress
- Egress
2022-08-16 09:40:54 +00:00
egress:
- to:
- podSelector:
matchLabels:
2022-12-12 18:37:03 +00:00
component: camera-motion-detect
ports:
- port: 5000
2022-08-16 09:40:54 +00:00
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: prometheus-operator
podSelector:
matchLabels:
app.kubernetes.io/name: prometheus
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: traefik
podSelector:
matchLabels:
app.kubernetes.io/name: traefik
2022-08-16 09:40:54 +00:00
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: log-viewer-backend
spec:
podSelector:
matchLabels:
2022-12-12 18:37:03 +00:00
app.kubernetes.io/name: camtiler
component: log-viewer-backend
2022-08-16 09:40:54 +00:00
policyTypes:
- Ingress
- Egress
2022-08-16 09:40:54 +00:00
egress:
- to:
- podSelector:
matchLabels:
app: mongodb-svc
2022-08-16 09:40:54 +00:00
- to:
# Minio access via Traefik's public endpoint
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: traefik
podSelector:
matchLabels:
app.kubernetes.io/name: traefik
2022-08-16 09:40:54 +00:00
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: traefik
podSelector:
matchLabels:
app.kubernetes.io/name: traefik
2022-08-16 09:40:54 +00:00
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: log-viewer-frontend
spec:
podSelector:
matchLabels:
2022-12-12 18:37:03 +00:00
app.kubernetes.io/name: camtiler
component: log-viewer-frontend
2022-08-16 09:40:54 +00:00
policyTypes:
- Ingress
- Egress
2022-08-16 09:40:54 +00:00
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: traefik
podSelector:
matchLabels:
app.kubernetes.io/name: traefik
2022-08-16 09:40:54 +00:00
---
2022-08-28 21:00:46 +00:00
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: cams.k-space.ee
2022-08-28 21:00:46 +00:00
spec:
group: k-space.ee
names:
plural: cams
singular: cam
kind: Camera
shortNames:
- cam
scope: Namespaced
versions:
- name: v1alpha1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
roi:
type: object
description: Region of interest for this camera
properties:
threshold:
type: integer
description: Percentage of pixels changed within ROI to
consider whole frame to have motion detected.
Defaults to 5.
enabled:
type: boolean
description: Whether motion detection is enabled for this
camera. Defaults to false.
left:
type: integer
description: Left boundary of ROI as
percentage of the width of a frame.
By default 0.
right:
type: integer
description: Right boundary of ROI as
percentage of the width of a frame.
By default 100.
top:
type: integer
description: Top boundary of ROI as
percentage of the height of a frame
By deafault 0.
bottom:
type: integer
description: Bottom boundary of ROI as
percentage of the height of a frame.
By default 100.
secretRef:
type: string
description: Secret that contains authentication credentials
target:
type: string
description: URL of the video feed stream
replicas:
type: integer
minimum: 1
maximum: 2
description: For highly available deployment set this to 2 or
higher. Make sure you also run Mongo and Minio in HA
configurations
required: ["target"]
required: ["spec"]
2022-08-28 21:00:46 +00:00
---
apiVersion: codemowers.io/v1alpha1
kind: ClusterOperator
metadata:
name: camera
spec:
resource:
group: k-space.ee
version: v1alpha1
plural: cams
secret:
enabled: false
services:
- apiVersion: v1
kind: Service
metadata:
name: foobar
labels:
2022-12-12 18:37:03 +00:00
app.kubernetes.io/name: foobar
component: camera-motion-detect
2022-08-28 21:00:46 +00:00
spec:
type: ClusterIP
selector:
2022-09-11 13:24:35 +00:00
app.kubernetes.io/name: foobar
2022-12-12 18:37:03 +00:00
component: camera-motion-detect
2022-08-28 21:00:46 +00:00
ports:
- protocol: TCP
port: 80
targetPort: 5000
2022-08-28 21:00:46 +00:00
deployments:
- apiVersion: apps/v1
kind: Deployment
metadata:
name: camera-foobar
# Make sure keel.sh pulls updates for this deployment
annotations:
keel.sh/policy: force
keel.sh/trigger: poll
spec:
replicas: 1
# Make sure we do not congest the network during rollout
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
selector:
matchLabels:
2022-09-11 13:24:35 +00:00
app.kubernetes.io/name: foobar
2022-08-28 21:00:46 +00:00
template:
metadata:
labels:
2022-09-11 13:24:35 +00:00
app.kubernetes.io/name: foobar
2022-12-12 18:37:03 +00:00
component: camera-motion-detect
2022-08-28 21:00:46 +00:00
spec:
containers:
2022-12-12 18:37:03 +00:00
- name: camera-motion-detect
2022-08-28 21:00:46 +00:00
image: harbor.k-space.ee/k-space/camera-motion-detect:latest
2022-12-12 18:37:03 +00:00
starupProbe:
2022-08-28 21:00:46 +00:00
httpGet:
2022-12-12 18:37:03 +00:00
path: /healthz
2022-08-28 21:00:46 +00:00
port: 5000
2022-12-12 18:37:03 +00:00
initialDelaySeconds: 2
2022-08-28 21:00:46 +00:00
periodSeconds: 180
timeoutSeconds: 60
2022-12-12 18:37:03 +00:00
readinessProbe:
httpGet:
path: /readyz
port: 5000
initialDelaySeconds: 60
periodSeconds: 60
timeoutSeconds: 5
2022-08-28 21:00:46 +00:00
ports:
- containerPort: 5000
name: "http"
2022-08-28 21:00:46 +00:00
resources:
requests:
memory: "64Mi"
cpu: "200m"
limits:
memory: "256Mi"
2022-08-28 21:00:46 +00:00
cpu: "1"
securityContext:
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
command:
- /app/camdetect.py
- http://user@foobar.cam.k-space.ee:8080/?action=stream
env:
- name: SOURCE_NAME
value: foobar
- name: S3_BUCKET_NAME
value: application
- name: S3_ENDPOINT_URL
value: http://minio
- name: BASIC_AUTH_PASSWORD
valueFrom:
secretKeyRef:
name: camera-secrets
key: password
- name: MONGO_URI
valueFrom:
secretKeyRef:
name: mongodb-application-readwrite
key: connectionString.standard
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
2022-12-12 18:37:03 +00:00
name: minio-secrets
key: MINIO_ROOT_PASSWORD
2022-08-28 21:00:46 +00:00
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
2022-12-12 18:37:03 +00:00
name: minio-secrets
key: MINIO_ROOT_USER
2022-08-28 21:00:46 +00:00
# Make sure 2+ pods of same camera are scheduled on different hosts
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- foobar
topologyKey: kubernetes.io/hostname
# Make sure camera deployments are spread over workers
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app.kubernetes.io/name: foobar
2022-12-12 18:37:03 +00:00
component: camera-motion-detect
2022-08-28 21:00:46 +00:00
---
2022-09-11 13:24:35 +00:00
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: camtiler
spec:
selector: {}
podMetricsEndpoints:
- port: http
podTargetLabels:
- app.kubernetes.io/name
2022-12-12 18:37:03 +00:00
- component
2022-09-11 13:24:35 +00:00
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: cameras
spec:
groups:
2022-09-11 13:24:35 +00:00
- name: cameras
rules:
- alert: CameraLost
2022-12-12 18:37:03 +00:00
expr: rate(camtiler_frames_total{stage="downloaded"}[1m]) < 1
for: 2m
labels:
severity: warning
annotations:
summary: Camera feed stopped
- alert: CameraServerRoomMotion
2022-12-12 18:37:03 +00:00
expr: rate(camtiler_events_total{app_kubernetes_io_name="server-room"}[30m]) > 0
for: 1m
labels:
severity: warning
annotations:
summary: Motion was detected in server room
- alert: CameraSlowUploads
2022-12-12 18:37:03 +00:00
expr: camtiler_queue_frames{stage="upload"} > 10
for: 5m
labels:
severity: warning
annotations:
summary: Motion detect snapshots are piling up and
not getting uploaded to S3
- alert: CameraSlowProcessing
2022-12-12 18:37:03 +00:00
expr: camtiler_queue_frames{stage="download"} > 10
for: 5m
labels:
severity: warning
annotations:
summary: Motion detection processing pipeline is not keeping up
with incoming frames
2022-09-11 13:24:35 +00:00
---
2022-08-28 21:00:46 +00:00
apiVersion: k-space.ee/v1alpha1
kind: Camera
metadata:
name: workshop
spec:
target: http://user@workshop.cam.k-space.ee:8080/?action=stream
secretRef: camera-secrets
2022-12-12 18:37:03 +00:00
replicas: 2
2022-08-28 21:00:46 +00:00
---
apiVersion: k-space.ee/v1alpha1
kind: Camera
metadata:
name: server-room
spec:
target: http://user@server-room.cam.k-space.ee:8080/?action=stream
secretRef: camera-secrets
2022-12-12 18:37:03 +00:00
replicas: 2
2022-08-28 21:00:46 +00:00
---
apiVersion: k-space.ee/v1alpha1
kind: Camera
metadata:
name: printer
spec:
target: http://user@printer.cam.k-space.ee:8080/?action=stream
secretRef: camera-secrets
2022-12-12 18:37:03 +00:00
replicas: 2
2022-08-28 21:00:46 +00:00
---
apiVersion: k-space.ee/v1alpha1
kind: Camera
metadata:
name: chaos
spec:
target: http://user@chaos.cam.k-space.ee:8080/?action=stream
secretRef: camera-secrets
2022-12-12 18:37:03 +00:00
replicas: 2
2022-08-28 21:00:46 +00:00
---
apiVersion: k-space.ee/v1alpha1
kind: Camera
metadata:
name: cyber
spec:
target: http://user@cyber.cam.k-space.ee:8080/?action=stream
secretRef: camera-secrets
2022-12-12 18:37:03 +00:00
replicas: 2
2022-08-28 21:00:46 +00:00
---
apiVersion: k-space.ee/v1alpha1
kind: Camera
metadata:
name: kitchen
spec:
target: http://user@kitchen.cam.k-space.ee:8080/?action=stream
secretRef: camera-secrets
2022-12-12 18:37:03 +00:00
replicas: 2
2022-08-28 21:00:46 +00:00
---
apiVersion: k-space.ee/v1alpha1
kind: Camera
metadata:
name: back-door
spec:
target: http://user@back-door.cam.k-space.ee:8080/?action=stream
secretRef: camera-secrets
2022-12-12 18:37:03 +00:00
replicas: 2
2022-08-28 21:00:46 +00:00
---
apiVersion: k-space.ee/v1alpha1
kind: Camera
metadata:
name: ground-door
spec:
target: http://user@ground-door.cam.k-space.ee:8080/?action=stream
secretRef: camera-secrets
2022-12-12 18:37:03 +00:00
replicas: 2