Skip to content

Commit d26cdc2

Browse files
authored
Add kube docs (#582)
1 parent 4210091 commit d26cdc2

3 files changed

Lines changed: 289 additions & 0 deletions

File tree

examples/kubernetes/README.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Kubernetes Install
2+
3+
Any deployment on Kubernetes is going to be specific to the environment and requirements of the solution. The following are examples that can be adopted to fit specific needs.
4+
5+
## Fixed Configuration
6+
7+
If you have an existing `device.yml` file containing a set of Device Agent credentials.
8+
9+
```bash
10+
kubectl create secret generic device-one-secret --from-file=device.yml=./device.yml
11+
```
12+
13+
The following manifest will create a Deployment and Service for a device using the supplied Secret as it's credentials
14+
15+
```yaml
16+
apiVersion: apps/v1
17+
kind: Deployment
18+
metadata:
19+
name: device-one
20+
labels:
21+
app: device-one
22+
spec:
23+
replicas: 1
24+
revisionHistoryLimit: 10
25+
selector:
26+
matchLabels:
27+
app: device-one
28+
template:
29+
metadata:
30+
labels:
31+
app: device-one
32+
spec:
33+
containers:
34+
- name: device-one
35+
image: flowfuse/device-agent:latest
36+
ports:
37+
- containerPort: 1880
38+
volumeMounts:
39+
- name: config
40+
mountPath: "/opt/flowfuse-device/device.yml"
41+
subPath: "device.yml"
42+
readOnly: true
43+
resources:
44+
limits:
45+
cpu: 1000m
46+
memory: 256Mi
47+
requests:
48+
cpu: 500m
49+
memory: 128Mi
50+
volumes:
51+
- name: config
52+
secret:
53+
secretName: device-one-secret
54+
---
55+
apiVersion: v1
56+
kind: Service
57+
metadata:
58+
name: device-one-service
59+
spec:
60+
selector:
61+
app: device-one
62+
ports:
63+
- protocol: TCP
64+
port: 1880
65+
targetPort: 1880
66+
```
67+
68+
## Automatic Provisioning
69+
70+
Using a FlowFuse Provisioning Token to automatically configure a new Device Agent on deployment.
71+
72+
Because the Device Agent will need to re-write the `device.yml` file it can no longer be stored in a Secret and a PersistentVolume must be used for each instance of the Device Agent.
73+
74+
A Secret is used to hold the initial `device.yml` which contains the provisioning token.
75+
76+
```bash
77+
kubectl create secret generic device-provisioning-secret --from-file=device.yml=./device.yml
78+
```
79+
80+
The following manifest will create a Deployment, Service and PVC for a device using the supplied Secret as the source of the Provisioning token.
81+
82+
The PVC will be used to store the updated `device.yml` and the Node-RED nodes installed by the Remote Instance.
83+
84+
```yaml
85+
apiVersion: apps/v1
86+
kind: Deployment
87+
metadata:
88+
name: device-one
89+
labels:
90+
app: device-one
91+
spec:
92+
replicas: 1
93+
revisionHistoryLimit: 10
94+
selector:
95+
matchLabels:
96+
app: device-one
97+
template:
98+
metadata:
99+
labels:
100+
app: device-one
101+
spec:
102+
initContainers:
103+
- name: config-copy
104+
image: busybox:latest
105+
command:
106+
- "/bin/sh"
107+
- "-c"
108+
- "if [ ! -f /opt/flowfuse-device/device.yml ]; then cp /tmp/device.yml /opt/flowfuse-device/device.yml; fi"
109+
volumeMounts:
110+
- name: config
111+
mountPath: "/opt/flowfuse-device"
112+
- name: initial-config
113+
mountPath: "/tmp/device.yml"
114+
subPath: "device.yml"
115+
readOnly: true
116+
containers:
117+
- name: device-one
118+
image: flowfuse/device-agent:latest
119+
ports:
120+
- containerPort: 1880
121+
volumeMounts:
122+
- name: config
123+
mountPath: "/opt/flowfuse-device"
124+
resources:
125+
limits:
126+
cpu: 1000m
127+
memory: 256Mi
128+
requests:
129+
cpu: 500m
130+
memory: 128Mi
131+
volumes:
132+
- name: initial-config
133+
secret:
134+
secretName: device-provisioning-secret
135+
- name: config
136+
persistentVolumeClaim:
137+
claimName: device-one-pvc
138+
139+
---
140+
apiVersion: v1
141+
kind: Service
142+
metadata:
143+
name: device-one-service
144+
spec:
145+
selector:
146+
app: device-one
147+
ports:
148+
- protocol: TCP
149+
port: 1880
150+
targetPort: 1880
151+
---
152+
apiVersion: v1
153+
kind: PersistentVolumeClaim
154+
metadata:
155+
name: device-one-pvc
156+
spec:
157+
accessModes:
158+
- ReadWriteOnce
159+
resources:
160+
requests:
161+
storage: 1Gi
162+
```
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: device-one
5+
labels:
6+
app: device-one
7+
spec:
8+
replicas: 1
9+
revisionHistoryLimit: 10
10+
selector:
11+
matchLabels:
12+
app: device-one
13+
template:
14+
metadata:
15+
labels:
16+
app: device-one
17+
spec:
18+
containers:
19+
- name: device-one
20+
image: flowfuse/device-agent:latest
21+
ports:
22+
- containerPort: 1880
23+
volumeMounts:
24+
- name: config
25+
mountPath: "/opt/flowfuse-device/device.yml"
26+
subPath: "device.yml"
27+
readOnly: true
28+
resources:
29+
limits:
30+
cpu: 1000m
31+
memory: 256Mi
32+
requests:
33+
cpu: 500m
34+
memory: 128Mi
35+
volumes:
36+
- name: config
37+
secret:
38+
secretName: device-one-secret
39+
---
40+
apiVersion: v1
41+
kind: Service
42+
metadata:
43+
name: device-one-service
44+
spec:
45+
selector:
46+
app: device-one
47+
ports:
48+
- protocol: TCP
49+
port: 1880
50+
targetPort: 1880
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: device-one
5+
labels:
6+
app: device-one
7+
spec:
8+
replicas: 1
9+
revisionHistoryLimit: 10
10+
selector:
11+
matchLabels:
12+
app: device-one
13+
template:
14+
metadata:
15+
labels:
16+
app: device-one
17+
spec:
18+
initContainers:
19+
- name: config-copy
20+
image: busybox:latest
21+
command:
22+
- "/bin/sh"
23+
- "-c"
24+
- "if [ ! -f /opt/flowfuse-device/device.yml ]; then cp /tmp/device.yml /opt/flowfuse-device/device.yml; fi"
25+
volumeMounts:
26+
- name: config
27+
mountPath: "/opt/flowfuse-device"
28+
- name: initial-config
29+
mountPath: "/tmp/device.yml"
30+
subPath: "device.yml"
31+
readOnly: true
32+
containers:
33+
- name: device-one
34+
image: flowfuse/device-agent:latest
35+
ports:
36+
- containerPort: 1880
37+
volumeMounts:
38+
- name: config
39+
mountPath: "/opt/flowfuse-device"
40+
resources:
41+
limits:
42+
cpu: 1000m
43+
memory: 256Mi
44+
requests:
45+
cpu: 500m
46+
memory: 128Mi
47+
volumes:
48+
- name: initial-config
49+
secret:
50+
secretName: device-provisioning-secret
51+
- name: config
52+
persistentVolumeClaim:
53+
claimName: device-one-pvc
54+
55+
---
56+
apiVersion: v1
57+
kind: Service
58+
metadata:
59+
name: device-one-service
60+
spec:
61+
selector:
62+
app: device-one
63+
ports:
64+
- protocol: TCP
65+
port: 1880
66+
targetPort: 1880
67+
---
68+
apiVersion: v1
69+
kind: PersistentVolumeClaim
70+
metadata:
71+
name: device-one-pvc
72+
spec:
73+
accessModes:
74+
- ReadWriteOnce
75+
resources:
76+
requests:
77+
storage: 1Gi

0 commit comments

Comments
 (0)