diff options
author | 2018-08-14 16:33:43 -0400 | |
---|---|---|
committer | 2018-08-17 09:06:37 -0400 | |
commit | 0c2d6fb07e947781c96a5d68a6481aee739926fa (patch) | |
tree | 406be45d2333bbf51ddca8ec7940c3d8e524e2e1 /kubernetes/contrib/charts/netbox/charts/netbox-app/templates | |
parent | d30de9427dfcebc7855d94b525eadfbce186059c (diff) |
Add provisioning job for Netbox
This is adding a script in a configmap along with a job that will
play the script.
This is also adding a readiness check to the netbox-app pod, so
that the job can be executed once the pod is ready.
Adding provisioning of:
- user
- region
- tenant group
- tenant
- site
- prefixes for vFW use case
Change-Id: I3bf00eb81ff4330b38e83b2f67cb17d4866e3990
Issue-ID: CCSDK-460
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'kubernetes/contrib/charts/netbox/charts/netbox-app/templates')
3 files changed, 89 insertions, 0 deletions
diff --git a/kubernetes/contrib/charts/netbox/charts/netbox-app/templates/configmap.yaml b/kubernetes/contrib/charts/netbox/charts/netbox-app/templates/configmap.yaml index 388d224569..f785478e1b 100755 --- a/kubernetes/contrib/charts/netbox/charts/netbox-app/templates/configmap.yaml +++ b/kubernetes/contrib/charts/netbox/charts/netbox-app/templates/configmap.yaml @@ -17,6 +17,14 @@ apiVersion: v1 kind: ConfigMap metadata: + name: {{ include "common.fullname" . }}-provisioning-configmap + namespace: {{ include "common.namespace" . }} +data: +{{ tpl (.Files.Glob "resources/config/provisioning/*").AsConfig . | indent 2 }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: name: {{ include "common.fullname" . }}-configuration-configmap namespace: {{ include "common.namespace" . }} data: diff --git a/kubernetes/contrib/charts/netbox/charts/netbox-app/templates/deployment.yaml b/kubernetes/contrib/charts/netbox/charts/netbox-app/templates/deployment.yaml index f321456ac0..3d4932b6cd 100755 --- a/kubernetes/contrib/charts/netbox/charts/netbox-app/templates/deployment.yaml +++ b/kubernetes/contrib/charts/netbox/charts/netbox-app/templates/deployment.yaml @@ -38,6 +38,22 @@ spec: imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} ports: - containerPort: {{ .Values.service.internalPort }} + # disable liveness probe when breakpoints set in debugger + # so K8s doesn't restart unresponsive container + {{ if .Values.liveness.enabled }} + livenessProbe: + tcpSocket: + port: {{ .Values.service.internalPort }} + initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }} + periodSeconds: {{ .Values.liveness.periodSeconds }} + {{ end }} + readinessProbe: + httpGet: + path: /api/dcim/regions/ + port: {{ .Values.service.internalPort }} + scheme: HTTP + initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }} + periodSeconds: {{ .Values.readiness.periodSeconds }} env: - name: DB_PASSWORD valueFrom: diff --git a/kubernetes/contrib/charts/netbox/charts/netbox-app/templates/job.yaml b/kubernetes/contrib/charts/netbox/charts/netbox-app/templates/job.yaml new file mode 100644 index 0000000000..89504afdc7 --- /dev/null +++ b/kubernetes/contrib/charts/netbox/charts/netbox-app/templates/job.yaml @@ -0,0 +1,65 @@ +# Copyright © 2018 Bell Canada +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ include "common.fullname" . }}-provisioning + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.name" . }}-job + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + backoffLimit: 5 + template: + metadata: + labels: + app: {{ include "common.name" . }}-provisioning-job + release: {{ .Release.Name }} + spec: + restartPolicy: Never + initContainers: + - name: {{ include "common.name" . }}-init-readiness + image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}" + imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} + command: + - /root/ready.py + args: + - --container-name + - netbox-app + env: + - name: NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + containers: + - name: {{ include "common.name" . }}-provisioning-job + image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}" + volumeMounts: + - name: {{ include "common.fullname" . }}-provisioning + mountPath: /tmp + command: + - /bin/bash + - ./tmp/provision.sh + volumes: + - name: {{ include "common.fullname" . }}-provisioning + configMap: + name: {{ include "common.fullname" . }}-provisioning-configmap + defaultMode: 0755 + imagePullSecrets: + - name: "{{ include "common.namespace" . }}-docker-registry-key" + restartPolicy: Never |