-
Notifications
You must be signed in to change notification settings - Fork 30
226 lines (210 loc) · 10.1 KB
/
deployment-template.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: OpenSearch and OpenSearch Dashboards Deployment Template
on:
workflow_call:
inputs:
helm-repo:
required: true
type: string
deploy-env:
required: true
type: string
secrets:
access-key-id:
required: true
secret-access-key:
required: true
region:
required: true
kube-config:
required: true
openid_client_id:
required: false
openid_client_secret:
required: false
openid_base_redirect_url:
required: false
openid_logout_url:
required: false
ga-tracking-id:
required: false
osd_user:
required: false
osd_user_password:
required: false
otel_root_ca:
required: false
otel_data_prepper_cert:
required: false
kibanaserver:
required: true
esnode_cert:
required: false
esnode_key_cert:
required: false
root_ca_cert:
required: false
jobs:
OS-OSD-Deployment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Step 1 - Replace Tokens for helm chart configuration
if: ${{ (inputs.deploy-env == 'preview') || (inputs.deploy-env == 'searchapps') || (inputs.deploy-env == 'observability') }}
uses: cschleiden/replace-tokens@v1
with:
files: '["${{ github.workspace }}/config/playground/helm/${{inputs.deploy-env}}/helm-opensearch-dashboards.yaml"]'
tokenPrefix: '${'
tokenSuffix: '}'
env:
OPENID_CLIENT_ID: ${{ secrets.openid_client_id }}
OPENID_CLIENT_SECRET: ${{ secrets.openid_client_secret }}
OPENID_BASE_REDIRECT_URL: ${{ secrets.openid_base_redirect_url }}
OPENID_LOGOUT_URL: ${{ secrets.openid_logout_url }}
GA_TRACKING_ID: ${{ secrets.ga-tracking-id }}
KIBANASERVER: ${{ secrets.kibanaserver }}
- name: Step 2 - Replace Token in opensearch.yml
if: ${{ (inputs.deploy-env == 'dev') || (inputs.deploy-env == 'prod') }}
uses: cschleiden/replace-tokens@v1
with:
files: '["${{ github.workspace }}/config/playground/helm/${{inputs.deploy-env}}/helm-opensearch.yaml"]'
tokenPrefix: '${'
tokenSuffix: '}'
env:
ESNODE_CERT: ${{ secrets.esnode_cert }}
ESNODE_KEY_CERT: ${{ secrets.esnode_key_cert }}
ROOT_CA_CERT: ${{ secrets.root_ca_cert }}
- name: Step 2.1 - Replace Token in machinelearning.yml
if: ${{ (inputs.deploy-env == 'dev') || (inputs.deploy-env == 'prod') }}
uses: cschleiden/replace-tokens@v1
with:
files: '["${{ github.workspace }}/config/playground/helm/${{inputs.deploy-env}}/helm-machinelearning.yaml"]'
tokenPrefix: '${'
tokenSuffix: '}'
env:
ESNODE_CERT: ${{ secrets.esnode_cert }}
ESNODE_KEY_CERT: ${{ secrets.esnode_key_cert }}
ROOT_CA_CERT: ${{ secrets.root_ca_cert }}
- name: Step 3 - Replace Tokens for dashboards
uses: cschleiden/replace-tokens@v1
with:
files: '["${{ github.workspace }}/config/playground/helm/${{inputs.deploy-env}}/helm-opensearch-dashboards.yaml"]'
tokenPrefix: '${'
tokenSuffix: '}'
env:
KIBANASERVER: ${{ secrets.kibanaserver }}
GA_TRACKING_ID: ${{ secrets.ga-tracking-id }}
- name: Step 4 - Replace Tokens for logstash configuration
if: ${{ (inputs.deploy-env == 'preview') || (inputs.deploy-env == 'searchapps') || (inputs.deploy-env == 'observability') }}
uses: cschleiden/replace-tokens@v1
with:
files: '["${{ github.workspace }}/config/playground/metrics/logstash/preview/logstash.yaml"]'
tokenPrefix: '${'
tokenSuffix: '}'
env:
OSD_USER: ${{ secrets.osd_user }}
OSD_USER_PASSWORD: ${{ secrets.osd_user_password }}
- name: Step 5 - Replace Tokens for tracing configuration
if: ${{ (inputs.deploy-env == 'preview') || (inputs.deploy-env == 'searchapps') || (inputs.deploy-env == 'observability') }}
uses: cschleiden/replace-tokens@v1
with:
files: '["${{ github.workspace }}/config/playground/metrics/tracing/preview/otel-config.yaml"]'
tokenPrefix: '${'
tokenSuffix: '}'
env:
OSD_USER: ${{ secrets.osd_user }}
OSD_USER_PASSWORD: ${{ secrets.osd_user_password }}
OTEL_ROOT_CA: ${{ secrets.otel_root_ca }}
OTEL_DATA_PREPPER_CERT: ${{ secrets.otel_data_prepper_cert }}
- name: Step 6 - Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.access-key-id }}
aws-secret-access-key: ${{ secrets.secret-access-key }}
aws-region: ${{ secrets.region }}
- name: Step 7 - Delete Logstash
if: ${{ (inputs.deploy-env == 'preview') || (inputs.deploy-env == 'searchapps') || (inputs.deploy-env == 'observability') }}
uses: elastic-analytics/dashboards-action@main
env:
KUBE_CONFIG_DATA: ${{ secrets.kube-config }}
with:
plugins: ""
command: |
kubectl delete ns logstash
- name: Step 8 - Delete Tracing
if: ${{ (inputs.deploy-env == 'preview') || (inputs.deploy-env == 'searchapps') || (inputs.deploy-env == 'observability') }}
uses: elastic-analytics/dashboards-action@main
env:
KUBE_CONFIG_DATA: ${{ secrets.kube-config }}
with:
plugins: ""
command: |
kubectl delete -f config/playground/metrics/tracing/preview/jaeger-agent.yaml
kubectl delete -f config/playground/metrics/tracing/preview/otel-config.yaml
kubectl delete -f config/playground/metrics/tracing/preview/otel-collector.yaml
kubectl delete -f config/playground/metrics/tracing/preview/data-prepper.yaml
- name: Step 9 - Deploy OpenSearch and OpenSearch Dashboards By Helm Chart
if: ${{ (inputs.deploy-env == 'searchapps') || (inputs.deploy-env == 'preview') || (inputs.deploy-env == 'observability')}}
uses: elastic-analytics/dashboards-action@main
env:
KUBE_CONFIG_DATA: ${{ secrets.kube-config }}
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
# of OS and OSD as it only takes 23 seconds for the process, will add
# blue/green deployment later.
command: |
helm repo add opensearch ${{ inputs.helm-repo }}
helm repo update
helm search repo opensearch
kubectl get nodes
helm uninstall opensearch --namespace default
helm uninstall dashboards --namespace default
kubectl get pvc | grep opensearch-cluster-leader-opensearch-cluster-leader- | awk '{print $1}'| xargs kubectl delete pvc
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
- name: Step 10 - Deploy OpenSearch/OpenSearch Dashboards/ML By Helm Chart
if: ${{ (inputs.deploy-env == 'dev') || (inputs.deploy-env == 'prod') || (inputs.deploy-env == 'ml') }}
uses: elastic-analytics/dashboards-action@main
env:
KUBE_CONFIG_DATA: ${{ secrets.kube-config }}
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
# of OS and OSD as it only takes 23 seconds for the process, will add
# blue/green deployment later.
command: |
helm repo add opensearch ${{ inputs.helm-repo }}
helm repo update
helm search repo opensearch
kubectl get nodes
helm uninstall opensearch --namespace default
helm uninstall dashboards --namespace default
helm uninstall machinelearning --namespace default
kubectl get pvc | grep opensearch-cluster-leader-opensearch-cluster-leader- | awk '{print $1}'| xargs kubectl delete pvc
kubectl get pvc | grep opensearch-cluster-machinelearning-opensearch-cluster-machinelearning- | awk '{print $1}'| xargs kubectl delete pvc
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
helm install machinelearning opensearch/opensearch -f config/playground/helm/${{inputs.deploy-env}}/helm-machinelearning.yaml
- name: Step 11 - Install Logstash
if: ${{ (inputs.deploy-env == 'preview') || (inputs.deploy-env == 'searchapps') || (inputs.deploy-env == 'observability') }}
uses: elastic-analytics/dashboards-action@main
env:
KUBE_CONFIG_DATA: ${{ secrets.kube-config }}
with:
plugins: ""
command: |
kubectl create ns logstash
kubectl create -f config/playground/metrics/logstash/preview/logstash-configmap.yaml
kubectl apply -f config/playground/metrics/logstash/preview/logstash.yaml
- name: Step 12 - Install Tracing
if: ${{ (inputs.deploy-env == 'preview') || (inputs.deploy-env == 'searchapps') || (inputs.deploy-env == 'observability') }}
uses: elastic-analytics/dashboards-action@main
env:
KUBE_CONFIG_DATA: ${{ secrets.kube-config }}
with:
plugins: ""
command: |
kubectl apply -f config/playground/metrics/tracing/preview/jaeger-agent.yaml
kubectl create -f config/playground/metrics/tracing/preview/otel-config.yaml
kubectl apply -f config/playground/metrics/tracing/preview/otel-collector.yaml
kubectl apply -f config/playground/metrics/tracing/preview/data-prepper.yaml