-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Mongodb DBAAS operator (PR2403 & PR2411) (#2416)
- Loading branch information
Toby Bellwood
authored
Feb 10, 2021
1 parent
bdf71d5
commit ee09835
Showing
44 changed files
with
1,589 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
images/kubectl-build-deploy-dind/helmcharts/mongodb-dbaas/.helmignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
17 changes: 17 additions & 0 deletions
17
images/kubectl-build-deploy-dind/helmcharts/mongodb-dbaas/Chart.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: v2 | ||
name: mongodb-dbaas | ||
description: A Helm chart for Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
version: 0.1.0 |
79 changes: 79 additions & 0 deletions
79
images/kubectl-build-deploy-dind/helmcharts/mongodb-dbaas/templates/_helpers.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "mongodb-dbaas.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
*/}} | ||
{{- define "mongodb-dbaas.fullname" -}} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "mongodb-dbaas.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create full hostname for autogenerated hosts | ||
*/}} | ||
{{- define "mongodb-dbaas.autogeneratedHost" -}} | ||
{{- printf "%s.%s" .Release.Name .Values.routesAutogenerateSuffix | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{- define "mongodb-dbaas.fullnameUppercase" -}} | ||
{{ include "mongodb-dbaas.fullname" . | upper | replace "-" "_" }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "mongodb-dbaas.labels" -}} | ||
helm.sh/chart: {{ include "mongodb-dbaas.chart" . }} | ||
{{ include "mongodb-dbaas.selectorLabels" . }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{ include "mongodb-dbaas.lagoonLabels" . }} | ||
|
||
{{- end -}} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "mongodb-dbaas.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "mongodb-dbaas.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Lagoon Labels | ||
*/}} | ||
{{- define "mongodb-dbaas.lagoonLabels" -}} | ||
lagoon.sh/service: {{ .Release.Name }} | ||
lagoon.sh/service-type: {{ .Chart.Name }} | ||
lagoon.sh/project: {{ .Values.project }} | ||
lagoon.sh/environment: {{ .Values.environment }} | ||
lagoon.sh/environmentType: {{ .Values.environmentType }} | ||
lagoon.sh/buildType: {{ .Values.buildType }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Annotations | ||
*/}} | ||
{{- define "mongodb-dbaas.annotations" -}} | ||
lagoon.sh/version: {{ .Values.lagoonVersion | quote }} | ||
{{- if .Values.branch }} | ||
lagoon.sh/branch: {{ .Values.branch | quote }} | ||
{{- end }} | ||
{{- if .Values.prNumber }} | ||
lagoon.sh/prNumber: {{ .Values.prNumber | quote }} | ||
lagoon.sh/prHeadBranch: {{ .Values.prHeadBranch | quote }} | ||
lagoon.sh/prBaseBranch: {{ .Values.prBaseBranch | quote }} | ||
{{- end }} | ||
{{- end -}} |
11 changes: 11 additions & 0 deletions
11
images/kubectl-build-deploy-dind/helmcharts/mongodb-dbaas/templates/dbaas.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: mongodb.amazee.io/v1 | ||
kind: MongoDBConsumer | ||
metadata: | ||
name: {{ include "mongodb-dbaas.fullname" . }} | ||
labels: | ||
{{- include "mongodb-dbaas.labels" . | nindent 4 }} | ||
annotations: | ||
{{- include "mongodb-dbaas.annotations" . | nindent 4 }} | ||
|
||
spec: | ||
environment: {{ .Values.environment}} |
5 changes: 5 additions & 0 deletions
5
images/kubectl-build-deploy-dind/helmcharts/mongodb-dbaas/values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Default values for nginx. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
environment: "" |
36 changes: 36 additions & 0 deletions
36
images/kubectl-build-deploy-dind/scripts/exec-kubectl-mongodb-dbaas.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# The operator can sometimes take a bit, wait until the details are available | ||
# We added a timeout of 10 minutes (120 retries) before exit | ||
OPERATOR_COUNTER=1 | ||
OPERATOR_TIMEOUT=180 | ||
# use the secret name from the consumer to prevent credential clash | ||
until kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get mongodbconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.consumer.database | ||
do | ||
if [ $OPERATOR_COUNTER -lt $OPERATOR_TIMEOUT ]; then | ||
let SERVICE_BROKER_COUNTER=SERVICE_BROKER_COUNTER+1 | ||
echo "Service for ${SERVICE_NAME} not available yet, waiting for 5 secs" | ||
sleep 5 | ||
else | ||
echo "Timeout of $OPERATOR_TIMEOUT for ${SERVICE_NAME} creation reached" | ||
exit 1 | ||
fi | ||
done | ||
set +x | ||
# Grab the details from the consumer spec | ||
DB_HOST=$(kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get mongodbconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.consumer.services.primary) | ||
DB_USER=$(kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get mongodbconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.consumer.username) | ||
DB_PASSWORD=$(kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get mongodbconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.consumer.password) | ||
DB_NAME=$(kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get mongodbconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.consumer.database) | ||
DB_PORT=$(kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get mongodbconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.provider.port) | ||
DB_AUTHSOURCE=$(kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get mongodbconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.provider.auth.source) | ||
DB_AUTHMECHANISM=$(kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get mongodbconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.provider.auth.mechanism) | ||
DB_AUTHTLS=$(kubectl --insecure-skip-tls-verify -n ${NAMESPACE} get mongodbconsumer/${SERVICE_NAME} -o yaml | shyaml get-value spec.provider.auth.tls) | ||
|
||
# Add credentials to our configmap, prefixed with the name of the servicename of this servicebroker | ||
kubectl patch --insecure-skip-tls-verify \ | ||
-n ${NAMESPACE} \ | ||
configmap lagoon-env \ | ||
-p "{\"data\":{\"${SERVICE_NAME_UPPERCASE}_HOST\":\"${DB_HOST}\", \"${SERVICE_NAME_UPPERCASE}_USERNAME\":\"${DB_USER}\", \"${SERVICE_NAME_UPPERCASE}_PASSWORD\":\"${DB_PASSWORD}\", \"${SERVICE_NAME_UPPERCASE}_DATABASE\":\"${DB_NAME}\", \"${SERVICE_NAME_UPPERCASE}_PORT\":\"${DB_PORT}\", \"${SERVICE_NAME_UPPERCASE}_AUTHSOURCE\":\"${DB_AUTHSOURCE}\", \"${SERVICE_NAME_UPPERCASE}_AUTHMECHANISM\":\"${DB_AUTHMECHANISM}\", \"${SERVICE_NAME_UPPERCASE}_AUTHTLS\":\"${DB_AUTHTLS}\" }}" | ||
|
||
set -x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.