You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by om...@apache.org on 2019/07/25 10:49:22 UTC

[incubator-dlab] branch DLAB-terraform updated: [DLAB-941]: Added ConfigMaps for DLab Java services

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

omartushevskyi 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 7cbc243  [DLAB-941]: Added ConfigMaps for DLab Java services
7cbc243 is described below

commit 7cbc243b8772930ae5d2ed9f8417c556915750c9
Author: Oleh Martushevskyi <Ol...@epam.com>
AuthorDate: Thu Jul 25 13:49:12 2019 +0300

    [DLAB-941]: Added ConfigMaps for DLab Java services
---
 .../templates/configmap-billing-yml.yaml           | 105 +++++++++++++++++++++
 .../dlab-billing-chart/templates/deployment.yaml   |   9 ++
 .../main/dlab-billing-chart/values.yaml            |  23 ++---
 .../aws/ssn-helm-charts/main/dlab-billing.tf       |  15 +++
 .../dlab-ui-chart/templates/configmap-ssn-yml.yaml |  77 +++++++++++++++
 .../main/dlab-ui-chart/templates/deployment.yaml   |   9 ++
 .../ssn-helm-charts/main/dlab-ui-chart/values.yaml |  31 ++----
 .../terraform/aws/ssn-helm-charts/main/dlab-ui.tf  |  27 ++++--
 .../main/files/configure_keycloak.sh               |  10 +-
 .../ssn-helm-charts/main/files/mongo_values.yaml   |   3 +-
 .../terraform/aws/ssn-helm-charts/main/mongo.tf    |  12 ++-
 .../aws/ssn-helm-charts/main/variables.tf          |  12 +++
 .../aws/ssn-k8s/main/files/masters-user-data.sh    |  20 ++--
 .../aws/ssn-k8s/main/files/workers-user-data.sh    |   6 +-
 14 files changed, 288 insertions(+), 71 deletions(-)

diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing-chart/templates/configmap-billing-yml.yaml b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing-chart/templates/configmap-billing-yml.yaml
new file mode 100644
index 0000000..10d2144
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing-chart/templates/configmap-billing-yml.yaml
@@ -0,0 +1,105 @@
+{{- /*
+# *****************************************************************************
+#
+# 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.
+#
+# ******************************************************************************
+*/ -}}
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ include "dlab-billing.fullname" . }}-billing-yml
+data:
+  billing.yml: |
+    # Specify the parameters enclosed in angle brackets.
+    # Run the follows command to get help for details of configuration:
+    # java -jar billing-1.0.jar --help conf
+    # java -jar billing-1.0.jar --help {adapter | parser | filter | logappender} [name]
+
+    billingEnabled: true
+
+    host: {{ .Values.billing.mongo.host }}
+    port: {{ .Values.billing.mongo.port }}
+    username: {{ .Values.billing.mongo.username }}
+    password: {{ .Values.billing.mongo.password }}
+    database: {{ .Values.billing.mongo.db_name }}
+
+    scheduler:
+    # Schedule is comma separated values of time in format hh[:mm[:ss]]. hh - in the 24-hour clock, at 8:15PM is 20:15.
+      schedule: 8:40, 8:50, 9:00, 9:10, 9:20, 9:30, 16:00, 16:30, 17:00, 17:30, 18:00, 15:45, 16:45, 17:45, 17:15, 18:15, 18:00, 21:00
+
+    # Adapter for reading source data. Known types: file, s3file
+    adapterIn:
+      - type: s3file
+        bucket: dlab-billing-reports
+        path:
+        awsJobEnabled: false
+        accountId: 203753054073
+        accessKeyId:
+        secretAccessKey:
+
+    # Adapter for writing converted data. Known types: console, file, s3file, mongodb
+    adapterOut:
+      - type: mongodlab
+        host: {{ .Values.billing.mongo.host }}
+        port: {{ .Values.billing.mongo.port }}
+        username: {{ .Values.billing.mongo.username }}
+        password: {{ .Values.billing.mongo.password }}
+        database: {{ .Values.billing.mongo.db_name }}
+    #    bufferSize: 10000
+        upsert: true
+
+    # Filter for source and converted data.
+    filter:
+      - type: aws
+        currencyCode: USD
+        columnDlabTag: user:user:tag
+        serviceBaseName: dem5-k8s
+
+
+    # Parser of source data to common format.
+    parser:
+      - type: csv
+        headerLineNo: 1
+        skipLines: 1
+        columnMapping: >-
+          dlab_id=user:user:tag;usage_date=UsageStartDate;product=ProductName;
+          usage_type=UsageType;usage=UsageQuantity;cost=BlendedCost;
+          resource_id=ResourceId;tags=Operation,ItemDescription
+        aggregate: day
+
+
+    # Logging configuration.
+    logging:
+     # Default logging level
+      level: INFO
+      # Logging levels for appenders.
+      loggers:
+        com.epam: DEBUG
+        org.apache.http: WARN
+        org.mongodb.driver: WARN
+        org.hibernate: WARN
+     # Logging appenders
+      appenders:
+        #- type: console
+        - type: file
+          currentLogFilename: /root/billing.log
+          archive: true
+          archivedLogFilenamePattern: /root/billing-%d{yyyy-MM-dd}.log.gz
+          archivedFileCount: 10
diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing-chart/templates/deployment.yaml b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing-chart/templates/deployment.yaml
index 4205481..06c9e17 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing-chart/templates/deployment.yaml
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing-chart/templates/deployment.yaml
@@ -53,6 +53,15 @@ spec:
               protocol: TCP
           resources:
             {{- toYaml .Values.resources | nindent 12 }}
