Support opensearch

Change-Id: I1a3854d31193a69f0fc97c62d78c3e395c94b37e
diff --git a/logging/opendistro_setting/Chart.yaml b/logging/opendistro_setting/Chart.yaml
index 33643af..141a6c2 100644
--- a/logging/opendistro_setting/Chart.yaml
+++ b/logging/opendistro_setting/Chart.yaml
@@ -3,7 +3,7 @@
 
 apiVersion: v2
 name: opendistro-setting
-description: A Helm chart deploying container to config opendistro services
+description: A Helm chart deploying container to config opensearch services
 
 # A chart can be either an 'application' or a 'library' chart.
 #
@@ -18,7 +18,7 @@
 # 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.
 # Versions are expected to follow Semantic Versioning (https://semver.org/)
-version: 0.1.2
+version: 0.1.3
 
 # This is the version number of the application being deployed. This version number should be
 # incremented each time you make changes to the application. Versions are not expected to
diff --git a/logging/opendistro_setting/templates/configmap-script.yml b/logging/opendistro_setting/templates/configmap-script.yml
index f28c55a..e8ff43d 100644
--- a/logging/opendistro_setting/templates/configmap-script.yml
+++ b/logging/opendistro_setting/templates/configmap-script.yml
@@ -14,6 +14,9 @@
   update.sh: |
     #!/bin/bash
     host=${ES_URL:-localhost:9201}
+    skip_tls=${SKIP_TLS:true}
+    auth_username=${AUTH_USERNAME}
+    auth_password=${AUTH_PASSWORD}
     dest_dir=${DEST_DIR}
     monitor_dir=${MONITOR_DIR}
     setting_dir=${SETTING_DIR}
@@ -135,13 +138,26 @@
         dir=$setting_dir
         mkdir -p "$temp_dir/$dir"
         config_file=$dir/config.json
+
+        curl_opts=""
+
+        if [ ! -z $auth_username ]; then
+          curl_opts="$curl_opts -u $auth_username:$auth_password"
+        fi
+
+        if [ $skip_tls ]; then
+          curl_opts="$curl_opts -k"
+        fi
+
+
         for k in $(jq ' keys | .[]' "$config_file"); do
             file=$dir/$(jq -r ".[$k].file" "$config_file");
+            type=$(jq -r ".[$k].type" "$config_file");
             url=$(jq -r ".[$k].url" "$config_file");
 
             new_file="$temp_dir/$file"
             jq -c '' < "$file" > "$new_file"
-            curl -s -X POST -H "content-type: application/json" -d "@$new_file" "$host/$url"
+            curl -s $curl_opts -X $type -H "content-type: application/json" -d "@$new_file" "$host/$url"
             rm "$new_file"
             echo "  "
         done
diff --git a/logging/opendistro_setting/templates/deployment.yml b/logging/opendistro_setting/templates/deployment.yml
index b1e43f4..af9515c 100644
--- a/logging/opendistro_setting/templates/deployment.yml
+++ b/logging/opendistro_setting/templates/deployment.yml
@@ -22,6 +22,12 @@
           env:
             - name: ES_URL
               value: "{{ .Values.elasticsearch.host }}:{{ .Values.elasticsearch.port}}"
+            - name: AUTH_USERNAME
+              value: "{{ .Values.elasticsearch.auth.username}}"
+            - name: AUTH_PASSWORD
+              value: "{{ .Values.elasticsearch.auth.password}}"
+            - name: SKIP_TLS
+              value: "{{ .Values.elasticsearch.auth.skip_tls}}"
             {{ if .Values.configuration.setting }}
             - name: SETTING_DIR
               value: "{{ .Values.configuration.base_dir }}/{{ .Values.configuration.setting }}"
diff --git a/logging/opendistro_setting/values.yaml b/logging/opendistro_setting/values.yaml
index d707602..52841e6 100644
--- a/logging/opendistro_setting/values.yaml
+++ b/logging/opendistro_setting/values.yaml
@@ -3,13 +3,17 @@
 
 
 elasticsearch:
-  host: opendistro-es-client-service.logging-system
+  host: https://opensearch-cluster-master.logging-system
   port: 9200
+  auth:
+    username: admin
+    password: admin
+    skip_tls: true
 
 configuration:
   base_dir: /tmp/opendistro
   # Have to prepare the configmap first
-  # setting_configmap: opendistro-kibana-setting
+  # setting_configmap: opensearch-kibana-setting
   # setting: settings/
   # Have to prepare the configmap first
   # monitor_configmap: opendistro-kibana-monitor