-
Notifications
You must be signed in to change notification settings - Fork 37
144 lines (122 loc) · 7.97 KB
/
nightly-playground-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Nightly Playground Validate and Deploy
on:
workflow_call:
inputs:
dist_version:
required: true
description: 'OpenSearch and Dashboards distribution version'
type: string
jobs:
set-os-osd-urls:
runs-on: ubuntu-latest
outputs:
OPENSEARCH_URL: ${{ steps.set-env.outputs.OPENSEARCH_URL }}
OPENSEARCH_DASHBOARDS_URL: ${{ steps.set-env.outputs.OPENSEARCH_DASHBOARDS_URL }}
OPENSEARCH_DIST_MANIFEST_URL: ${{ steps.set-env.outputs.OPENSEARCH_DIST_MANIFEST_URL }}
OPENSEARCH_DASHBOARDS_DIST_MANIFEST_URL: ${{ steps.set-env.outputs.OPENSEARCH_DASHBOARDS_DIST_MANIFEST_URL }}
steps:
- name: Set Env variables
id: set-env
run: |
wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{inputs.dist_version}}/latest/linux/x64/tar/dist/opensearch/manifest.yml -O opensearch.yml
wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{inputs.dist_version}}/latest/linux/x64/tar/dist/opensearch-dashboards/manifest.yml -O dashboards.yml
opensearch_build_id=$(yq .build.id opensearch.yml)
dashboards_build_id=$(yq .build.id dashboards.yml)
echo "OPENSEARCH_URL=$(yq .build.location opensearch.yml)" >> "$GITHUB_OUTPUT"
echo "OPENSEARCH_DASHBOARDS_URL=$(yq .build.location dashboards.yml)" >> "$GITHUB_OUTPUT"
echo "OPENSEARCH_DIST_MANIFEST_URL=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{inputs.dist_version}}/$opensearch_build_id/linux/x64/tar/dist/opensearch/manifest.yml" >> "$GITHUB_OUTPUT"
echo "OPENSEARCH_DASHBOARDS_DIST_MANIFEST_URL=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/${{inputs.dist_version}}/$dashboards_build_id/linux/x64/tar/dist/opensearch-dashboards/manifest.yml" >> "$GITHUB_OUTPUT"
validate-and-deploy:
outputs:
ENDPOINT: ${{ steps.deploy.outputs.ENDPOINT }}
PLAYGROUND_ID: ${{ steps.deploy.outputs.playground_id }}
permissions:
id-token: write
contents: read
needs: set-os-osd-urls
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: 'opensearch-project/opensearch-build'
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9
- name: Install Pipenv and Dependencies
run: |
python -m pip install --upgrade pipenv wheel
pipenv install --deploy --dev
- name: Validate OS and OSD
run: unset JAVA_HOME && ./validation.sh --file-path opensearch=${{needs.set-os-osd-urls.outputs.OPENSEARCH_URL}} opensearch-dashboards=${{needs.set-os-osd-urls.outputs.OPENSEARCH_DASHBOARDS_URL}}
- uses: actions/checkout@v3
- uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.DEPLOY_NIGHTLY_PLAYGROUND_ROLE }}
aws-region: us-west-2
- uses: actions/setup-node@v4
with:
node-version: 16.x
- name: Deploy nightly playground
id: deploy
working-directory: nightly-playground
run: |
npm install
playground_id=`echo ${{inputs.dist_version}} | cut -d. -f1`x
echo "PLAYGROUND_ID=$playground_id" >> "$GITHUB_OUTPUT"
aws s3 cp s3://nightly-playgrounds-snapshots-bucket/internal_users.yml resources/security-config/internal_users.yml
npm run cdk deploy "infra*" -- -c playGroundId=$playground_id -c distVersion=${{inputs.dist_version}} -c distributionUrl=${{needs.set-os-osd-urls.outputs.OPENSEARCH_URL}} -c dashboardsUrl=${{needs.set-os-osd-urls.outputs.OPENSEARCH_DASHBOARDS_URL}} -c dashboardPassword=${{ SECRETS.DASHBOARDS_PASSWORD }} -c adminPassword=${{ SECRETS.OPENSEARCH_PASSWORD }} -c dashboardOpenIDClientSecret=${{ SECRETS.DASHBOARD_OPENID_CLIENT_SECRET }} --require-approval never
echo "ENDPOINT=$(aws cloudformation --region us-west-2 describe-stacks --stack-name infraStack-$playground_id --query 'Stacks[0].Outputs[0].OutputValue' --output text)" >> "$GITHUB_OUTPUT"
index-dist-manifests:
needs:
- set-os-osd-urls
- validate-and-deploy
runs-on: ubuntu-latest
steps:
- name: Index distribution manifests
run: |
wget ${{ needs.set-os-osd-urls.outputs.OPENSEARCH_DIST_MANIFEST_URL }} -O opensearch.yml
wget ${{ needs.set-os-osd-urls.outputs.OPENSEARCH_DASHBOARDS_DIST_MANIFEST_URL }} -O opensearch-dashboards.yml
yq -o=json '.' opensearch.yml > opensearch.json
yq -o=json '.' opensearch-dashboards.yml > dashboards.json
curl -XPOST -f "https://${{needs.validate-and-deploy.outputs.ENDPOINT}}:8443/opensearch/_doc/1" -H "Content-Type: application/json" -d @opensearch.json -u ${{ secrets.OPENSEARCH_USER }}:${{ secrets.OPENSEARCH_PASSWORD }} --insecure
curl -XPOST -f "https://${{needs.validate-and-deploy.outputs.ENDPOINT}}:8443/opensearch-dashboards/_doc/1" -H "Content-Type: application/json" -d @dashboards.json -u ${{ secrets.OPENSEARCH_USER }}:${{ secrets.OPENSEARCH_PASSWORD }} --insecure
configure-alerts-notifications:
needs: validate-and-deploy
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Check and Create notification channel
run: |
status_code=$(curl -XGET -s -o /dev/null -w "%{http_code}" "https://${{needs.validate-and-deploy.outputs.ENDPOINT}}:8443/_plugins/_notifications/configs/slack-notification-channel" -u ${{ secrets.OPENSEARCH_USER }}:${{ secrets.OPENSEARCH_PASSWORD }} --insecure)
if [ "$status_code" != "200" ]; then
curl -XPOST -f "https://${{needs.validate-and-deploy.outputs.ENDPOINT}}:8443/_plugins/_notifications/configs" -H 'Content-Type: application/json' -d'
{
"config_id": "slack-notification-channel",
"name": "slack-notification-channel",
"config": {
"name": "slack-notification-channel",
"description": "Slack notification channel for monitoring alerts",
"config_type": "webhook",
"is_enabled": true,
"webhook": {
"url": "${{ secrets.SLACK_WEBHOOK }}"
}
}
}' -u ${{ secrets.OPENSEARCH_USER }}:${{ secrets.OPENSEARCH_PASSWORD }} --insecure
fi
- name: Configure monitors
run: |
for config in `ls nightly-playground/resources/monitors-config/`;
do curl -XPOST -f "https://${{needs.validate-and-deploy.outputs.ENDPOINT}}:8443/_plugins/_alerting/monitors" -H 'Content-Type: application/json' -d @nightly-playground/resources/monitors-config/$config -u ${{ secrets.OPENSEARCH_USER }}:${{ secrets.OPENSEARCH_PASSWORD }} --insecure;
done
add-sample-data:
needs: validate-and-deploy
runs-on: ubuntu-latest
steps:
- name: Add sample data
run : |
curl -X POST -f 'https://${{needs.validate-and-deploy.outputs.ENDPOINT}}/${{needs.validate-and-deploy.outputs.PLAYGROUND_ID}}/api/sample_data/logs' -H 'securitytenant: global' -H 'Content-Type: application/json' -H 'osd-version: ${{inputs.dist_version}}' -H 'osd-xsrf: osd-fetch' -u ${{ secrets.OPENSEARCH_USER }}:${{ secrets.OPENSEARCH_PASSWORD }} --insecure
curl -X POST -f 'https://${{needs.validate-and-deploy.outputs.ENDPOINT}}/${{needs.validate-and-deploy.outputs.PLAYGROUND_ID}}/api/sample_data/flights' -H 'securitytenant: global' -H 'Content-Type: application/json' -H 'osd-version: ${{inputs.dist_version}}' -H 'osd-xsrf: osd-fetch' -u ${{ secrets.OPENSEARCH_USER }}:${{ secrets.OPENSEARCH_PASSWORD }} --insecure
curl -X POST -f 'https://${{needs.validate-and-deploy.outputs.ENDPOINT}}/${{needs.validate-and-deploy.outputs.PLAYGROUND_ID}}/api/sample_data/ecommerce' -H 'securitytenant: global' -H 'Content-Type: application/json' -H 'osd-version: ${{inputs.dist_version}}' -H 'osd-xsrf: osd-fetch' -u ${{ secrets.OPENSEARCH_USER }}:${{ secrets.OPENSEARCH_PASSWORD }} --insecure