+          volumeMounts:
+            - name: billing-yml
+              mountPath: /root/
+              readOnly: true
+        volumes:
+          - name: billing-yml
+            configMap:
+              name: {{ include "dlab-billing.fullname" . }}-billing-yml
+              defaultMode: 0644
       {{- with .Values.nodeSelector }}
       nodeSelector:
         {{- toYaml . | nindent 8 }}
diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing-chart/values.yaml b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing-chart/values.yaml
index a6236ef..57e98ef 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing-chart/values.yaml
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing-chart/values.yaml
@@ -52,20 +52,11 @@ ingress:
   #    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: {}
\ No newline at end of file
+billing:
+  mongo:
+    host: ${mongo_service_name}
+    port: ${mongo_port}
+    username: ${mongo_user}
+    password: ${mongo_db_password}
+    db_name: ${mongo_db_name}
\ No newline at end of file
diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing.tf b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing.tf
index a1b30d7..7546f6b 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing.tf
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-billing.tf
@@ -19,9 +19,24 @@
 #
 # ******************************************************************************
 
+data "template_file" "dlab_billing_values" {
+  template = file("./dlab-billing-chart/values.yaml")
+  vars = {
+      mongo_db_name       = var.mongo_dbname
+      mongo_db_password   = var.mongo_db_pwd
+      mongo_user          = var.mongo_db_username
+      mongo_port          = var.mongo_service_port
+      mongo_service_name  = var.mongo_service_name
+  }
+}
+
 resource "helm_release" "dlab-billing" {
     name      = "dlab-billing"
     chart     = "./dlab-billing-chart"
     depends_on = [helm_release.mongodb]
     wait = true
+
+    values     = [
+        data.template_file.dlab_billing_values.rendered
+    ]
 }
diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui-chart/templates/configmap-ssn-yml.yaml b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui-chart/templates/configmap-ssn-yml.yaml
new file mode 100644
index 0000000..3322e95
--- /dev/null
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui-chart/templates/configmap-ssn-yml.yaml
@@ -0,0 +1,77 @@
+{{- /*
+# *****************************************************************************
+#
+# 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.
+#
+# ******************************************************************************
+*/ -}}
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ include "dlab-ui.fullname" . }}-ssn-yml
+data:
+  ssn.yml: |
+    <#assign LOG_ROOT_DIR="/var/opt/dlab/log">
+    <#assign KEYS_DIR="/root/keys">
+    <#assign KEY_STORE_PATH="/root/keys/dlab.keystore.jks">
+    <#assign KEY_STORE_PASSWORD="jhMDPlwgGb">
+    <#assign TRUST_STORE_PATH="/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts">
+    <#assign TRUST_STORE_PASSWORD="changeit">
+
+    # Available options are aws, azure, gcp
+    <#assign CLOUD_TYPE="aws">
+    cloudProvider: ${CLOUD_TYPE}
+
+    #Switch on/off developer mode here
+    <#assign DEV_MODE="false">
+    devMode: ${DEV_MODE}
+
+    mongo:
+      host: {{ .Values.dlab-ui.mongo.host }}
+      port: {{ .Values.dlab-ui.mongo.port }}
+      username: {{ .Values.dlab-ui.mongo.username }}
+      password: {{ .Values.dlab-ui.mongo.password }}
+      database: {{ .Values.dlab-ui.mongo.db_name }}
+
+    selfService:
+      protocol: https
+      host: 172.17.0.1
+      port: 8443
+      jerseyClient:
+        timeout: 3s
+        connectionTimeout: 3s
+
+    securityService:
+      protocol: https
+      host: 172.17.0.1
+      port: 8090
+      jerseyClient:
+        timeout: 20s
+        connectionTimeout: 20s
+
+    provisioningService:
+      protocol: https
+      host: 172.17.0.1
+      port: 8084
+      jerseyClient:
+        timeout: 3s
+        connectionTimeout: 3s
+
+    # Log out user on inactivity
+    inactiveUserTimeoutMillSec: 7200000
\ No newline at end of file
diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui-chart/templates/deployment.yaml b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui-chart/templates/deployment.yaml
index 1fdaba0..d270f47 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui-chart/templates/deployment.yaml
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui-chart/templates/deployment.yaml
@@ -64,6 +64,15 @@ spec:
 #              port: http
           resources:
             {{- toYaml .Values.resources | nindent 12 }}
