Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set up workflow to install plugins #91

Merged
merged 6 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/build-custom-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: OpenSearch Dashboards Build Custom Docker Image
BionIT marked this conversation as resolved.
Show resolved Hide resolved

on:
workflow_dispatch:

jobs:
Build-Custom-Docker-Image:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: append config and custom command
env:
PLUGINS: ${{ secrets.PLUGINS }}
run: |
echo -e "\r\n" >> config/playground/docker/dev/Dockerfile
echo CMD [\"python\", \"/opt/opensearch-dashboards/scripts/custom_osd_entry.py\", \"$PLUGINS\"] >> config/playground/docker/dev/Dockerfile

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
env:
DOCKER_HUB_REPO: ${{ secrets.DOCKER_HUB_REPO }}
DOCKER_HUB_TAG: ${{ secrets.DOCKER_HUB_TAG }}
run: |
chmod -R 755 config/playground/docker/dev/scripts/
docker build -t $DOCKER_HUB_REPO:$DOCKER_HUB_TAG config/playground/docker/dev
docker push $DOCKER_HUB_REPO:$DOCKER_HUB_TAG

12 changes: 10 additions & 2 deletions .github/workflows/deployment-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ on:
required: true
kube-config:
required: true
ga-tracking-id:
required: false
default: ''

jobs:

OS-OSD-Deployment:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Step 1 - Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -38,6 +41,7 @@ jobs:
uses: elastic-analytics/dashboards-action@main
env:
KUBE_CONFIG_DATA: ${{ secrets.kube-config }}
TRACKING_ID: ${{ secrets.ga-tracking-id }}
with:
plugins: "" # optional, list of Helm plugins. eg. helm-secrets or helm-diff.
# Teardown the current OS and OSD and then install the lastest version
Expand All @@ -52,4 +56,8 @@ jobs:
helm uninstall dashboards --namespace default
kubectl delete pvc --all
helm install opensearch opensearch/opensearch -f config/playground/helm/${{inputs.deploy-env}}/helm-opensearch.yaml
helm install dashboards opensearch/opensearch-dashboards -f config/playground/helm/${{inputs.deploy-env}}/helm-opensearch-dashboards.yaml
args=""
if [[ $TRACKING_ID ]]; then
args='--set config."opensearch_dashboards\.yml"."google_analytics_plugin\.trackingID"='"$TRACKING_ID"''
fi
helm install dashboards opensearch/opensearch-dashboards -f config/playground/helm/${{inputs.deploy-env}}/helm-opensearch-dashboards.yaml $args
5 changes: 3 additions & 2 deletions .github/workflows/os-osd-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
config_change_prod: ${{steps.filter.outputs.prod}}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
# creats filters for tracking dev and prod changes
# creates filters to check if any dev or prod changes
filters: |
dev:
- 'config/playground/helm/dev/**'
Expand All @@ -41,6 +41,7 @@ jobs:
secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
region: ${{ secrets.AWS_REGION_DEV }}
kube-config: ${{ secrets.KUBE_CONFIG_DATA_DEV }}
ga-tracking-id: ${{ secrets.GA_TRACKING_ID }}

OS-OSD-Prod-Deployment:
needs: Pre-Deployment
Expand Down
4 changes: 4 additions & 0 deletions config/playground/docker/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM opensearchproject/opensearch-dashboards:latest

COPY . /opt/opensearch-dashboards/

Empty file.
50 changes: 50 additions & 0 deletions config/playground/docker/dev/scripts/custom_osd_entry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/python

import os
import sys

SOURCE_FILE = "/opt/opensearch-dashboards/extra_config/osd.yml"
TARGET_FILE = "/usr/share/opensearch-dashboards/config/opensearch_dashboards.yml"

def update_config():
s_keys = set()
nc = []
with open(SOURCE_FILE, "r") as s:
for r in s:
if not r.strip():
continue
nc += [r]
kv = r.split(":")
if len(kv) < 2 or r.strip().startswith("#"):
continue
s_keys.add(kv[0])

if not nc:
return

nt = []
with open(TARGET_FILE, "r") as t:
for r in t:
kv = r.split(":")
if len(kv) < 2 or r.strip().startswith("#"):
nt += [r]
elif kv[0] in s_keys:
# skip to use src value
continue
else:
nt += [r]

with open(TARGET_FILE, "w") as f:
f.write("\n".join(nt + nc))
BionIT marked this conversation as resolved.
Show resolved Hide resolved

def run():
if os.path.exists(SOURCE_FILE):
update_config()

for i in range(1, len(sys.argv)):
os.system("/opt/opensearch-dashboards/scripts/install-plugins.sh " + sys.argv[i])

os.system("./opensearch-dashboards-docker-entrypoint.sh opensearch-dashboards")

if __name__ == "__main__":
run()
12 changes: 12 additions & 0 deletions config/playground/docker/dev/scripts/install-plugins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

echo "Start plugin installation"
cnt=0

for var in "$@"
do
/usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin install $var
cnt=$((cnt+1))
done
echo "Finished installing $cnt plugins"
14 changes: 9 additions & 5 deletions config/playground/helm/dev/helm-opensearch-dashboards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ opensearchHosts: "https://opensearch-cluster-leader:9200"
replicaCount: 2

image:
repository: "opensearchproject/opensearch-dashboards"
repository: "opensearchplayground/opensearch-dashboards"
# override image tag, which is .Chart.AppVersion by default
tag: ""
pullPolicy: "IfNotPresent"
tag: "latest"
# Always/Never/IfNotPresent
pullPolicy: "Always"

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

priorityClassName: ""

Expand Down