Skip to content

Commit a0b0b40

Browse files
authored
set up workflow to install plugins (#91)
* set up workflow to install plugins Signed-off-by: Lu Yu <nluyu@amazon.com> * change to const and change permission level Signed-off-by: Lu Yu <nluyu@amazon.com> * change to use checkout v3 and use always pull due to latest tag and check file exist before updating config Signed-off-by: Lu Yu <nluyu@amazon.com> * added padding for varibales Signed-off-by: Lu Yu <nluyu@amazon.com> * move config from extra config folder to chart values yaml and set tracking id when install chart Signed-off-by: Lu Yu <nluyu@amazon.com> * enable ga in dev Signed-off-by: Lu Yu <nluyu@amazon.com> Signed-off-by: Lu Yu <nluyu@amazon.com>
1 parent d711942 commit a0b0b40

File tree

8 files changed

+119
-7
lines changed

8 files changed

+119
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: OpenSearch Dashboards Build Custom Docker Image
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
Build-Custom-Docker-Image:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: append config and custom command
13+
env:
14+
PLUGINS: ${{ secrets.PLUGINS }}
15+
run: |
16+
echo -e "\r\n" >> config/playground/docker/dev/Dockerfile
17+
echo CMD [\"python\", \"/opt/opensearch-dashboards/scripts/custom_osd_entry.py\", \"$PLUGINS\"] >> config/playground/docker/dev/Dockerfile
18+
19+
- name: Login to Docker Hub
20+
uses: docker/login-action@v2
21+
with:
22+
username: ${{ secrets.DOCKERHUB_USERNAME }}
23+
password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
25+
- name: Build and push
26+
env:
27+
DOCKER_HUB_REPO: ${{ secrets.DOCKER_HUB_REPO }}
28+
DOCKER_HUB_TAG: ${{ secrets.DOCKER_HUB_TAG }}
29+
run: |
30+
chmod -R 755 config/playground/docker/dev/scripts/
31+
docker build -t $DOCKER_HUB_REPO:$DOCKER_HUB_TAG config/playground/docker/dev
32+
docker push $DOCKER_HUB_REPO:$DOCKER_HUB_TAG
33+

.github/workflows/deployment-template.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ on:
1818
required: true
1919
kube-config:
2020
required: true
21+
ga-tracking-id:
22+
required: false
23+
default: ''
2124

2225
jobs:
2326

@@ -38,6 +41,7 @@ jobs:
3841
uses: elastic-analytics/dashboards-action@main
3942
env:
4043
KUBE_CONFIG_DATA: ${{ secrets.kube-config }}
44+
TRACKING_ID: ${{ secrets.ga-tracking-id }}
4145
with:
4246
plugins: "" # optional, list of Helm plugins. eg. helm-secrets or helm-diff.
4347
# Teardown the current OS and OSD and then install the lastest version
@@ -52,4 +56,8 @@ jobs:
5256
helm uninstall dashboards --namespace default
5357
kubectl delete pvc --all
5458
helm install opensearch opensearch/opensearch -f config/playground/helm/${{inputs.deploy-env}}/helm-opensearch.yaml
55-
helm install dashboards opensearch/opensearch-dashboards -f config/playground/helm/${{inputs.deploy-env}}/helm-opensearch-dashboards.yaml
59+
args=""
60+
if [[ $TRACKING_ID ]]; then
61+
args='--set config."opensearch_dashboards\.yml"."google_analytics_plugin\.trackingID"='"$TRACKING_ID"''
62+
fi
63+
helm install dashboards opensearch/opensearch-dashboards -f config/playground/helm/${{inputs.deploy-env}}/helm-opensearch-dashboards.yaml $args

.github/workflows/os-osd-deployment.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- uses: dorny/paths-filter@v2
2323
id: filter
2424
with:
25-
# creats filters for tracking dev and prod changes
25+
# creates filters to check if any dev or prod changes
2626
filters: |
2727
dev:
2828
- 'config/playground/helm/dev/**'
@@ -41,6 +41,7 @@ jobs:
4141
secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
4242
region: ${{ secrets.AWS_REGION_DEV }}
4343
kube-config: ${{ secrets.KUBE_CONFIG_DATA_DEV }}
44+
ga-tracking-id: ${{ secrets.GA_TRACKING_ID }}
4445

4546
OS-OSD-Prod-Deployment:
4647
needs: Pre-Deployment
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM opensearchproject/opensearch-dashboards:latest
2+
3+
COPY . /opt/opensearch-dashboards/
4+

config/playground/docker/dev/extra_config/osd.yml

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/python
2+
3+
import os
4+
import sys
5+
6+
SOURCE_FILE = "/opt/opensearch-dashboards/extra_config/osd.yml"
7+
TARGET_FILE = "/usr/share/opensearch-dashboards/config/opensearch_dashboards.yml"
8+
9+
def update_config():
10+
s_keys = set()
11+
nc = []
12+
with open(SOURCE_FILE, "r") as s:
13+
for r in s:
14+
if not r.strip():
15+
continue
16+
nc += [r]
17+
kv = r.split(":")
18+
if len(kv) < 2 or r.strip().startswith("#"):
19+
continue
20+
s_keys.add(kv[0])
21+
22+
if not nc:
23+
return
24+
25+
nt = []
26+
with open(TARGET_FILE, "r") as t:
27+
for r in t:
28+
kv = r.split(":")
29+
if len(kv) < 2 or r.strip().startswith("#"):
30+
nt += [r]
31+
elif kv[0] in s_keys:
32+
# skip to use src value
33+
continue
34+
else:
35+
nt += [r]
36+
37+
with open(TARGET_FILE, "w") as f:
38+
f.write("\n".join(nt + nc))
39+
40+
def run():
41+
if os.path.exists(SOURCE_FILE):
42+
update_config()
43+
44+
for i in range(1, len(sys.argv)):
45+
os.system("/opt/opensearch-dashboards/scripts/install-plugins.sh " + sys.argv[i])
46+
47+
os.system("./opensearch-dashboards-docker-entrypoint.sh opensearch-dashboards")
48+
49+
if __name__ == "__main__":
50+
run()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Start plugin installation"
5+
cnt=0
6+
7+
for var in "$@"
8+
do
9+
/usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin install $var
10+
cnt=$((cnt+1))
11+
done
12+
echo "Finished installing $cnt plugins"

config/playground/helm/dev/helm-opensearch-dashboards.yaml

+9-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ opensearchHosts: "https://opensearch-cluster-leader:9200"
99
replicaCount: 2
1010

1111
image:
12-
repository: "opensearchproject/opensearch-dashboards"
12+
repository: "opensearchplayground/opensearch-dashboards"
1313
# override image tag, which is .Chart.AppVersion by default
14-
tag: ""
15-
pullPolicy: "IfNotPresent"
14+
tag: "latest"
15+
# Always/Never/IfNotPresent
16+
pullPolicy: "Always"
1617

1718
imagePullSecrets: []
1819
nameOverride: ""
@@ -76,8 +77,11 @@ config:
7677
server.host: '0.0.0.0'
7778
# Use the consolidated menu and global header bar
7879
opensearchDashboards.branding.useExpandedHeader: false
79-
# Enable wizard feature
80-
wizard.enabled: true
80+
#Content security policy(csp) settings
81+
csp.rules: [ "connect-src 'self' www.google-analytics.com maps.opensearch.org;" ]
82+
csp.warnLegacyBrowsers: false
83+
# Google analytics plugin settings
84+
google_analytics_plugin.enabled: true
8185

8286
priorityClassName: ""
8387

0 commit comments

Comments
 (0)