Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/containers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "containers/ansible/**"
- "containers/dnsmasq/**"
- "containers/ironic-nautobot-client/**"
- "containers/nautobot-target-proxy/**"
- "containers/ironic-vnc-client/**"
- "containers/understack-tests/**"
- "python/**"
Expand All @@ -34,6 +35,8 @@ jobs:
target: prod
- name: ironic-nautobot-client
target: prod
- name: nautobot-target-proxy
target: prod
- name: understack-tests
target: prod
- name: ironic-vnc-container
Expand Down
1 change: 1 addition & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ignore:
- charts/argocd-understack/templates/
- charts/nautobot-api-tokens/templates/
- charts/nautobot-job-queues/templates/
- charts/nautobot-target-proxy/templates/
- charts/site-workflows/templates/
- charts/undersync/templates/

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{- if eq (include "understack.isEnabled" (list $.Values.site "nautobot_target_proxy")) "true" }}
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: {{ printf "%s-%s" $.Release.Name "nautobot-target-proxy" }}
finalizers:
- resources-finalizer.argocd.argoproj.io
annotations:
argocd.argoproj.io/compare-options: ServerSideDiff=true,IncludeMutationWebhook=true
{{- include "understack.appLabelsBlock" $ | nindent 2 }}
spec:
destination:
namespace: nautobot
server: {{ $.Values.cluster_server }}
project: understack
sources:
- helm:
releaseName: nautobot-target-proxy
ignoreMissingValueFiles: true
valueFiles:
- $understack/components/nautobot-target-proxy/values.yaml
- $deploy/{{ include "understack.deploy_path" $ }}/nautobot-target-proxy/values.yaml
path: charts/nautobot-target-proxy
ref: understack
repoURL: {{ include "understack.understack_url" $ }}
targetRevision: {{ include "understack.understack_ref" $ }}
- path: {{ include "understack.deploy_path" $ }}/nautobot-target-proxy
ref: deploy
repoURL: {{ include "understack.deploy_url" $ }}
targetRevision: {{ include "understack.deploy_ref" $ }}
syncPolicy:
automated:
prune: true
selfHeal: true
managedNamespaceMetadata:
annotations:
argocd.argoproj.io/sync-options: Delete=false
Comment on lines +36 to +38
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't want this if the namespace is created by the site worker

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this protect against deletions which is what we want?

syncOptions:
- CreateNamespace=true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The namespace is probably created by the site worker so we don't want this line.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I question whether it matters, but if it does matter, I think the assumption that nautobot-worker creates it is wrong, since nautobot-target-proxy comes before nautobot-worker alphabetically.

- ServerSideApply=true
- RespectIgnoreDifferences=true
- ApplyOutOfSyncOnly=true
{{- end }}
6 changes: 6 additions & 0 deletions charts/argocd-understack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@ site:
# @default -- false
enabled: false

# -- Nautobot target proxy service
nautobot_target_proxy:
# -- Enable/disable deploying the nautobot-target-proxy Helm chart
# @default -- false
enabled: false

# -- OpenEBS
openebs:
# -- Enable/disable deploying OpenEBS
Expand Down
8 changes: 8 additions & 0 deletions charts/nautobot-target-proxy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v2
name: nautobot-target-proxy
description: FastAPI service that exposes Nautobot GraphQL targets for Prometheus HTTP service discovery
type: application
version: 0.1.0
appVersion: "0.0.1"
maintainers:
- name: rackerlabs
63 changes: 63 additions & 0 deletions charts/nautobot-target-proxy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# nautobot-target-proxy

Helm chart that deploys the `nautobot_target_proxy` FastAPI service.

## Behavior

- Runs the proxy as a Kubernetes `Deployment`.
- Exposes the app internally with a Kubernetes `Service`.
- Starts the container with `uvicorn nautobot_target_proxy.app:app --host 0.0.0.0 --port 8000`.
- Injects `NAUTOBOT_URL` directly from values.
- Injects `NAUTOBOT_LOCATION` directly from values.
- Injects `UNDERSTACK_PARTITION` from the shared `cluster-data` ConfigMap.
- Injects `NAUTOBOT_TOKEN` from a referenced Kubernetes Secret.
- Uses TCP liveness and readiness probes on port `8000`.

