-
Notifications
You must be signed in to change notification settings - Fork 26
211 lines (179 loc) · 8.09 KB
/
qa-saas.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
# qa-saas workflow is for scale testing and/or validation against the Nexodus qa or prod SaaS deployments
name: qa-saas
concurrency:
group: qa-scale
on:
workflow_dispatch:
inputs:
deployment_size:
description: 'deployment size: small | medium | large | xlarge'
required: true
default: 'small'
type: string
pr_or_branch:
description: 'pull request number or branch name'
required: true
default: 'main'
debug_pause:
description: 'time in minutes to pause before tearing down the infra for debugging'
required: false
default: '0'
controller_address:
description: 'options: qa.nexodus.io | try.nexodus.io'
required: true
default: 'qa.nexodus.io'
type: string
schedule:
- cron: '0 17 * * *'
jobs:
deploy-qa:
name: deploy-qa-ec2
runs-on: ubuntu-latest
timeout-minutes: 60
env:
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ANSIBLE_PRIVATE_KEY_FILE: "nexodus.pem"
ANSIBLE_HOST_KEY_CHECKING: "false"
# Set default values for scheduled runs
DEPLOYMENT_SIZE: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.deployment_size || 'small' }}
PR_OR_BRANCH: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pr_or_branch || 'main' }}
DEBUG_PAUSE: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_pause || '0' }}
CONTROLLER_ADDRESS: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.controller_address || 'qa.nexodus.io' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Determine if pr_or_branch is a PR number
id: check_pr
run: |
if [[ "${{ github.event.inputs.pr_or_branch }}" =~ ^[0-9]+$ ]]; then
echo "is_pr=true" >> "$GITHUB_OUTPUT"
else
echo "is_pr=false" >> "$GITHUB_OUTPUT"
fi
- name: Fetch and checkout PR
if: steps.check_pr.outputs.is_pr == 'true'
run: |
git fetch origin pull/${{ github.event.inputs.pr_or_branch }}/head:pr-${{ github.event.inputs.pr_or_branch }}
git checkout pr-${{ github.event.inputs.pr_or_branch }}
- name: Checkout branch
if: steps.check_pr.outputs.is_pr == 'false'
run: git checkout ${{ github.event.inputs.pr_or_branch }}
- name: Setup Go
uses: ./.github/actions/setup-go-env
- name: Build
run: |
make dist/nexd-linux-amd64
make dist/nexctl-linux-amd64
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE }}
role-session-name: nexodus-ci-deploy
aws-region: us-east-1
- name: Copy binaries to s3
run: |
aws s3 cp ./dist/nexd-linux-amd64 s3://nexodus-io/ec2-e2e/qa/
aws s3 cp ./dist/nexctl-linux-amd64 s3://nexodus-io/ec2-e2e/qa/
- name: Set Controller and Keycloak Credentials
run: |
# Set controller address to default if not provided in event inputs
controller_address=${{ github.event.inputs.controller_address || 'qa.nexodus.io' }}
echo "controller_address=${controller_address}" >> "$GITHUB_ENV"
controller_auth_address="auth.$controller_address"
echo "CONTROLLER_AUTH_ADDRESS=$controller_auth_address" >> "$GITHUB_ENV"
# Set Keycloak credentials based on controller address
if [ "$controller_address" = "qa.nexodus.io" ]; then
echo "KC_USERNAME=${{ secrets.KC_QA_USERNAME }}" >> "$GITHUB_ENV"
echo "KC_PASSWORD=${{ secrets.KC_QA_PASSWORD }}" >> "$GITHUB_ENV"
elif [ "$controller_address" = "try.nexodus.io" ]; then
echo "KC_USERNAME=${{ secrets.KC_PROD_USERNAME }}" >> "$GITHUB_ENV"
echo "KC_PASSWORD=${{ secrets.KC_PROD_PASSWORD }}" >> "$GITHUB_ENV"
else
# Default to qa.nexodus.io credentials if controller_address is not specified
echo "KC_USERNAME=${{ secrets.KC_QA_USERNAME }}" >> "$GITHUB_ENV"
echo "KC_PASSWORD=${{ secrets.KC_QA_PASSWORD }}" >> "$GITHUB_ENV"
fi
- name: Build Keycloak Tool
run: |
go build -o ./ ./hack/e2e-scripts/kctool/
- name: Create a Keycloak User
id: kc-user
run: |
output=$(./kctool --create-user \
-ku "${{ env.KC_USERNAME }}" \
-kp "${{ env.KC_PASSWORD }}" \
-u qa \
-p "${{ secrets.QA_USER_PASSWORD }}" \
"https://${{ env.CONTROLLER_AUTH_ADDRESS }}")
echo "USER=$output" >> "$GITHUB_OUTPUT"
- name: User results from Keycloak
run: echo "User is ${{ steps.kc-user.outputs.USER }}"
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Ansible and Dependencies
run: pip3.10 install boto boto3 ansible-vault ansible-core
- name: Install amazon.aws Ansible library
run: ansible-galaxy collection install amazon.aws
- name: Set Default Deployment Size if Not Provided
if: github.event_name == 'schedule' || github.event.inputs.deployment_size == ''
run: |
echo "${{ secrets.ANSIBLE_VARS_SMALL_QA }}" > ./ops/ansible/aws/vars.yml
- name: Set Deployment Size to Small
if: github.event.inputs.deployment_size == 'small'
run: |
echo "${{ secrets.ANSIBLE_VARS_SMALL_QA }}" > ./ops/ansible/aws/vars.yml
- name: Set Deployment Size to Medium
if: github.event.inputs.deployment_size == 'medium'
run: |
echo "${{ secrets.ANSIBLE_VARS_MEDIUM_QA }}" > ./ops/ansible/aws/vars.yml
- name: Set Deployment Size to Large
if: github.event.inputs.deployment_size == 'large'
run: |
echo "${{ secrets.ANSIBLE_VARS_LARGE_QA }}" > ./ops/ansible/aws/vars.yml
- name: Set Deployment Size to XLarge
if: github.event.inputs.deployment_size == 'xlarge'
run: |
echo "${{ secrets.ANSIBLE_VARS_XLARGE_QA }}" > ./ops/ansible/aws/vars.yml
- name: Create Ansible Secrets
run: |
echo "${{ secrets.ANSIBLE_SSH_KEY }}" > nexodus.pem
chmod 0400 nexodus.pem
echo "${{ secrets.ANSIBLE_VAULT_PASSWORD }}" > vault-secret.txt
chmod 0400 vault-secret.txt
- name: Deploy EC2 Agent Nodes
run: |
ansible-playbook -vv ./ops/ansible/aws/deploy-ec2-qa.yml \
-i ./ops/ansible/aws/inventory.txt \
--private-key nexodus.pem \
--vault-password-file vault-secret.txt \
--extra-vars "nexodus_auth_uid=${{ steps.kc-user.outputs.USER }}" \
--extra-vars "nexodus_auth_password=${{ secrets.QA_USER_PASSWORD }}" \
--extra-vars "debug_pause=0" \
--extra-vars "controller_address=$controller_address"
- name: Mesh Connectivity Results
run: |
set -e
/bin/sh -c 'cat ./ops/ansible/aws/*-connectivity-results.txt > ./ops/ansible/aws/mesh-connectivity-results.txt'
cat ./ops/ansible/aws/mesh-connectivity-results.txt
if grep -iq 'Unreachable' ./ops/ansible/aws/mesh-connectivity-results.txt || grep -iq 'Failed' ./ops/ansible/aws/mesh-connectivity-results.txt; then
echo "Connectivity results contain 'Unreachable or Failed' nodes, check the connectivity results and artifacts for details. Failing the job"
exit 1
else
echo "Connectivity results do not contain any 'Unreachable' nodes"
fi
- name: Terminate EC2 Instances
if: always()
run: |
ansible-playbook -vv ./ops/ansible/aws/terminate-instances.yml \
--private-key nexodus.pem \
--vault-password-file vault-secret.txt
- name: Upload nexd and api-server Logs to Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: dev-ec2-artifacts
path: ./ops/ansible/aws/nexd-logs/
retention-days: 10