forked from CENGN/netbox-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnetbox-deployment.yaml
234 lines (228 loc) · 7.38 KB
/
netbox-deployment.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: netbox
namespace: netbox-community
labels:
k8s-app: netbox
spec:
replicas: 3
template:
metadata:
labels:
k8s-app: netbox
spec:
containers:
# NetBox container using the netbox-docker image: https://github.com/netbox-community/netbox-docker
- name: netbox
image: netboxcommunity/netbox:v2.6.3-ldap
ports:
- name: http
containerPort: 80
readinessProbe: # will mark the pod as ready once the initialization script is completed and will probe every 5 seconds
httpGet:
path: /
port: http
initialDelaySeconds: 5
periodSeconds: 5
env:
# More configuration can be added via: https://netbox.readthedocs.io/en/stable/configuration/optional-settings/
- name: ALLOWED_HOSTS
valueFrom:
configMapKeyRef:
key: ALLOWED_HOSTS
name: netbox-configmap
- name: DB_HOST
valueFrom:
configMapKeyRef:
key: DB_HOST
name: netbox-configmap
- name: DB_NAME
valueFrom:
configMapKeyRef:
key: DB_NAME
name: netbox-configmap
- name: DB_USER
valueFrom:
configMapKeyRef:
key: DB_USER
name: netbox-configmap
- name: EMAIL_FROM
valueFrom:
configMapKeyRef:
key: EMAIL_FROM
name: netbox-configmap
- name: EMAIL_PORT
valueFrom:
configMapKeyRef:
key: EMAIL_PORT
name: netbox-configmap
- name: EMAIL_SERVER
valueFrom:
configMapKeyRef:
key: EMAIL_SERVER
name: netbox-configmap
- name: EMAIL_TIMEOUT
valueFrom:
configMapKeyRef:
key: EMAIL_TIMEOUT
name: netbox-configmap
- name: EMAIL_USERNAME
valueFrom:
configMapKeyRef:
key: EMAIL_USERNAME
name: netbox-configmap
- name: EXEMPT_VIEW_PERMISSIONS
valueFrom:
configMapKeyRef:
key: EXEMPT_VIEW_PERMISSIONS
name: netbox-configmap
- name: LOGIN_REQUIRED
valueFrom:
configMapKeyRef:
key: LOGIN_REQUIRED
name: netbox-configmap
- name: METRICS_ENABLED
valueFrom:
configMapKeyRef:
key: METRICS_ENABLED
name: netbox-configmap
- name: NETBOX_USERNAME
valueFrom:
configMapKeyRef:
key: NETBOX_USERNAME
name: netbox-configmap
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
key: REDIS_HOST
name: netbox-configmap
volumeMounts:
# Mounting secrets for netbox and other related components
- name: auth-ldap-bind-password
mountPath: /run/secrets/auth_ldap_bind_password
subPath: auth_ldap_bind_password
readOnly: true
- name: db-password
mountPath: /run/secrets/db_password
subPath: db_password
readOnly: true
- name: email-password
mountPath: /run/secrets/email_password
subPath: email_password
readOnly: true
- name: napalm-password
mountPath: /run/secrets/napalm_password
subPath: napalm_password
readOnly: true
- name: redis-password
mountPath: /run/secrets/redis_password
subPath: redis_password
- name: secret-key
mountPath: /run/secrets/secret_key
subPath: secret_key
readOnly: true
- name: superuser-api-token
mountPath: /run/secrets/superuser_api_token
subPath: superuser_api_token
- name: superuser-password
mountPath: /run/secrets/superuser_password
subPath: superuser_password
readOnly: true
# Persistent Volume paths
- name: netbox-static-files # Shared directory with the nginx container for static files
mountPath: /opt/netbox/netbox/static
- name: netbox-media-files # Allows for multiple replicas of the netbox pod to be available
mountPath: /etc/netbox/media
- name: ldap-config # Allows for LDAP authentication to work
subPath: ldap_config.py
mountPath: /opt/netbox/netbox/netbox/ldap_config.py
# nginx sidecar container used to serve static files
- name: nginx
image: nginx:1.17.3-alpine
volumeMounts:
- name: netbox-static-files
mountPath: /opt/netbox/netbox/static
- name: netbox-nginx-config
subPath: nginx.conf
mountPath: /etc/nginx/nginx.conf
volumes:
# Secret volumes
- name: netbox-secret # contains most netbox secrets that would be used
secret:
secretName: netbox-secret
- name: netbox-redis # contains the password used for redis caching
secret:
secretName: netbox-redis
# Populate via secret
- name: auth-ldap-bind-password
secret:
secretName: netbox-secret
items:
- key: auth_ldap_bind_password
path: auth_ldap_bind_password
- name: db-password
secret:
secretName: netbox-community-postgresql
items:
- key: postgresql-password
path: db_password
- name: email-password
secret:
secretName: netbox-secret
items:
- key: email_password
path: email_password
- name: napalm-password
secret:
secretName: netbox-secret
items:
- key: napalm_password
path: napalm_password
- name: redis-password
secret:
secretName: netbox-redis
items:
- key: redis-password
path: redis_password
- name: secret-key
secret:
secretName: netbox-secret
items:
- key: secret_key
path: secret_key
- name: superuser-password
secret:
secretName: netbox-secret
items:
- key: superuser_password
path: superuser_password
- name: superuser-api-token
secret:
secretName: netbox-secret
items:
- key: superuser_api_token
path: superuser_api_token
# Reference to configmaps and PVs
- name: ldap-config
configMap:
name: netbox-configmap
items:
- key: ldap_config.py
path: ldap_config.py
- name: netbox-nginx-config
configMap:
name: netbox-configmap
items:
- key: nginx.conf
path: nginx.conf
- name: netbox-static-files
emptyDir: {}
- name: netbox-media-files
flexVolume: # in this example, we use Ceph as our storage backend, managed by the Rook operator: https://github.com/rook/rook/
driver: ceph.rook.io/rook #changeme
fsType: ceph
options:
fsName: sharedfs
clusterNamespace: rook-ceph
path: /netbox-community-media # a premade path in the shared filesystem specifically for netbox related files