Redo deployment to consolidate api and front

This commit is contained in:
Alexander Olofsson 2019-07-05 09:24:29 +02:00
parent 8d3f88485c
commit e65ae3d6c8
No known key found for this signature in database
GPG key ID: D439C9470CB04C73
5 changed files with 105 additions and 104 deletions

View file

@ -4,4 +4,4 @@ appVersion: "2.6.1"
description: An IP address management (IPAM) and data center infrastructure management (DCIM) tool.
icon: https://raw.githubusercontent.com/digitalocean/netbox/develop/netbox/project-static/img/netbox.ico
name: netbox
version: 0.1.2
version: 0.2.0

View file

@ -1,3 +1,4 @@
---
apiVersion: v1
kind: ConfigMap
metadata:

View file

@ -1,103 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "netbox.fullname" . }}-front
labels:
app.kubernetes.io/name: {{ include "netbox.name" . }}
helm.sh/chart: {{ include "netbox.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
com.digitalocean.netbox/component: front
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "netbox.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
com.digitalocean.netbox/component: front
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "netbox.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
com.digitalocean.netbox/component: front
spec:
initContainers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- sh
- -c
- |
cp /etc/netbox-nginx/* /tmp/netbox-nginx
sed -e 's!http://netbox:8001!http://{{ include "netbox.fullname" . }}-api:8001!' -i /tmp/netbox-nginx/nginx.conf
cp -r /opt/netbox/netbox/project-static/* \
/usr/local/lib/python3.6/site-packages/django/contrib/admin/static/* \
/usr/local/lib/python3.6/site-packages/debug_toolbar/static/* \
/usr/local/lib/python3.6/site-packages/django_tables2/static/* \
/usr/local/lib/python3.6/site-packages/drf_yasg/static/* \
/usr/local/lib/python3.6/site-packages/mptt/static/* \
/usr/local/lib/python3.6/site-packages/rest_framework/static/* \
/tmp/netbox-static
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: netbox-nginx-config
mountPath: /tmp/netbox-nginx
- name: netbox-static-files
mountPath: /tmp/netbox-static
# - name: netbox-configuration
# path: /etc/netbox/config
# readOnly: true
# - name: netbox-initializers
# path: /opt/netbox/initializers
# readOnly: true
# - name: netbox-startup-scripts
# path: /opt/netbox/startup_scripts
# readOnly: true
# - name: netbox-reports
# path: /opt/netbox/reports
# readOnly: true
containers:
- name: nginx
image: "nginx:alpine"
imagePullPolicy: Always
command:
- nginx
- -c
- /etc/netbox-nginx/nginx.conf
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
tcpSocket:
port: http
readinessProbe:
tcpSocket:
port: http
volumeMounts:
- name: netbox-nginx-config
mountPath: /etc/netbox-nginx
readOnly: true
- name: netbox-static-files
mountPath: /opt/netbox/netbox/static
readOnly: true
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: netbox-nginx-config
emptyDir: {}
- name: netbox-static-files
emptyDir: {}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View file

@ -51,6 +51,14 @@ spec:
{{- toYaml .Values.resources | nindent 12 }}
{{- if or .Values.persistence.enabled .Values.extraVolumeMounts }}
volumeMounts:
- name: netbox-static-files
mountPath: /opt/netbox/netbox/static
- name: netbox-config-files
mountPath: /etc/netbox/config/gunicorn_config.py
subPath: gunicorn_config.py
readOnly: true
- name: netbox-socket
mountPath: /tmp/netbox
{{- if .Values.persistence.enabled }}
- name: data
mountPath: /etc/netbox/media
@ -71,11 +79,49 @@ spec:
# - name: netbox-reports
# path: /opt/netbox/reports
# readOnly: true
- name: nginx
image: "nginx:alpine"
imagePullPolicy: Always
command:
- nginx
- -c
- /etc/netbox-nginx/nginx.conf
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
tcpSocket:
port: http
readinessProbe:
tcpSocket:
port: http
volumeMounts:
- name: netbox-config-files
mountPath: /etc/netbox-nginx/nginx.conf
subPath: nginx.conf
readOnly: true
- name: netbox-static-files
mountPath: /opt/netbox/netbox/static
readOnly: true
- name: netbox-socket
mountPath: /tmp/netbox
# resources:
# limits:
# cpu: 125m
# memory: 50Mi
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: netbox-config-files
configMap:
name: {{ .Chart.Name }}-config-files
- name: netbox-static-files
emptyDir: {}
- name: netbox-socket
emptyDir: {}
# - name: netbox-configuration
# configMap:
# name: {{ .Chart.Name }}-configuration

View file

@ -0,0 +1,57 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Chart.Name }}-config-files
labels:
app.kubernetes.io/name: {{ include "netbox.name" . }}
helm.sh/chart: {{ include "netbox.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
gunicorn_config.py: |-
command = '/usr/bin/gunicorn'
pythonpath = '/opt/netbox/netbox'
bind = 'unix:/tmp/netbox/gunicorn.sock'
workers = 3
errorlog = '-'
accesslog = '-'
capture_output = False
loglevel = 'info'
nginx.conf: |-
daemon off;
worker_processes 1;
error_log /dev/stderr info;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
gzip off;
server_tokens off;
client_max_body_size 10M;
server {
listen 8080;
access_log off;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
proxy_pass unix:/tmp/netbox/gunicorn.sock;
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"';
}
}
}