+          volumeMounts:
+            - name: ssn-yml
+              mountPath: /root/
+              readOnly: true
+        volumes:
+          - name: ssn-yml
+            configMap:
+              name: {{ include "dlab-ui.fullname" . }}-ssn-yml
+              defaultMode: 0644
       {{- with .Values.nodeSelector }}
       nodeSelector:
         {{- toYaml . | nindent 8 }}
diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui-chart/values.yaml b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui-chart/values.yaml
index 17e533b..dd545e6 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui-chart/values.yaml
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui-chart/values.yaml
@@ -28,13 +28,8 @@ replicaCount: 1
 image:
   repository: koppox/dlab-ui
   tag: '1.3-hardj'
-  # pullPolicy: IfNotPresent
   pullPolicy: Always
 
-#imagePullSecrets: []
-#nameOverride: ""
-#fullnameOverride: ""
-
 service:
   type: NodePort
 #  port: 58443
@@ -42,31 +37,21 @@ service:
 
 ingress:
   enabled: true
-  host: ""
+  host: ${ssn_k8s_alb_dns_name}
   annotations: 
     kubernetes.io/ingress.class: nginx
     nginx.ingress.kubernetes.io/ssl-redirect: "false"
-    # kubernetes.io/tls-acme: "true"
 
   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: {}
+dlab-ui:
+  mongo:
+    host: ${mongo_service_name}
+    port: ${mongo_port}
+    username: ${mongo_user}
+    password: ${mongo_db_password}
+    db_name: ${mongo_db_name}
diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui.tf b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui.tf
index e7c1dd7..8671c6a 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui.tf
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/dlab-ui.tf
@@ -19,14 +19,25 @@
 #
 # ******************************************************************************
 
