docs: camtiler & doors
This commit is contained in:
		@@ -1,5 +1,7 @@
 | 
			
		||||
# ansible doors -m shell -a "ctr image pull harbor.k-space.ee/k-space/mjpg-streamer:latest"
 | 
			
		||||
# journalctl -u mjpg_streamer@video0.service -f
 | 
			
		||||
 | 
			
		||||
# Referenced and documented by https://wiki.k-space.ee/en/hosting/doors
 | 
			
		||||
- name: Setup doors
 | 
			
		||||
  hosts: doors
 | 
			
		||||
  tasks:
 | 
			
		||||
@@ -8,7 +10,7 @@
 | 
			
		||||
      name: containerd
 | 
			
		||||
      state: present
 | 
			
		||||
 | 
			
		||||
  - name: Copy systemd service for Doorboy controller
 | 
			
		||||
  - name: Copy systemd service for Doorboy controller # https://git.k-space.ee/k-space/godoor
 | 
			
		||||
    copy:
 | 
			
		||||
      dest: /etc/systemd/system/godoor.service
 | 
			
		||||
      content: |
 | 
			
		||||
@@ -34,7 +36,7 @@
 | 
			
		||||
      daemon_reload: yes
 | 
			
		||||
      name: godoor.service
 | 
			
		||||
 | 
			
		||||
  - name: Copy systemd service for mjpg-streamer
 | 
			
		||||
  - name: Copy systemd service for mjpg-streamer # https://git.k-space.ee/k-space/mjpg-steramer
 | 
			
		||||
    copy:
 | 
			
		||||
      dest: /etc/systemd/system/mjpg_streamer@.service
 | 
			
		||||
      content: |
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,56 @@
 | 
			
		||||
To apply changes:
 | 
			
		||||
# Cameras
 | 
			
		||||
Camtiler is the umbrella name for our homegrown camera surveilance system.
 | 
			
		||||
 | 
			
		||||