## Image behavior

- Default image repository is `ghcr.io/rackerlabs/understack/nautobot-target-proxy`.
- Default tag comes from chart `appVersion` (currently `0.0.1`).
- You can override image repository/tag/pullPolicy in values.

## Required values

```yaml
nautobot:
url: https://nautobot.example.com
location: dev
clusterDataConfigMapRef:
name: cluster-data
key: UNDERSTACK_PARTITION
tokenSecretRef:
name: nautobot-env
key: NAUTOBOT_TOKEN
```

## Example values

```yaml
image:
repository: ghcr.io/rackerlabs/understack/nautobot-target-proxy
tag: "0.0.1"
pullPolicy: IfNotPresent

service:
type: ClusterIP
port: 8000

nautobot:
url: https://nautobot.example.com
location: dev
clusterDataConfigMapRef:
name: cluster-data
key: UNDERSTACK_PARTITION
tokenSecretRef:
name: nautobot-env
key: NAUTOBOT_TOKEN
```

## Install

```bash
helm upgrade --install nautobot-target-proxy ./charts/nautobot-target-proxy -n nautobot
```
14 changes: 14 additions & 0 deletions charts/nautobot-target-proxy/ci/example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
image:
repository: ghcr.io/rackerlabs/understack/nautobot-target-proxy
tag: "0.0.1"
pullPolicy: IfNotPresent

nautobot:
url: https://nautobot.example.com
location: dev
clusterDataConfigMapRef:
name: cluster-data
key: UNDERSTACK_PARTITION
tokenSecretRef:
name: nautobot-env
key: NAUTOBOT_TOKEN
49 changes: 49 additions & 0 deletions charts/nautobot-target-proxy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "nautobot-target-proxy.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
*/}}
{{- define "nautobot-target-proxy.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "nautobot-target-proxy.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "nautobot-target-proxy.labels" -}}
helm.sh/chart: {{ include "nautobot-target-proxy.chart" . }}
{{ include "nautobot-target-proxy.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "nautobot-target-proxy.selectorLabels" -}}
app.kubernetes.io/name: {{ include "nautobot-target-proxy.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
75 changes: 75 additions & 0 deletions charts/nautobot-target-proxy/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "nautobot-target-proxy.fullname" . }}
labels:
{{- include "nautobot-target-proxy.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "nautobot-target-proxy.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "nautobot-target-proxy.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
{{- toYaml .Values.command | nindent 12 }}
args:
{{- toYaml .Values.args | nindent 12 }}
ports:
- name: http
containerPort: 8000
protocol: TCP
livenessProbe:
tcpSocket:
port: http
readinessProbe:
tcpSocket:
port: http
env:
- name: NAUTOBOT_URL
value: {{ required "values.nautobot.url is required" .Values.nautobot.url | quote }}
- name: NAUTOBOT_LOCATION
value: {{ required "values.nautobot.location is required" .Values.nautobot.location | quote }}
- name: UNDERSTACK_PARTITION
valueFrom:
configMapKeyRef:
name: {{ required "values.nautobot.clusterDataConfigMapRef.name is required" .Values.nautobot.clusterDataConfigMapRef.name | quote }}
key: {{ required "values.nautobot.clusterDataConfigMapRef.key is required" .Values.nautobot.clusterDataConfigMapRef.key | quote }}
- name: NAUTOBOT_TOKEN
valueFrom:
secretKeyRef:
name: {{ required "values.nautobot.tokenSecretRef.name is required" .Values.nautobot.tokenSecretRef.name | quote }}
key: {{ required "values.nautobot.tokenSecretRef.key is required" .Values.nautobot.tokenSecretRef.key | quote }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/nautobot-target-proxy/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "nautobot-target-proxy.fullname" . }}
labels:
{{- include "nautobot-target-proxy.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "nautobot-target-proxy.selectorLabels" . | nindent 4 }}
Loading
Loading