Skip to content

Commit 8691a0a

Browse files
feat: nautobot-target-proxy helm chart and updates
1 parent 333b6d5 commit 8691a0a

14 files changed

Lines changed: 569 additions & 27 deletions

File tree

.github/workflows/containers.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- "containers/ansible/**"
1212
- "containers/dnsmasq/**"
1313
- "containers/ironic-nautobot-client/**"
14+
- "containers/nautobot-target-proxy/**"
1415
- "containers/ironic-vnc-client/**"
1516
- "containers/understack-tests/**"
1617
- "python/**"
@@ -34,6 +35,8 @@ jobs:
3435
target: prod
3536
- name: ironic-nautobot-client
3637
target: prod
38+
- name: nautobot-target-proxy
39+
target: prod
3740
- name: understack-tests
3841
target: prod
3942
- name: ironic-vnc-container
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v2
2+
name: nautobot-target-proxy
3+
description: FastAPI service that exposes Nautobot GraphQL targets for Prometheus HTTP service discovery
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.0.1"
7+
maintainers:
8+
- name: rackerlabs
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# nautobot-target-proxy
2+
3+
Helm chart that deploys the `nautobot_target_proxy` FastAPI service.
4+
5+
## Behavior
6+
7+
- Runs the proxy as a Kubernetes `Deployment`.
8+
- Exposes the app internally with a Kubernetes `Service`.
9+
- Starts the container with `uvicorn app:app --host 0.0.0.0 --port 8000`.
10+
- Injects `NAUTOBOT_URL` directly from values.
11+
- Injects `UNDERSTACK_PARTITION` from the shared `cluster-data` ConfigMap.
12+
- Injects `NAUTOBOT_TOKEN` from a referenced Kubernetes Secret.
13+
- Uses TCP liveness and readiness probes on port `8000`.
14+
15+
## Image behavior
16+
17+
- Default image repository is `ghcr.io/rackerlabs/understack/nautobot-target-proxy`.
18+
- Default tag comes from chart `appVersion` (currently `0.0.1`).
19+
- You can override image repository/tag/pullPolicy in values.
20+
21+
## Required values
22+
23+
```yaml
24+
nautobot:
25+
url: https://nautobot.example.com
26+
clusterDataConfigMapRef:
27+
name: cluster-data
28+
key: UNDERSTACK_PARTITION
29+
tokenSecretRef:
30+
name: nautobot-env
31+
key: NAUTOBOT_TOKEN
32+
```
33+
34+
## Example values
35+
36+
```yaml
37+
image:
38+
repository: ghcr.io/rackerlabs/understack/nautobot-target-proxy
39+
tag: "0.0.1"
40+
pullPolicy: IfNotPresent
41+
42+
service:
43+
type: ClusterIP
44+
port: 8000
45+
46+
nautobot:
47+
url: https://nautobot.example.com
48+
clusterDataConfigMapRef:
49+
name: cluster-data
50+
key: UNDERSTACK_PARTITION
51+
tokenSecretRef:
52+
name: nautobot-env
53+
key: NAUTOBOT_TOKEN
54+
```
55+
56+
## Install
57+
58+
```bash
59+
helm upgrade --install nautobot-target-proxy ./charts/nautobot-target-proxy -n nautobot
60+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
image:
2+
repository: ghcr.io/rackerlabs/understack/nautobot-target-proxy
3+
tag: "0.0.1"
4+
pullPolicy: IfNotPresent
5+
6+
nautobot:
7+
url: https://nautobot.example.com
8+
clusterDataConfigMapRef:
9+
name: cluster-data
10+
key: UNDERSTACK_PARTITION
11+
tokenSecretRef:
12+
name: nautobot-env
13+
key: NAUTOBOT_TOKEN
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "nautobot-target-proxy.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
*/}}
11+
{{- define "nautobot-target-proxy.fullname" -}}
12+
{{- if .Values.fullnameOverride }}
13+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
14+
{{- else }}
15+
{{- $name := default .Chart.Name .Values.nameOverride }}
16+
{{- if contains $name .Release.Name }}
17+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
18+
{{- else }}
19+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
20+
{{- end }}
21+
{{- end }}
22+
{{- end }}
23+
24+
{{/*
25+
Create chart name and version as used by the chart label.
26+
*/}}
27+
{{- define "nautobot-target-proxy.chart" -}}
28+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
29+
{{- end }}
30+
31+
{{/*
32+
Common labels
33+
*/}}
34+
{{- define "nautobot-target-proxy.labels" -}}
35+
helm.sh/chart: {{ include "nautobot-target-proxy.chart" . }}
36+
{{ include "nautobot-target-proxy.selectorLabels" . }}
37+
{{- if .Chart.AppVersion }}
38+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
39+
{{- end }}
40+
app.kubernetes.io/managed-by: {{ .Release.Service }}
41+
{{- end }}
42+
43+
{{/*
44+
Selector labels
45+
*/}}
46+
{{- define "nautobot-target-proxy.selectorLabels" -}}
47+
app.kubernetes.io/name: {{ include "nautobot-target-proxy.name" . }}
48+
app.kubernetes.io/instance: {{ .Release.Name }}
49+
{{- end }}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "nautobot-target-proxy.fullname" . }}
5+
labels:
6+
{{- include "nautobot-target-proxy.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
{{- include "nautobot-target-proxy.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
{{- with .Values.podAnnotations }}
15+
annotations:
16+
{{- toYaml . | nindent 8 }}
17+
{{- end }}
18+
labels:
19+
{{- include "nautobot-target-proxy.selectorLabels" . | nindent 8 }}
20+
spec:
21+
{{- with .Values.imagePullSecrets }}
22+
imagePullSecrets:
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
securityContext:
26+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
27+
containers:
28+
- name: {{ .Chart.Name }}
29+
securityContext:
30+
{{- toYaml .Values.securityContext | nindent 12 }}
31+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
32+
imagePullPolicy: {{ .Values.image.pullPolicy }}
33+
command:
34+
{{- toYaml .Values.command | nindent 12 }}
35+
args:
36+
{{- toYaml .Values.args | nindent 12 }}
37+
ports:
38+
- name: http
39+
containerPort: 8000
40+
protocol: TCP
41+
livenessProbe:
42+
tcpSocket:
43+
port: http
44+
readinessProbe:
45+
tcpSocket:
46+
port: http
47+
env:
48+
- name: NAUTOBOT_URL
49+
value: {{ required "values.nautobot.url is required" .Values.nautobot.url | quote }}
50+
- name: UNDERSTACK_PARTITION
51+
valueFrom:
52+
configMapKeyRef:
53+
name: {{ required "values.nautobot.clusterDataConfigMapRef.name is required" .Values.nautobot.clusterDataConfigMapRef.name | quote }}
54+
key: {{ required "values.nautobot.clusterDataConfigMapRef.key is required" .Values.nautobot.clusterDataConfigMapRef.key | quote }}
55+
- name: NAUTOBOT_TOKEN
56+
valueFrom:
57+
secretKeyRef:
58+
name: {{ required "values.nautobot.tokenSecretRef.name is required" .Values.nautobot.tokenSecretRef.name | quote }}
59+
key: {{ required "values.nautobot.tokenSecretRef.key is required" .Values.nautobot.tokenSecretRef.key | quote }}
60+
resources:
61+
{{- toYaml .Values.resources | nindent 12 }}
62+
{{- with .Values.nodeSelector }}
63+
nodeSelector:
64+
{{- toYaml . | nindent 8 }}
65+
{{- end }}
66+
{{- with .Values.affinity }}
67+
affinity:
68+
{{- toYaml . | nindent 8 }}
69+
{{- end }}
70+
{{- with .Values.tolerations }}
71+
tolerations:
72+
{{- toYaml . | nindent 8 }}
73+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "nautobot-target-proxy.fullname" . }}
5+
labels:
6+
{{- include "nautobot-target-proxy.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: http
12+
protocol: TCP
13+
name: http
14+
selector:
15+
{{- include "nautobot-target-proxy.selectorLabels" . | nindent 4 }}

0 commit comments

Comments
 (0)