Everything besides [Camera](#camera)s is deployed with Kubernetes.
 | 
			
		||||
 | 
			
		||||
## Components
 | 
			
		||||

 | 
			
		||||
<!-- Manually rendered with https://dreampuf.github.io/GraphvizOnline
 | 
			
		||||
digraph G {
 | 
			
		||||
  "camera-operator" -> "camera-motion-detect" [label="deploys"]
 | 
			
		||||
  "camera-tiler" -> "cam.k-space.ee/tiled"
 | 
			
		||||
  camera -> "camera-tiler"
 | 
			
		||||
  camera -> "camera-motion-detect" -> mongo
 | 
			
		||||
  "camera-motion-detect" -> "Minio S3"
 | 
			
		||||
 | 
			
		||||
  "cam.k-space.ee" -> mongo [label="queries events", decorate=true]
 | 
			
		||||
  mongo -> "camtiler-event-broker" [label="transforms object to add (signed) URL to S3", ]
 | 
			
		||||
  "camtiler-event-broker" -> "cam.k-space.ee"
 | 
			
		||||
 | 
			
		||||
  "Minio S3" -> "cam.k-space.ee" [label="using signed URL from camtiler-event-broker", decorate=true]
 | 
			
		||||
 | 
			
		||||
  camera [label="📸 camera"]
 | 
			
		||||
}
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
### 📸 Camera
 | 
			
		||||
Cameras are listed in [application.yml](application.yml) as `kind: Camera`.
 | 
			
		||||
 | 
			
		||||
Two types of camera hosts:
 | 
			
		||||
- GL-AR150 with [openwrt-camera-images](https://git.k-space.ee/k-space/openwrt-camera-image).
 | 
			
		||||
- [Doors](https://wiki.k-space.ee/e/en/hosting/doors) (Raspberry Pi) with mjpg-streamer.
 | 
			
		||||
 | 
			
		||||
### camera-tiler (cam.k-space.ee/tiled)
 | 
			
		||||
Out-of-bound, connects to cameras and streams to web browser.
 | 
			
		||||
 | 
			
		||||
One instance per every camera
 | 
			
		||||
 | 
			
		||||
#### camera-operator
 | 
			
		||||
Functionally the same as a kubernetes deployment for camera-tiler.
 | 
			
		||||
 | 
			
		||||
Operator/deployer for camera-tiler.
 | 
			
		||||
 | 
			
		||||
### camera-motion-detect
 | 
			
		||||
Connects to cameras, on motion writes events to Mongo and frames to S3.
 | 
			
		||||
 | 
			
		||||
### cam.k-space.ee (logmower)
 | 
			
		||||
Fetches motion-detect events from mongo. Fetches referenced images from S3 (minio).
 | 
			
		||||
 | 
			
		||||
#### camtiler-event-broker
 | 
			
		||||
MitM between motion-detect -> mongo. Appends S3 URLs to the response.
 | 
			
		||||
 | 
			
		||||
## Kubernetes commands
 | 
			
		||||
Apply changes:
 | 
			
		||||
```
 | 
			
		||||
kubectl apply -n camtiler \
 | 
			
		||||
  -f application.yml \
 | 
			
		||||
@@ -13,14 +64,12 @@ kubectl apply -n camtiler \
 | 
			
		||||
  -f networkpolicy-base.yml
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
To deploy changes:
 | 
			
		||||
 | 
			
		||||
Deploy changes:
 | 
			
		||||
```
 | 
			
		||||
kubectl -n camtiler rollout restart deployment.apps/camtiler
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
To initialize secrets:
 | 
			
		||||
 | 
			
		||||
Initialize secrets:
 | 
			
		||||
```
 | 
			
		||||
kubectl create secret generic -n camtiler mongodb-application-readwrite-password --from-literal="password=$(cat /dev/urandom | base64 | head -c 30)"
 | 
			
		||||
kubectl create secret generic -n camtiler mongodb-application-readonly-password --from-literal="password=$(cat /dev/urandom | base64 | head -c 30)"
 | 
			
		||||
@@ -32,8 +81,7 @@ kubectl -n camtiler create secret generic camera-secrets \
 | 
			
		||||
    --from-literal=password=...
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
To restart all deployments:
 | 
			
		||||
 | 
			
		||||
Restart all deployments:
 | 
			
		||||
```
 | 
			
		||||
for j in $(kubectl get deployments -n camtiler -o name); do kubectl rollout restart -n camtiler $j; done
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
@@ -268,6 +268,7 @@ spec:
 | 
			
		||||
          annotations:
 | 
			
		||||
            summary: CPU limits are bottleneck
 | 
			
		||||
---
 | 
			
		||||
# Referenced by README.md
 | 
			
		||||
apiVersion: k-space.ee/v1alpha1
 | 
			
		||||
kind: Camera
 | 
			
		||||
metadata:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										131
									
								
								camtiler/cams.graphviz.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								camtiler/cams.graphviz.svg
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,131 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 | 
			
		||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 | 
			
		||||
<!-- Generated by graphviz version 2.40.1 (20161225.0304)
 | 
			
		||||
 -->
 | 
			
		||||
<!-- Title: G Pages: 1 -->
 | 
			
		||||
<svg width="658pt" height="387pt" viewBox="0.00 0.00 658.36 386.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 | 
			
		||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 382.8)">
 | 
			
		||||
<title>G</title>
 | 
			
		||||
<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-382.8 654.3562,-382.8 654.3562,4 -4,4"/>
 | 
			
		||||
<!-- camera-operator -->
 | 
			
		||||
<g id="node1" class="node">
 | 
			
		||||
<title>camera-operator</title>
 | 
			
		||||
<ellipse fill="none" stroke="#000000" cx="356.22" cy="-360.8" rx="74.095" ry="18"/>
 | 
			
		||||
<text text-anchor="middle" x="356.22" y="-356.6" font-family="Times,serif" font-size="14.00" fill="#000000">camera-operator</text>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- camera-motion-detect -->
 | 
			
		||||
<g id="node2" class="node">
 | 
			
		||||
<title>camera-motion-detect</title>
 | 
			
		||||
<ellipse fill="none" stroke="#000000" cx="356.22" cy="-272" rx="95.5221" ry="18"/>
 | 
			
		||||
<text text-anchor="middle" x="356.22" y="-267.8" font-family="Times,serif" font-size="14.00" fill="#000000">camera-motion-detect</text>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- camera-operator->camera-motion-detect -->
 | 
			
		||||
<g id="edge1" class="edge">
 | 
			
		||||
<title>camera-operator->camera-motion-detect</title>
 | 
			
		||||
<path fill="none" stroke="#000000" d="M356.22,-342.4006C356.22,-330.2949 356.22,-314.2076 356.22,-300.4674"/>
 | 
			
		||||
<polygon fill="#000000" stroke="#000000" points="359.7201,-300.072 356.22,-290.072 352.7201,-300.0721 359.7201,-300.072"/>
 | 
			
		||||
<text text-anchor="middle" x="377.9949" y="-312.2" font-family="Times,serif" font-size="14.00" fill="#000000">deploys</text>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- mongo -->
 | 
			
		||||
<g id="node6" class="node">
 | 
			
		||||
<title>mongo</title>
 | 
			
		||||
<ellipse fill="none" stroke="#000000" cx="292.22" cy="-199" rx="37.7256" ry="18"/>
 | 
			
		||||
<text text-anchor="middle" x="292.22" y="-194.8" font-family="Times,serif" font-size="14.00" fill="#000000">mongo</text>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- camera-motion-detect->mongo -->
 | 
			
		||||
<g id="edge5" class="edge">
 | 
			
		||||
<title>camera-motion-detect->mongo</title>
 | 
			
		||||
<path fill="none" stroke="#000000" d="M340.3997,-253.9551C332.3383,-244.76 322.4178,-233.4445 313.6783,-223.476"/>
 | 
			
		||||
<polygon fill="#000000" stroke="#000000" points="316.2049,-221.0485 306.9807,-215.8365 310.9413,-225.6632 316.2049,-221.0485"/>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- Minio S3 -->
 | 
			
		||||
<g id="node7" class="node">
 | 
			
		||||
<title>Minio S3</title>
 | 
			
		||||
<ellipse fill="none" stroke="#000000" cx="396.22" cy="-145" rx="47.0129" ry="18"/>
 | 
			
		||||
<text text-anchor="middle" x="396.22" y="-140.8" font-family="Times,serif" font-size="14.00" fill="#000000">Minio S3</text>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- camera-motion-detect->Minio S3 -->
 | 
			
		||||
<g id="edge6" class="edge">
 | 
			
		||||
<title>camera-motion-detect->Minio S3</title>
 | 
			
		||||
<path fill="none" stroke="#000000" d="M361.951,-253.804C368.6045,-232.6791 379.6542,-197.5964 387.4031,-172.9935"/>
 | 
			
		||||
<polygon fill="#000000" stroke="#000000" points="390.8337,-173.7518 390.4996,-163.1622 384.157,-171.6489 390.8337,-173.7518"/>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- camera-tiler -->
 | 
			
		||||
<g id="node3" class="node">
 | 
			
		||||
<title>camera-tiler</title>
 | 
			
		||||
<ellipse fill="none" stroke="#000000" cx="527.22" cy="-272" rx="57.8558" ry="18"/>
 | 
			
		||||
<text text-anchor="middle" x="527.22" y="-267.8" font-family="Times,serif" font-size="14.00" fill="#000000">camera-tiler</text>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- cam.k-space.ee/tiled -->
 | 
			
		||||
<g id="node4" class="node">
 | 
			
		||||
<title>cam.k-space.ee/tiled</title>
 | 
			
		||||
<ellipse fill="none" stroke="#000000" cx="527.22" cy="-199" rx="89.7229" ry="18"/>
 | 
			
		||||
<text text-anchor="middle" x="527.22" y="-194.8" font-family="Times,serif" font-size="14.00" fill="#000000">cam.k-space.ee/tiled</text>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- camera-tiler->cam.k-space.ee/tiled -->
 | 
			
		||||
<g id="edge2" class="edge">
 | 
			
		||||
<title>camera-tiler->cam.k-space.ee/tiled</title>
 | 
			
		||||
<path fill="none" stroke="#000000" d="M527.22,-253.9551C527.22,-245.8828 527.22,-236.1764 527.22,-227.1817"/>
 | 
			
		||||
<polygon fill="#000000" stroke="#000000" points="530.7201,-227.0903 527.22,-217.0904 523.7201,-227.0904 530.7201,-227.0903"/>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- camera -->
 | 
			
		||||
<g id="node5" class="node">
 | 
			
		||||
<title>camera</title>
 | 
			
		||||
<ellipse fill="none" stroke="#000000" cx="513.22" cy="-360.8" rx="51.565" ry="18"/>
 | 
			
		||||
<text text-anchor="middle" x="513.22" y="-356.6" font-family="Times,serif" font-size="14.00" fill="#000000">📸 camera</text>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- camera->camera-motion-detect -->
 | 
			
		||||
<g id="edge4" class="edge">
 | 
			
		||||
<title>camera->camera-motion-detect</title>
 | 
			
		||||
<path fill="none" stroke="#000000" d="M485.8726,-345.3322C460.8217,-331.1633 423.4609,-310.0318 395.271,-294.0875"/>
 | 
			
		||||
<polygon fill="#000000" stroke="#000000" points="396.8952,-290.9851 386.4679,-289.1084 393.449,-297.078 396.8952,-290.9851"/>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- camera->camera-tiler -->
 | 
			
		||||
<g id="edge3" class="edge">
 | 
			
		||||
<title>camera->camera-tiler</title>
 | 
			
		||||
<path fill="none" stroke="#000000" d="M516.1208,-342.4006C518.0482,-330.175 520.6159,-313.8887 522.7961,-300.0599"/>
 | 
			
		||||
<polygon fill="#000000" stroke="#000000" points="526.2706,-300.4951 524.3708,-290.072 519.356,-299.4049 526.2706,-300.4951"/>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- camtiler-event-broker -->
 | 
			
		||||
<g id="node9" class="node">
 | 
			
		||||
<title>camtiler-event-broker</title>
 | 
			
		||||
<ellipse fill="none" stroke="#000000" cx="95.22" cy="-91" rx="95.4404" ry="18"/>
 | 
			
		||||
<text text-anchor="middle" x="95.22" y="-86.8" font-family="Times,serif" font-size="14.00" fill="#000000">camtiler-event-broker</text>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- mongo->camtiler-event-broker -->
 | 
			
		||||
<g id="edge8" class="edge">
 | 
			
		||||
<title>mongo->camtiler-event-broker</title>
 | 
			
		||||
<path fill="none" stroke="#000000" d="M254.6316,-196.5601C185.4398,-191.6839 43.6101,-179.7471 28.9976,-163 18.4783,-150.9441 20.8204,-140.7526 28.9976,-127 32.2892,-121.4639 36.7631,-116.7259 41.8428,-112.6837"/>
 | 
			
		||||
<polygon fill="#000000" stroke="#000000" points="43.9975,-115.4493 50.2411,-106.8896 40.0224,-109.6875 43.9975,-115.4493"/>
 | 
			
		||||
<text text-anchor="middle" x="153.8312" y="-140.8" font-family="Times,serif" font-size="14.00" fill="#000000">transforms object to add (signed) URL to S3</text>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- cam.k-space.ee -->
 | 
			
		||||
<g id="node8" class="node">
 | 
			
		||||
<title>cam.k-space.ee</title>
 | 
			
		||||
<ellipse fill="none" stroke="#000000" cx="292.22" cy="-18" rx="70.0229" ry="18"/>
 | 
			
		||||
<text text-anchor="middle" x="292.22" y="-13.8" font-family="Times,serif" font-size="14.00" fill="#000000">cam.k-space.ee</text>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- Minio S3->cam.k-space.ee -->
 | 
			
		||||
<g id="edge10" class="edge">
 | 
			
		||||
<title>Minio S3->cam.k-space.ee</title>
 | 
			
		||||
<path fill="none" stroke="#000000" d="M394.7596,-126.8896C392.7231,-111.3195 387.8537,-88.922 376.22,-73 366.0004,-59.0134 351.0573,-47.5978 336.5978,-38.8647"/>
 | 
			
		||||
<polygon fill="#000000" stroke="#000000" points="338.1215,-35.7041 327.7038,-33.7748 334.6446,-41.7796 338.1215,-35.7041"/>
 | 
			
		||||
<text text-anchor="middle" x="521.2881" y="-86.8" font-family="Times,serif" font-size="14.00" fill="#000000">using signed URL from camtiler-event-broker</text>
 | 
			
		||||
<polyline fill="none" stroke="#000000" points="650.3562,-82.6 392.22,-82.6 392.9753,-115.8309 "/>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- cam.k-space.ee->mongo -->
 | 
			
		||||
<g id="edge7" class="edge">
 | 
			
		||||
<title>cam.k-space.ee->mongo</title>
 | 
			
		||||
<path fill="none" stroke="#000000" d="M292.22,-36.2125C292.22,-67.8476 292.22,-133.1569 292.22,-170.7273"/>
 | 
			
		||||
<polygon fill="#000000" stroke="#000000" points="288.7201,-170.9833 292.22,-180.9833 295.7201,-170.9833 288.7201,-170.9833"/>
 | 
			
		||||
<text text-anchor="middle" x="332.0647" y="-86.8" font-family="Times,serif" font-size="14.00" fill="#000000">queries events</text>
 | 
			
		||||
<polyline fill="none" stroke="#000000" points="371.9094,-82.6 292.22,-82.6 292.22,-91.3492 "/>
 | 
			
		||||
</g>
 | 
			
		||||
<!-- camtiler-event-broker->cam.k-space.ee -->
 | 
			
		||||
<g id="edge9" class="edge">
 | 
			
		||||
<title>camtiler-event-broker->cam.k-space.ee</title>
 | 
			
		||||
<path fill="none" stroke="#000000" d="M138.9406,-74.7989C169.6563,-63.417 210.7924,-48.1737 242.716,-36.3441"/>
 | 
			
		||||
<polygon fill="#000000" stroke="#000000" points="244.1451,-39.5472 252.3059,-32.7905 241.7128,-32.9833 244.1451,-39.5472"/>
 | 
			
		||||
</g>
 | 
			
		||||
</g>
 | 
			
		||||
</svg>
 | 
			
		||||
| 
		 After Width: | Height: | Size: 7.8 KiB  | 
@@ -1,3 +1,4 @@
 | 
			
		||||
# Referenced and documented by https://wiki.k-space.ee/en/hosting/doors
 | 
			
		||||
---
 | 
			
		||||
apiVersion: apps/v1
 | 
			
		||||
kind: Deployment
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user