Last active
April 24, 2020 18:51
-
-
Save tkuther/34e7a9ff770d2c792a356392cb8146b2 to your computer and use it in GitHub Desktop.
Netbox on Kubernetes (https://github.com/digitalocean/netbox)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Netbox deployment manifest for Kubernetes. | |
# Assumes pre-installed postgres | |
# | |
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: netbox | |
labels: | |
app: netbox | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: netbox | |
spec: | |
containers: | |
- name: netbox | |
image: ninech/netbox:v2.5.5 | |
ports: | |
- containerPort: 8001 | |
resources: | |
requests: | |
memory: "250Mi" | |
cpu: "250m" | |
limits: | |
memory: "512Mi" | |
cpu: "500m" | |
env: | |
- name: ALLOWED_HOSTS | |
value: '*' | |
- name: DB_HOST | |
value: CHANGEME | |
- name: DB_NAME | |
value: 'netbox' | |
- name: DB_PASSWORD | |
value: CHANGEME | |
- name: DB_USER | |
value: 'netbox' | |
- name: EMAIL_FROM | |
value: CHANGEME | |
- name: EMAIL_PORT | |
value: '25' | |
- name: EMAIL_SERVER | |
value: 'localhost' | |
- name: EMAIL_TIMEOUT | |
value: '10' | |
- name: NETBOX_PASSWORD | |
value: 'guest' | |
- name: NETBOX_USERNAME | |
value: 'guest' | |
- name: SECRET_KEY | |
value: CHANGEME | |
- name: SUPERUSER_API_TOKEN | |
value: CHANGEME | |
- name: SUPERUSER_EMAIL | |
value: CHANGEME | |
- name: SUPERUSER_NAME | |
value: CHANGEME | |
- name: SUPERUSER_PASSWORD | |
value: CHANGEME | |
volumeMounts: | |
- name: netbox-static-files | |
mountPath: /opt/netbox/netbox/static | |
- name: netbox-nginx | |
image: nginx | |
ports: | |
- containerPort: 80 | |
resources: | |
requests: | |
memory: "128Mi" | |
cpu: "125m" | |
limits: | |
memory: "256Mi" | |
cpu: "250m" | |
volumeMounts: | |
- name: netbox-nginx-config | |
mountPath: /etc/nginx/nginx.conf | |
subPath: nginx.conf | |
- name: netbox-static-files | |
mountPath: /opt/netbox/netbox/static | |
restartPolicy: Always | |
volumes: | |
- name: netbox-nginx-config | |
configMap: | |
name: netbox-nginx-conf | |
- name: netbox-static-files | |
persistentVolumeClaim: | |
claimName: netbox-static-files | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: netbox | |
labels: | |
app: netbox | |
spec: | |
ports: | |
- name: netbox | |
port: 8001 | |
targetPort: 8001 | |
selector: | |
app: netbox | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: netbox-nginx | |
labels: | |
app: netbox-nginx | |
spec: | |
ports: | |
- name: netbox-nginx | |
port: 80 | |
targetPort: 80 | |
selector: | |
app: netbox | |
--- | |
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: netbox-static-files | |
labels: | |
pvcname: netbox-static-files | |
spec: | |
accessModes: | |
- ReadWriteMany | |
resources: | |
requests: | |
storage: 100Mi | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: netbox-nginx-conf | |
data: | |
nginx.conf: | | |
worker_processes 1; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
sendfile on; | |
tcp_nopush on; | |
keepalive_timeout 65; | |
gzip on; | |
server_tokens off; | |
server { | |
listen 80; | |
server_name localhost; | |
access_log off; | |
location /static/ { | |
alias /opt/netbox/netbox/static/; | |
} | |
location / { | |
proxy_pass http://netbox:8001; | |
proxy_set_header X-Forwarded-Host $http_host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; | |
} | |
} | |
} | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: Ingress | |
metadata: | |
name: netbox | |
spec: | |
rules: | |
- host: CHANGEME | |
http: | |
paths: | |
- path: / | |
backend: | |
serviceName: netbox-nginx | |
servicePort: 80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment