Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Add option to set MongoDB URL string in a secret #568

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion chart/monocular/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
name: monocular
description: Monocular is a search and discovery front end for Helm Charts Repositories.
version: 1.2.4
version: 1.3.0
appVersion: v1.0.3
home: https://github.com/helm/monocular
sources:
Expand Down
1 change: 1 addition & 0 deletions chart/monocular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@ $ helm install monocular/monocular -f custom-domains.yaml
| `ingress.annotations` | Ingress annotations | `{ingress.kubernetes.io/rewrite-target: /, kubernetes.io/ingress.class: nginx}` |
| `ingress.tls` | TLS configuration for the Ingress object | `nil` |
| `global.mongoUrl` | External MongoDB connection URL | `nil` |
| `global.mongoUrlSecret` | External MongoDB connection URL secret | `nil` |
6 changes: 6 additions & 0 deletions chart/monocular/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ Point your Ingress hosts to the address from the output of the above command:
{{ end -}}

Visit https://github.com/helm/monocular for more information.

{{- if .Values.global.mongoUrlSecret }}
If you have not already created the external MongoDB connection URL secret:

kubectl create secret generic {{ .Values.global.mongoUrlSecret }} --namespace {{ .Release.Namespace }} --from-file=./mongo-url-secret
{{- end }}
17 changes: 13 additions & 4 deletions chart/monocular/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,37 @@ spec:
args:
- sync
- --user-agent-comment=monocular/{{ $global.Chart.AppVersion }}
{{- if and $global.Values.global.mongoUrl (not $global.Values.mongodb.enabled) }}
- --mongo-url={{ $global.Values.global.mongoUrl }}
{{- else }}
{{- if $global.Values.mongodb.enabled }}
- --mongo-url={{ template "mongodb.fullname" $global }}
- --mongo-user=root
{{- else if $global.Values.global.mongoUrl }}
- --mongo-url={{ $global.Values.global.mongoUrl }}
{{- else if $global.Values.global.mongoUrlSecret }}
- --mongo-url={{ "$MONGO_URL" }}
Copy link
Member

Choose a reason for hiding this comment

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

Are the {{ }} needed here? I think this could just be

Suggested change
- --mongo-url={{ "$MONGO_URL" }}
- --mongo-url="$MONGO_URL"

{{- end }}
- {{ $repo.name }}
- {{ $repo.url }}
command:
- /chart-repo
{{- if $global.Values.mongodb.enabled }}
env:
- name: HTTP_PROXY
value: {{ $global.Values.sync.httpProxy }}
- name: HTTPS_PROXY
value: {{ $global.Values.sync.httpsProxy }}
{{- if $global.Values.mongodb.enabled }}
- name: MONGO_PASSWORD
valueFrom:
secretKeyRef:
key: mongodb-root-password
name: {{ template "mongodb.fullname" $global }}
{{- end }}
{{- if $global.Values.global.mongoUrlSecret }}
Copy link
Member

Choose a reason for hiding this comment

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

this could be elseif I guess, though does not really matter much...

- name: MONGO_URL
valueFrom:
secretKeyRef:
name: {{ $global.Values.global.mongoUrlSecret }}
key: mongo-url-secret
{{- end }}
resources:
{{ toYaml $global.Values.sync.resources | indent 6 }}
{{- with $global.Values.sync.nodeSelector }}
Expand Down
20 changes: 16 additions & 4 deletions chart/monocular/templates/chartsvc-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,30 @@ spec:
command:
- /chartsvc
args:
{{- if and .Values.global.mongoUrl (not .Values.mongodb.enabled) }}
- --mongo-url={{ .Values.global.mongoUrl }}
{{- else }}
- --mongo-user=root
{{- if .Values.mongodb.enabled }}
- --mongo-url={{ template "mongodb.fullname" . }}
- --mongo-user=root
{{- else if .Values.global.mongoUrl }}
- --mongo-url={{ .Values.global.mongoUrl }}
{{- else if .Values.global.mongoUrlSecret }}
- --mongo-url={{ "$MONGO_URL" }}
{{- end }}
{{- if .Values.mongodb.enabled }}
env:
- name: MONGO_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "mongodb.fullname" . }}
key: mongodb-root-password
{{- end }}
{{- if .Values.global.mongoUrlSecret }}
env:
- name: MONGO_URL
valueFrom:
secretKeyRef:
name: {{ .Values.global.mongoUrlSecret }}
key: mongo-url-secret
{{- end }}
ports:
- name: http
containerPort: {{ .Values.chartsvc.service.port }}
Expand Down
5 changes: 5 additions & 0 deletions chart/monocular/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,10 @@ mongodb:
# This must be set if mongodb.enabled is set to false, following the pattern:
# `mongodb://${MONGODB_USER}:${MONGODB_ROOT_PASSWORD}@${MONGODB_DNS}:${MONGODB_PORT}/${MONGODB_DATABASE}`
# ref: https://docs.mongodb.com/manual/reference/connection-string/
# You may set the connection URL in one of two ways:
# - mongoUrl: store the connection string directly in Helm values
# - mongoUrlSecret: name of the secret where the connection string is stored,
# where the key is "mongo-url-secret". See NOTES.txt.
global:
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about moving this configuration to externalDatabase? e.g. https://github.com/helm/charts/blob/master/stable/wordpress/values.yaml#L78. Then in the future we are one step closer to splitting up the options in host, user, password, etc. It would make this a breaking change, but I doubt anyone is using this setting yet so the risk should be very low.

mongoUrl:
mongoUrlSecret: