You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by io...@apache.org on 2019/07/04 14:58:33 UTC

[incubator-dlab] branch DLAB-terraform updated: [DLAB-759] TF module for Mongo-HA [DLAB-836] TF module for nginx load balancer [DLAB-811] chart for dlab-ui

This is an automated email from the ASF dual-hosted git repository.

ioleksandr pushed a commit to branch DLAB-terraform
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/DLAB-terraform by this push:
     new 7733f96  [DLAB-759] TF module for Mongo-HA [DLAB-836] TF module for nginx load balancer [DLAB-811] chart for dlab-ui
7733f96 is described below

commit 7733f9665cc05adf4ee3772109b549a1dc13686e
Author: Oleksandr_Isniuk <i....@gmail.com>
AuthorDate: Thu Jul 4 17:58:16 2019 +0300

    [DLAB-759] TF module for Mongo-HA
    [DLAB-836] TF module for nginx load balancer
    [DLAB-811] chart for dlab-ui
---
 .../aws/modules/dlab-ui/dlab-ui-chart/.helmignore  | 22 ++++++++
 .../aws/modules/dlab-ui/dlab-ui-chart/Chart.yaml   |  5 ++
 .../dlab-ui/dlab-ui-chart/templates/NOTES.txt      | 21 ++++++++
 .../dlab-ui/dlab-ui-chart/templates/_helpers.tpl   | 45 ++++++++++++++++
 .../dlab-ui-chart/templates/deployment.yaml        | 52 ++++++++++++++++++
 .../dlab-ui/dlab-ui-chart/templates/ingress.yaml   | 35 +++++++++++++
 .../dlab-ui/dlab-ui-chart/templates/service.yaml   | 16 ++++++
 .../aws/modules/dlab-ui/dlab-ui-chart/values.yaml  | 49 +++++++++++++++++
 .../terraform/aws/modules/dlab-ui/dlab-ui.tf       | 20 +++++++
 .../terraform/aws/modules/mongo/mongo.tf           | 61 ++++++++++++++++++++++
 .../terraform/aws/modules/mongo/variables.tf       | 40 ++++++++++++++
 .../terraform/aws/modules/nginx/nginx.tf           | 48 +++++++++++++++++
 .../terraform/aws/modules/nginx/variables.tf       | 28 ++++++++++
 13 files changed, 442 insertions(+)