-resource "helm_release" "dlab-ui" {
-    name      = "dlab-ui"
-    chart     = "./dlab-ui-chart"
+data "template_file" "dlab_ui_values" {
+  template = file("./dlab-ui-chart/values.yaml")
+  vars = {
+      mongo_db_name       = var.mongo_dbname
+      mongo_db_password   = var.mongo_db_pwd
+      mongo_user          = var.mongo_db_username
+      mongo_port          = var.mongo_service_port
+      mongo_service_name  = var.mongo_service_name
+      ssn_k8s_alb_dns_name = var.ssn_k8s_alb_dns_name
+  }
+}
+
+resource "helm_release" "dlab_ui" {
+    name       = "dlab-ui"
+    chart      = "./dlab-ui-chart"
     depends_on = [helm_release.mongodb]
-    wait = true
+    wait       = true
 
-    set {
-        name = "ingress.host"
-        value = var.ssn_k8s_alb_dns_name
-    }
+    values     = [
+        data.template_file.dlab_ui_values.rendered
+    ]
 }
diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/files/configure_keycloak.sh b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/files/configure_keycloak.sh
index 8db3ded..582eeb9 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/files/configure_keycloak.sh
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/files/configure_keycloak.sh
@@ -23,17 +23,17 @@
       # 6 spaces needed as this file will be pasted in keycloak_values.yaml by Terraform
       set -x
       auth () {
-          RUN=`/opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://127.0.0.1:8080/auth --realm master \
-          --user ${keycloak_user} --password ${keycloak_passowrd} > /dev/null && echo "true" || echo "false"`
+          RUN=$(/opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://127.0.0.1:8080/auth --realm master \
+          --user ${keycloak_user} --password ${keycloak_passowrd} > /dev/null && echo "true" || echo "false")
       }
       check_realm () {
-          RUN=`/opt/jboss/keycloak/bin/kcadm.sh get realms/dlab > /dev/null && echo "true" || echo "false"`
+          RUN=$(/opt/jboss/keycloak/bin/kcadm.sh get realms/dlab > /dev/null && echo "true" || echo "false")
       }
       configure_keycloak () {
           # Create Realm
           /opt/jboss/keycloak/bin/kcadm.sh create realms -s realm=dlab -s enabled=true
           # Get realm ID
-          dlab_realm_id=`/opt/jboss/keycloak/bin/kcadm.sh get realms/dlab | /usr/bin/jq -r '.id'`
+          dlab_realm_id=$(/opt/jboss/keycloak/bin/kcadm.sh get realms/dlab | /usr/bin/jq -r '.id')
           # Create user federation
           /opt/jboss/keycloak/bin/kcadm.sh create components -r dlab -s name=dlab-ldap -s providerId=ldap \
           -s providerType=org.keycloak.storage.UserStorageProvider -s parentId=$dlab_realm_id  -s 'config.priority=["1"]' \
@@ -49,7 +49,7 @@
           -s 'config.useTruststoreSpi=["ldapsOnly"]' -s 'config.connectionPooling=["true"]' \
           -s 'config.pagination=["true"]' --server http://127.0.0.1:8080/auth
           # Get user federation ID
-          user_f_id=`/opt/jboss/keycloak/bin/kcadm.sh get components -r dlab --query name=dlab-ldap | /usr/bin/jq -er '.[].id'`
+          user_f_id=$(/opt/jboss/keycloak/bin/kcadm.sh get components -r dlab --query name=dlab-ldap | /usr/bin/jq -er '.[].id')
           # Create user federation mapper
           /opt/jboss/keycloak/bin/kcadm.sh create components -r dlab -s name=uid-attribute-to-email-mapper \
           -s providerId=user-attribute-ldap-mapper -s providerType=org.keycloak.storage.ldap.mappers.LDAPStorageMapper \
diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/files/mongo_values.yaml b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/files/mongo_values.yaml
index f8100d2..497b75a 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/files/mongo_values.yaml
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/files/mongo_values.yaml
@@ -35,4 +35,5 @@ persistence:
 
 service:
   type: NodePort
-  nodePort: 31017
\ No newline at end of file
+  port: ${mongo_service_port}
+  nodePort: ${mongo_node_port}
\ No newline at end of file
diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/mongo.tf b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/mongo.tf
index 873a8de..442f1e9 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/mongo.tf
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/mongo.tf
@@ -22,11 +22,13 @@
 data "template_file" "mongo_values" {
   template = file("./files/mongo_values.yaml")
   vars     = {
-      mongo_root_pwd    = var.mongo_root_pwd
-      mongo_db_username = var.mongo_db_username
-      mongo_dbname      = var.mongo_dbname
-      mongo_db_pwd      = var.mongo_db_pwd
-      mongo_image_tag   = var.mongo_image_tag
+      mongo_root_pwd      = var.mongo_root_pwd
+      mongo_db_username   = var.mongo_db_username
+      mongo_dbname        = var.mongo_dbname
+      mongo_db_pwd        = var.mongo_db_pwd
+      mongo_image_tag     = var.mongo_image_tag
+      mongo_service_port  = var.mongo_service_port
+      mongo_node_port     = var.mongo_node_port
   }
 }
 
diff --git a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/variables.tf b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/variables.tf
index ed40c34..267e788 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/variables.tf
+++ b/infrastructure-provisioning/terraform/aws/ssn-helm-charts/main/variables.tf
@@ -99,6 +99,18 @@ variable "mongo_image_tag" {
     description = "MongoDB Image tag"
 }
 
+variable "mongo_service_port" {
+    default = "27017"
+}
+
+variable "mongo_node_port" {
+    default = "31017"
+}
+
+variable "mongo_service_name" {
+    default = "mongo-ha-mongodb"
+}
+
 //variable "nginx_http_port" {
 //    default = "31080"
 //    description = "Sets the nodePort that maps to the Ingress' port 80"
diff --git a/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/masters-user-data.sh b/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/masters-user-data.sh
index 0fc3ec0..737dc2b 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/masters-user-data.sh
+++ b/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/masters-user-data.sh
@@ -23,14 +23,14 @@
 set -ex
 
 check_tokens () {
-RUN=`aws s3 ls s3://${k8s-bucket-name}/k8s/masters/ > /dev/null && echo "true" || echo "false"`
+RUN=$(aws s3 ls s3://${k8s-bucket-name}/k8s/masters/ > /dev/null && echo "true" || echo "false")
 sleep 5
 }
 
 check_elb_status () {
-RUN=`aws elbv2 describe-target-health --target-group-arn ${k8s-tg-arn} --region ${k8s-region} | \
+RUN=$(aws elbv2 describe-target-health --target-group-arn ${k8s-tg-arn} --region ${k8s-region} | \
      jq -r '.TargetHealthDescriptions[].TargetHealth.State' | \
-     grep "^healthy" > /dev/null && echo "true" || echo "false"`
+     grep "^healthy" > /dev/null && echo "true" || echo "false")
 sleep 5
 }
 
@@ -48,11 +48,11 @@ sudo apt-get install -y python-pip jq unzip
 sudo pip install -U pip
 sudo pip install awscli
 
-local_ip=`curl http://169.254.169.254/latest/meta-data/local-ipv4`
-first_master_ip=`aws autoscaling describe-auto-scaling-instances --region ${k8s-region} --output text --query \
+local_ip=$(curl http://169.254.169.254/latest/meta-data/local-ipv4)
+first_master_ip=$(aws autoscaling describe-auto-scaling-instances --region ${k8s-region} --output text --query \
                  "AutoScalingInstances[?AutoScalingGroupName=='${k8s-asg}'].InstanceId" | xargs -n1 aws ec2 \
                  describe-instances --instance-ids $ID --region ${k8s-region} --query \
-                 "Reservations[].Instances[].PrivateIpAddress" --output text | sort | head -n1`
+                 "Reservations[].Instances[].PrivateIpAddress" --output text | sort | head -n1)
 
 # installing Docker
 sudo bash -c 'curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -'
@@ -68,7 +68,7 @@ sudo apt-get update
 sudo apt-get install -y kubelet kubeadm kubectl
 
 check_tokens
-if [[ $local_ip == $first_master_ip ]] && [[ $RUN == "false" ]];then
+if [[ $local_ip == "$first_master_ip" ]] && [[ $RUN == "false" ]];then
 cat <<EOF > /tmp/kubeadm-config.yaml
 apiVersion: kubeadm.k8s.io/v1beta2
 kind: ClusterConfiguration
@@ -136,9 +136,9 @@ do
 done
 aws s3 cp s3://${k8s-bucket-name}/k8s/masters/join_command /tmp/join_command
 aws s3 cp s3://${k8s-bucket-name}/k8s/masters/cert_key /tmp/cert_key
-join_command=`cat /tmp/join_command`
-cert_key=`cat /tmp/cert_key`
-sudo $join_command --control-plane --certificate-key $cert_key
+join_command=$(cat /tmp/join_command)
+cert_key=$(cat /tmp/cert_key)
+sudo "$join_command" --control-plane --certificate-key "$cert_key"
 sudo mkdir -p /home/${k8s_os_user}/.kube
 sudo cp -i /etc/kubernetes/admin.conf /home/${k8s_os_user}/.kube/config
 sudo chown -R ${k8s_os_user}:${k8s_os_user} /home/${k8s_os_user}/.kube
diff --git a/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/workers-user-data.sh b/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/workers-user-data.sh
index ed2cfd0..55ffbbf 100644
--- a/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/workers-user-data.sh
+++ b/infrastructure-provisioning/terraform/aws/ssn-k8s/main/files/workers-user-data.sh
@@ -23,7 +23,7 @@
 set -e
 
 check_tokens () {
-RUN=`aws s3 ls s3://${k8s-bucket-name}/k8s/masters/ > /dev/null && echo "true" || echo "false"`
+RUN=$(aws s3 ls s3://${k8s-bucket-name}/k8s/masters/ > /dev/null && echo "true" || echo "false")
 sleep 5
 }
 
@@ -64,5 +64,5 @@ do
     fi
 done
 aws s3 cp s3://${k8s-bucket-name}/k8s/masters/join_command /tmp/join_command
-join_command=`cat /tmp/join_command`
-sudo $join_command
+join_command=$(cat /tmp/join_command)
+sudo "$join_command"


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