diff --git a/kaniko/kaniko.yaml b/kaniko/build-kaniko-test.yaml similarity index 100% rename from kaniko/kaniko.yaml rename to kaniko/build-kaniko-test.yaml diff --git a/kaniko/build-netbox.yaml b/kaniko/build-netbox.yaml new file mode 100644 index 0000000..9f06785 --- /dev/null +++ b/kaniko/build-netbox.yaml @@ -0,0 +1,35 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: kaniko-build-netbox + namespace: kaniko +spec: + backoffLimit: 0 + template: + metadata: + labels: + app: kaniko-build-netbox + spec: + restartPolicy: Never + containers: + - name: kaniko + image: gcr.io/kaniko-project/executor:v1.23.2 + imagePullPolicy: IfNotPresent + args: + - --context=git://gitea.apps.undercloud.dev/Undercloud/k8s-apps.git + - --dockerfile=netbox/image/Dockerfile + - --destination=docker-repo.apps.undercloud.dev/library/netbox-custom:latest + - --cleanup + - --skip-tls-verify + - --skip-tls-verify-pull + - --insecure-registry=docker-repo.apps.undercloud.dev + volumeMounts: + - name: docker-config + mountPath: /kaniko/.docker + volumes: + - name: docker-config + secret: + secretName: harbor-creds + items: + - key: .dockerconfigjson + path: config.json \ No newline at end of file diff --git a/netbox/image/Dockerfile b/netbox/image/Dockerfile new file mode 100644 index 0000000..40db010 --- /dev/null +++ b/netbox/image/Dockerfile @@ -0,0 +1,12 @@ +FROM ghcr.io/netbox-community/netbox:latest + +USER root + +# needed for topology views +RUN mkdir -p /opt/netbox/netbox/static/netbox_topology_views/img + +COPY requirements-plugins.txt /tmp/requirements-plugins.txt + +RUN /opt/netbox/venv/bin/pip install --no-cache-dir -r /tmp/requirements-plugins.txt + +USER unit \ No newline at end of file diff --git a/netbox/image/requirements-plugins.txt b/netbox/image/requirements-plugins.txt new file mode 100644 index 0000000..76b99fd --- /dev/null +++ b/netbox/image/requirements-plugins.txt @@ -0,0 +1,3 @@ +netbox-topology-views +netbox-plugin-dns +netbox-routing \ No newline at end of file diff --git a/netbox/netbox.yaml b/netbox/netbox.yaml index 9ffeb3f..235195a 100644 --- a/netbox/netbox.yaml +++ b/netbox/netbox.yaml @@ -1,3 +1,21 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: netbox-plugins + namespace: netbox +data: + plugins.py: | + PLUGINS = [ + "netbox_topology_views", + "netbox_dns", + "netbox_routing", + ] + + PLUGINS_CONFIG = { + "netbox_topology_views": {}, + "netbox_dns": {}, + "netbox_routing": {}, + } --- apiVersion: v1 kind: PersistentVolumeClaim @@ -100,6 +118,96 @@ spec: failureThreshold: 30 periodSeconds: 10 + apiVersion: apps/v1 +kind: Deployment +metadata: + name: netbox + namespace: netbox +spec: + replicas: 1 + selector: + matchLabels: + app: netbox + template: + metadata: + labels: + app: netbox + spec: + containers: + - name: netbox + image: docker-repo.apps.undercloud.dev/library/netbox-custom:latest + imagePullPolicy: Always + ports: + - containerPort: 8080 + name: http + env: + - name: SUPERUSER_NAME + valueFrom: + secretKeyRef: + name: netbox-superuser + key: username + - name: SUPERUSER_EMAIL + valueFrom: + secretKeyRef: + name: netbox-superuser + key: email + - name: SUPERUSER_PASSWORD + valueFrom: + secretKeyRef: + name: netbox-superuser + key: password + + - name: DB_NAME + value: netbox + - name: DB_HOST + value: db + - name: DB_PORT + value: "5432" + - name: DB_USER + valueFrom: + secretKeyRef: + name: netbox-db + key: username + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: netbox-db + key: user.pw + - name: DB_WAIT_DEBUG + value: "1" + + - name: REDIS_HOST + value: redis + - name: REDIS_PORT + value: "6379" + - name: REDIS_CACHE_HOST + value: redis + - name: REDIS_CACHE_PORT + value: "6379" + + - name: SECRET_KEY + valueFrom: + secretKeyRef: + name: netbox-secrets + key: SECRET_KEY + + - name: ALLOWED_HOSTS + value: "*" + + volumeMounts: + - name: netbox-data + mountPath: /opt/netbox/netbox/media + - name: netbox-plugins-config + mountPath: /etc/netbox/config/plugins.py + subPath: plugins.py + + startupProbe: + httpGet: + path: / + port: 8080 + failureThreshold: 30 + periodSeconds: 10 + readinessProbe: httpGet: path: / @@ -118,6 +226,9 @@ spec: - name: netbox-data persistentVolumeClaim: claimName: netbox + - name: netbox-plugins-config + configMap: + name: netbox-plugins --- apiVersion: v1