-
Notifications
You must be signed in to change notification settings - Fork 115
272 lines (233 loc) · 9.9 KB
/
int-test-gcp-workflow.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: Integration Test on GCP Workflow
on:
push:
branches:
- develop
- main
- google-object-storage-support
jobs:
build-operator-image:
runs-on: ubuntu-latest
env:
SPLUNK_ENTERPRISE_IMAGE: ${{ secrets.SPLUNK_ENTERPRISE_IMAGE }}
SPLUNK_OPERATOR_IMAGE_NAME: splunk/splunk-operator
ARTIFACT_REGISTRY: ${{ secrets.GCP_ARTIFACT_REGISTRY }} # Updated for Artifact Registry
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Load Environment Variables
id: dotenv
uses: falti/dotenv-action@d4d12eaa0e1dd06d5bdc3d7af3bf4c8c93cb5359
with:
path: .env # Adjust the path if your dotenv file is located elsewhere
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ steps.dotenv.outputs.GO_VERSION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.5.0
- name: Install Operator SDK
run: |
ARCH=$(case $(uname -m) in
x86_64) echo -n amd64 ;;
aarch64) echo -n arm64 ;;
*) echo -n $(uname -m) ;;
esac)
OS=$(uname | awk '{print tolower($0)}')
OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/${{ steps.dotenv.outputs.OPERATOR_SDK_VERSION }}
curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
chmod +x operator-sdk_${OS}_${ARCH}
sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk
- name: Authenticate to GCP
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
- name: Login to GCR
uses: docker/login-action@v3
with:
registry: ${{ secrets.GCP_ARTIFACT_REGISTRY }}
username: _json_key
password: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
- name: Build Splunk Operator Image
run: |
make docker-buildx IMG=${{ secrets.GCP_ARTIFACT_REGISTRY }}/${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA
create-cluster-and-run-tests:
strategy:
matrix:
test_focus:
- "gcp_sanity"
#- "basic"
#- "appframeworks1gcp"
#- "managerappframeworkc3gcp"
#- "managerappframeworkm4gcp"
#- "managersecretgcp"
#- "managermcgcp"
runs-on: ubuntu-latest
needs: build-operator-image
env:
CLUSTER_WORKERS: 5
TEST_CLUSTER_PLATFORM: gcp
CLUSTER_PROVIDER: gcp
ARTIFACT_REGISTRY: ${{ secrets.GCP_ARTIFACT_REGISTRY }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_REGION: ${{ secrets.GCP_REGION }}
GCP_ZONE: ${{ secrets.GCP_ZONE }}
GCP_NETWORK: default # Adjust if using a custom network
GCP_SUBNETWORK: default # Adjust if using a custom subnetwork
TEST_FOCUS: ${{ matrix.test_focus }}
CLUSTER_NODES: 2
SPLUNK_ENTERPRISE_IMAGE: ${{ secrets.SPLUNK_ENTERPRISE_IMAGE }}
SPLUNK_ENTERPRISE_RELEASE_IMAGE: ${{ secrets.SPLUNK_ENTERPRISE_RELEASE_IMAGE }}
SPLUNK_OPERATOR_IMAGE_NAME: splunk/splunk-operator
SPLUNK_OPERATOR_IMAGE_FILENAME: splunk-operator
TEST_TO_SKIP: "^(?:[^s]+|s(?:$|[^m]|m(?:$|[^o]|o(?:$|[^k]|k(?:$|[^e])))))*$"
TEST_BUCKET: ${{ secrets.TEST_BUCKET }}
TEST_INDEXES_S3_BUCKET: ${{ secrets.TEST_INDEXES_S3_BUCKET }}
GCP_ENTERPRISE_LICENSE_LOCATION: "test_licenses/"
ENTERPRISE_LICENSE_LOCATION: "test_licenses/"
REGISTRY_REPOSITORY: ${{ secrets.GCP_ARTIFACT_REGISTRY }}
CLUSTER_WIDE: "true"
GCP_SERVICE_ACCOUNT_ENABLED: "false"
PRIVATE_REGISTRY: ${{ secrets.GCP_ARTIFACT_REGISTRY }}
GCP_STORAGE_ACCOUNT: ${{ secrets.GCP_STORAGE_ACCOUNT }}
GCP_STORAGE_ACCOUNT_KEY: ${{ secrets.GCP_STORAGE_ACCOUNT_KEY }}
GCP_TEST_CONTAINER: ${{ secrets.GCP_TEST_CONTAINER}}
GCP_INDEXES_CONTAINER: ${{ secrets.GCP_INDEXES_CONTAINER}}
ECR_REPOSITORY: ${{ secrets.GCP_ARTIFACT_REGISTRY }}
GCP_CONTAINER_REGISTRY_LOGIN_SERVER: ${{ secrets.AZURE_ACR_LOGIN_SERVER }}
steps:
- name: Set Test Cluster Name
run: |
echo "CLUSTER_NAME=gke-$(echo ${{ matrix.test_focus }} | tail -c 5)-$GITHUB_RUN_ID" >> $GITHUB_ENV
- name: Checkout Code
uses: actions/checkout@v2
- name: Load Environment Variables
id: dotenv
uses: falti/dotenv-action@d4d12eaa0e1dd06d5bdc3d7af3bf4c8c93cb5359
with:
path: .env
- name: Authenticate to GCP
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
install_components: 'kubectl'
- name: Set GCP Project
run: |
gcloud config set project ${{ env.GCP_PROJECT_ID }}
- name: Create GKE Cluster
run: |
gcloud container clusters create ${{ env.CLUSTER_NAME }} \
--zone ${{ env.GCP_ZONE }} \
--num-nodes ${{ env.CLUSTER_WORKERS }} \
--machine-type e2-standard-4 \
--enable-ip-alias \
--network ${{ env.GCP_NETWORK }} \
--subnetwork ${{ env.GCP_SUBNETWORK }} \
--scopes "https://www.googleapis.com/auth/cloud-platform"
- name: Get Kubernetes Credentials
run: |
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --zone ${{ env.GCP_ZONE }} --project ${{ env.GCP_PROJECT_ID }}
- name: Allow Pulling from Artifact Registry
run: |
gcloud auth configure-docker ${{ secrets.GCP_ARTIFACT_REGISTRY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
install_components: 'kubectl'
- name: Change Splunk Enterprise Image on Main Branches
if: github.ref == 'refs/heads/main'
run: |
echo "SPLUNK_ENTERPRISE_IMAGE=${{ steps.dotenv.outputs.SPLUNK_ENTERPRISE_RELEASE_IMAGE }}" >> $GITHUB_ENV
- name: Authenticate to GCP
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
- name: Set GCP Project
run: |
gcloud config set project ${{ env.GCP_PROJECT_ID }}
- name: Install Kubectl
uses: azure/setup-kubectl@v3
with:
version: ${{ steps.dotenv.outputs.KUBECTL_VERSION }}
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.x' # Specify the Python version if needed
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ steps.dotenv.outputs.GO_VERSION }}
- name: Install Go Lint
run: |
go version
go install golang.org/x/lint/golint@latest
- name: Install Ginkgo
run: |
make setup/ginkgo
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.5.0
- name: Login to GCR
uses: docker/login-action@v3
with:
registry: ${{ secrets.GCP_ARTIFACT_REGISTRY }}
username: _json_key
password: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
- name: Pull Splunk Enterprise Image
run: docker pull ${{ env.SPLUNK_ENTERPRISE_IMAGE }}
- name: Pull Splunk Operator Image Locally
run: |
docker pull ${{ secrets.GCP_ARTIFACT_REGISTRY }}/${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA
docker tag ${{ secrets.GCP_ARTIFACT_REGISTRY }}/${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA ${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA
echo "SPLUNK_OPERATOR_IMAGE=${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA" >> $GITHUB_ENV
- name: Tag and Push Splunk Enterprise Image to Artifact Registry
run: |
docker tag ${{ env.SPLUNK_ENTERPRISE_IMAGE }} ${{ secrets.GCP_ARTIFACT_REGISTRY }}/${{ env.SPLUNK_ENTERPRISE_IMAGE }}
docker push ${{ secrets.GCP_ARTIFACT_REGISTRY }}/${{ env.SPLUNK_ENTERPRISE_IMAGE }}
- name: Get Kubernetes Credentials
run: |
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --zone ${{ env.GCP_ZONE }} --project ${{ env.GCP_PROJECT_ID }}
- name: Get GKE Credentials
uses: google-github-actions/get-gke-credentials@v1
with:
cluster_name: ${{ env.CLUSTER_NAME }}
location: ${{ env.GCP_ZONE }}
- name: Install Metrics Server
run: |
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
- name: Install Kubernetes Dashboard
run: |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.5/aio/deploy/recommended.yaml
- name: Setup Kustomize
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
sudo mv kustomize /usr/local/bin/
- name: Run Integration Tests
run: |
export GCP_SERVICE_ACCOUNT_KEY=${{ secrets.GCP_SERVICE_ACCOUNT_KEY_BASE64 }}
make int-test
- name: Collect Test Logs
if: ${{ always() }}
run: |
mkdir -p /tmp/pod_logs
find ./test -name "*.log" -exec cp {} /tmp/pod_logs \;
- name: Archive Pod Logs
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: splunk-pods-logs-artifacts-${{ matrix.test_focus }}
path: /tmp/pod_logs/**
- name: Cleanup Test Case Artifacts
if: ${{ always() }}
run: |
tools/cleanup.sh
make cleanup
make clean
- name: Delete GKE Cluster
if: always()
run: |
gcloud container clusters delete ${{ env.CLUSTER_NAME }} --zone ${{ env.GCP_ZONE }} --project ${{ env.GCP_PROJECT_ID }} --quiet