-
Notifications
You must be signed in to change notification settings - Fork 9
feat(nautobot-target-proxy): Moves nautobot-target-proxy in to Understack #1957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f52e44c
5b031f0
099ea70
adfe658
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| syncOptions: | ||
| - CreateNamespace=true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }} | ||
| 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 |
| 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 | ||
| ``` |
| 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 |
| 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 }} |
| 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 }} |
| 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 }} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?