diff --git a/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/.helmignore b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/.helmignore
new file mode 100644
index 0000000..50af031
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/.helmignore
@@ -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/
diff --git a/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/Chart.yaml b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/Chart.yaml
new file mode 100644
index 0000000..0fe03fe
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/Chart.yaml
@@ -0,0 +1,5 @@
+apiVersion: v1
+appVersion: "1.0"
+description: A Helm chart for Kubernetes
+name: dlab-ui
+version: 0.1.0
diff --git a/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/NOTES.txt b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/NOTES.txt
new file mode 100644
index 0000000..27f3f3a
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/NOTES.txt
@@ -0,0 +1,21 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+  {{- range .paths }}
+  http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
+  {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+  export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "dlab-ui.fullname" . }})
+  export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+  echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+     NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+           You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "dlab-ui.fullname" . }}'
+  export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dlab-ui.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
+  echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+  export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "dlab-ui.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+  echo "Visit http://127.0.0.1:8080 to use your application"
+  kubectl port-forward $POD_NAME 8080:80
+{{- end }}
diff --git a/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/_helpers.tpl b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/_helpers.tpl
new file mode 100644
index 0000000..2686270
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/_helpers.tpl
@@ -0,0 +1,45 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "dlab-ui.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).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "dlab-ui.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 "dlab-ui.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Common labels
+*/}}
+{{- define "dlab-ui.labels" -}}
+app.kubernetes.io/name: {{ include "dlab-ui.name" . }}
+helm.sh/chart: {{ include "dlab-ui.chart" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end -}}
diff --git a/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/deployment.yaml b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/deployment.yaml
new file mode 100644
index 0000000..f585efb
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/deployment.yaml
@@ -0,0 +1,52 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: {{ include "dlab-ui.fullname" . }}
+  labels:
+{{ include "dlab-ui.labels" . | indent 4 }}
+spec:
+  replicas: {{ .Values.replicaCount }}
+  selector:
+    matchLabels:
+      app.kubernetes.io/name: {{ include "dlab-ui.name" . }}
+      app.kubernetes.io/instance: {{ .Release.Name }}
+  template:
+    metadata:
+      labels:
+        app.kubernetes.io/name: {{ include "dlab-ui.name" . }}
+        app.kubernetes.io/instance: {{ .Release.Name }}
+    spec:
+    {{- with .Values.imagePullSecrets }}
+      imagePullSecrets:
+        {{- toYaml . | nindent 8 }}
+    {{- end }}
+      containers:
+        - name: {{ .Chart.Name }}
+          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
+          imagePullPolicy: {{ .Values.image.pullPolicy }}
+          ports:
+            - name: https
+              containerPort: 443
+              protocol: TCP
+          livenessProbe:
+            httpGet:
+              path: /
+              port: http
+          readinessProbe:
+            httpGet:
+              path: /
+              port: http
+          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 }}
diff --git a/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/ingress.yaml b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/ingress.yaml
new file mode 100644
index 0000000..272c548
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/ingress.yaml
@@ -0,0 +1,35 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "dlab-ui.fullname" . -}}
+apiVersion: extensions/v1beta1
+kind: Ingress
+metadata:
+  name: {{ $fullName }}
+  labels:
+{{ include "dlab-ui.labels" . | indent 4 }}
+  {{- with .Values.ingress.annotations }}
+  annotations:
+    {{- toYaml . | nindent 4 }}
+  {{- end }}
+spec:
+{{- if .Values.ingress.tls }}
+  tls:
+  {{- range .Values.ingress.tls }}
+    - hosts:
+      {{- range .hosts }}
+        - {{ . | quote }}
+      {{- end }}
+      secretName: {{ .secretName }}
+  {{- end }}
+{{- end }}
+  rules:
+  {{- range .Values.ingress.rules }}
+    - http:
+        paths:
+        {{- range .paths }}
+          - path: {{ . }}
+            backend:
+              serviceName: {{ $fullName }}
+              servicePort: 443
+        {{- end }}
+  {{- end }}
+{{- end }}
\ No newline at end of file
diff --git a/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/service.yaml b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/service.yaml
new file mode 100644
index 0000000..647c879
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/templates/service.yaml
@@ -0,0 +1,16 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ include "dlab-ui.fullname" . }}
+  labels:
+{{ include "dlab-ui.labels" . | indent 4 }}
+spec:
+  type: {{ .Values.service.type }}
+  ports:
+    - port: {{ .Values.service.port }}
+      targetPort: 58443
+      protocol: TCP
+      name: https
+  selector:
+    app.kubernetes.io/name: {{ include "dlab-ui.name" . }}
+    app.kubernetes.io/instance: {{ .Release.Name }}
diff --git a/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/values.yaml b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/values.yaml
new file mode 100644
index 0000000..1c64e64
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui-chart/values.yaml
@@ -0,0 +1,49 @@
+# Default values for dlab-ui.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+  repository: koppox/dlab-ui
+  tag: '1.3-hardj'
+  pullPolicy: IfNotPresent
+
+#imagePullSecrets: []
+#nameOverride: ""
+#fullnameOverride: ""
+
+service:
+  type: NodePort
+  port: 58443
+
+ingress:
+  enabled: true
+  annotations: 
+    kubernetes.io/ingress.class: nginx
+    # kubernetes.io/tls-acme: "true"
+  rules:
+    - paths: [/]
+
+  tls: []
+  #  - secretName: chart-example-tls
+  #    hosts:
+  #      - chart-example.local
+labels: {}
+#resources: {}
+  # We usually recommend not to specify default resources and to leave this as a conscious
+  # choice for the user. This also increases chances charts run on environments with little
+  # resources, such as Minikube. If you do want to specify resources, uncomment the following
+  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+  # limits:
+  #   cpu: 100m
+  #   memory: 128Mi
+  # requests:
+  #   cpu: 100m
+  #   memory: 128Mi
+
+#nodeSelector: {}
+
+#tolerations: []
+
+#affinity: {}
diff --git a/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui.tf b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui.tf
new file mode 100644
index 0000000..04cd33e
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/dlab-ui/dlab-ui.tf
@@ -0,0 +1,20 @@
+# *****************************************************************************
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# ******************************************************************************
\ No newline at end of file
diff --git a/infrastructure-provisioning/terraform/aws/modules/mongo/mongo.tf b/infrastructure-provisioning/terraform/aws/modules/mongo/mongo.tf
new file mode 100644
index 0000000..6188f83
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/mongo/mongo.tf
@@ -0,0 +1,61 @@
+# *****************************************************************************
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# ******************************************************************************
+provider "helm" {
+    install_tiller  = true
+    namespace       = "kube-system"
+    service_account = "tiller"
+    tiller_image    = "gcr.io/kubernetes-helm/tiller:v2.14.1"
+}
+
+
+resource "helm_release" "my_mongo" {
+    name      = "mongo-ha"
+    chart     = "stable/mongodb"
+
+    set {
+        name  = "replicaSet.enabled"
+        value = "true"
+    }
+
+    set {
+        name = "mongodbRootPassword"
+        value = "${var.mongo_root_pwd}"
+    }
+
+    set {
+        name = "mongodbUsername"
+        value = "${var.mongo_db_username}"
+    }
+
+    set {
+        name = "mongodbPassword"
+        value = "${var.mongo_db_pwd}"
+    }
+
+    set {
+        name = "mongodbDatabase"
+        value = "${var.mongo_dbname}"
+    }
+    set {
+        name = "image.tag"
+        value = "${var.image_tag}"
+    }
+}
diff --git a/infrastructure-provisioning/terraform/aws/modules/mongo/variables.tf b/infrastructure-provisioning/terraform/aws/modules/mongo/variables.tf
new file mode 100644
index 0000000..16342e5
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/mongo/variables.tf
@@ -0,0 +1,40 @@
+# *****************************************************************************
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# ******************************************************************************
+variable "mongo_root_pwd" {
+    default = "$tr0ng_r00T-passworI)"
+    description = "Password for MongoDB root user"
+}
+variable "mongo_db_username" {
+    default = "admin"
+    description = "Password for MongoDB root user"
+}
+variable "mongo_db_pwd" {
+    default = "$tr0ng_N0N=r00T-passworI)"
+    description = "Password for MongoDB root user"
+}
+variable "mongo_dbname" {
+    default = "dlabdb"
+    description = "Password for MongoDB root user"
+}
+variable "image_tag" {
+    default = "4.0.10-debian-9-r13"
+    description = "MongoDB Image tag"
+}
\ No newline at end of file
diff --git a/infrastructure-provisioning/terraform/aws/modules/nginx/nginx.tf b/infrastructure-provisioning/terraform/aws/modules/nginx/nginx.tf
new file mode 100644
index 0000000..003b99b
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/nginx/nginx.tf
@@ -0,0 +1,48 @@
+# *****************************************************************************
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# ******************************************************************************
+provider "helm" {
+    install_tiller  = true
+    namespace       = "kube-system"
+    service_account = "tiller"
+    tiller_image    = "gcr.io/kubernetes-helm/tiller:v2.14.1"
+}
+
+
+resource "helm_release" "my_mongo" {
+    name      = "nginx-ingress"
+    chart     = "stable/nginx-ingress"
+
+    set {
+        name = "controller.service.nodePorts.http"
+        value = "${var.mongo_root_pwd}"
+    }
+
+    set {
+        name = "controller.service.nodePorts.https"
+        value = "${var.mongo_db_username}"
+    }
+
+    set {
+        name = "controller.service.type"
+        value = "NodePort"
+    }
+
+}
diff --git a/infrastructure-provisioning/terraform/aws/modules/nginx/variables.tf b/infrastructure-provisioning/terraform/aws/modules/nginx/variables.tf
new file mode 100644
index 0000000..d6d6143
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/modules/nginx/variables.tf
@@ -0,0 +1,28 @@
+# *****************************************************************************
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# ******************************************************************************
+variable "nginx_http_port" {
+    default = "31080"
+    description = "Sets the nodePort that maps to the Ingress' port 80"
+}
+variable "nginx_https_port" {
+    default = "31443"
+    description = "Sets the nodePort that maps to the Ingress' port 443"
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org