-
Notifications
You must be signed in to change notification settings - Fork 33
216 lines (183 loc) · 8.71 KB
/
logzio-monitoring-test.yaml
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
name: Test `logzio-monitoring` chart
on:
pull_request:
branches:
- master
paths:
- 'charts/logzio-monitoring/templates/**'
- 'charts/logzio-monitoring/Chart.yaml'
- 'charts/logzio-monitoring/values.yaml'
jobs:
eks-e2e-test:
name: EKS e2e Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
kubernetes_version: ['1.24', '1.25', '1.27', '1.30']
environment: [eks-linux, eks-fargate]
steps:
- name: Generate random id
id: random_id
run: echo "rand=$(echo $RANDOM)" >> $GITHUB_ENV
- name: Set ENV_ID
id: set_env_id
run: |
echo "ENV_ID=monitoring-test-run-${{ env.rand }}-${{ matrix.environment }}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up credentials
run: |
echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV
echo "AWS_REGION=us-east-1" >> $GITHUB_ENV
echo "NUMBER_OF_NODES=3" >> $GITHUB_ENV
echo "NODE_TYPE=m5.large" >> $GITHUB_ENV
echo "KUBERNETES_ENV=${{ matrix.environment }}" >> $GITHUB_ENV
echo "LOGZIO_LOGS_API_KEY=${{ secrets.LOGZIO_LOGS_API_KEY }}" >> $GITHUB_ENV
echo "LOGZIO_METRICS_API_KEY=${{ secrets.LOGZIO_METRICS_API_KEY }}" >> $GITHUB_ENV
echo "LOGZIO_TRACES_API_KEY=${{ secrets.LOGZIO_TRACES_API_KEY }}" >> $GITHUB_ENV
- name: Set up eksctl
run: |
ARCH=amd64
PLATFORM=$(uname -s)_$ARCH
curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz"
tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp && rm eksctl_$PLATFORM.tar.gz
sudo mv /tmp/eksctl /usr/local/bin
- name: Provision Cluster
run: |
if [ "${{ matrix.environment }}" == "eks-linux" ]; then
eksctl create cluster --name ${{ env.ENV_ID }}-${{ matrix.environment }} --region ${{ env.AWS_REGION }} \
--version ${{ matrix.kubernetes_version }} --nodes ${{ env.NUMBER_OF_NODES }} \
--node-type ${{ env.NODE_TYPE }} --with-oidc
elif [ "${{ matrix.environment }}" == "eks-fargate" ]; then
eksctl create cluster --name ${{ env.ENV_ID }}-${{ matrix.environment }} --region ${{ env.AWS_REGION }} \
--version ${{ matrix.kubernetes_version }} --fargate
fi
- name: Update kubeconfig
run: |
aws eks --region ${{ env.AWS_REGION }} update-kubeconfig --name ${{ env.ENV_ID }}-${{ matrix.environment }}
- name: Label Nodes
if: matrix.environment == 'eks-linux'
run: |
kubectl get nodes -o name | xargs -I {} kubectl label {} node-role.kubernetes.io/worker=worker --overwrite
- name: Deploy Helm Chart
run: |
cd charts/logzio-monitoring
helm dependency build
HELM_CMD="helm upgrade --install \
--set logs.enabled=true \
--set logzio-logs-collector.enabled=true \
--set logzio-logs-collector.secrets.logzioLogsToken='${{ secrets.LOGZIO_LOGS_TOKEN }}' \
--set logzio-logs-collector.secrets.logzioRegion='us' \
--set logzio-logs-collector.secrets.env_id='${{ env.ENV_ID }}' \
--set logzio-logs-collector.secrets.logType='${{ env.ENV_ID }}' \
--set metricsOrTraces.enabled=true \
--set logzio-k8s-telemetry.metrics.enabled=true \
--set logzio-k8s-telemetry.secrets.MetricsToken='${{ secrets.LOGZIO_METRICS_TOKEN }}' \
--set logzio-k8s-telemetry.secrets.ListenerHost='https://listener.logz.io:8053' \
--set logzio-k8s-telemetry.secrets.p8s_logzio_name='${{ env.ENV_ID }}' \
--set logzio-k8s-telemetry.traces.enabled=true \
--set logzio-k8s-telemetry.secrets.TracesToken='${{ secrets.LOGZIO_TRACES_TOKEN }}' \
--set logzio-k8s-telemetry.secrets.LogzioRegion='us' \
--set logzio-k8s-telemetry.spm.enabled=true \
--set logzio-k8s-telemetry.secrets.env_id='${{ env.ENV_ID }}' \
--set logzio-k8s-telemetry.secrets.SpmToken='${{ secrets.LOGZIO_METRICS_TOKEN }}' \
--set logzio-k8s-telemetry.serviceGraph.enabled=true"
if [ "${{ matrix.environment }}" == "eks-fargate" ]; then
HELM_CMD="$HELM_CMD --set logzio-logs-collector.fargateLogRouter.enabled='true' --set logzio-k8s-telemetry.collector.mode=standalone"
fi
HELM_CMD="$HELM_CMD logzio-monitoring ."
echo "Running Helm command: $HELM_CMD"
eval $HELM_CMD
- name: Wait for pods to be ready
run: |
kubectl rollout status deployment/logzio-monitoring-otel-collector-standalone --timeout=300s
kubectl rollout status deployment/logzio-monitoring-otel-collector-spm --timeout=300s
kubectl rollout status deployment/logzio-monitoring-kube-state-metrics --timeout=300s
if [ "${{ matrix.environment }}" == "eks-linux" ]; then
kubectl rollout status ds/logzio-monitoring-prometheus-node-exporter --timeout=300s
kubectl rollout status ds/logzio-monitoring-otel-collector-ds --timeout=300s
fi
- name: Check `aws-observability` namespace and configmap (fargate)
if: matrix.environment == 'eks-fargate'
run: |
NAMESPACE="aws-observability"
CONFIGMAP="aws-logging"
if kubectl get namespace $NAMESPACE; then
echo "Namespace $NAMESPACE exists."
else
echo "Namespace $NAMESPACE does not exist."
exit 1
fi
# Check if the configmap exists in the namespace
if kubectl get configmap $CONFIGMAP -n $NAMESPACE; then
echo "ConfigMap $CONFIGMAP exists in namespace $NAMESPACE."
else
echo "ConfigMap $CONFIGMAP does not exist in namespace $NAMESPACE."
exit 1
fi
- name: Run log generator
run: |
kubectl apply -f tests/resources/logsgen.yaml
kubectl rollout status deployment/log-generator --timeout=300s
- name: Run trace generator
run: |
kubectl apply -f tests/resources/tracegen-monitoring.yaml
kubectl rollout status deployment/trace-gen --timeout=300s
- name: Run otel demo
run: |
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo update
helm install otel-demo -f tests/resources/otel-demo-monitoring.yaml open-telemetry/opentelemetry-demo --version 0.32.5
kubectl rollout status deployment/otel-demo-loadgenerator --timeout=300s
- name: Sleep
run: sleep 180
- name: Get Logs
run: |
echo "logzio-monitoring-otel-collector-standalone: "
kubectl logs deployment/logzio-monitoring-otel-collector-standalone
echo "logzio-monitoring-otel-collector-spm: "
kubectl logs deployment/logzio-monitoring-otel-collector-spm
if [ "${{ matrix.environment }}" == "eks-linux" ]; then
echo "logzio-monitoring-otel-collector-ds: "
kubectl logs ds/logzio-monitoring-otel-collector-ds
fi
- name: Run logs tests
id: logs_tests
continue-on-error: true
run: |
go get go.uber.org/zap
if [ "${{ matrix.environment }}" == "eks-linux" ]; then
go test -v ./tests/logs_e2e_test.go ./tests/common.go
elif [ "${{ matrix.environment }}" == "eks-fargate" ]; then
go test -v ./tests/fargate_logs_e2e_test.go ./tests/common.go
fi
- name: Run metrics tests
id: metrics_tests
continue-on-error: true
run: |
go get go.uber.org/zap
go test -v ./tests/metrics_e2e_test.go ./tests/common.go
- name: Run traces tests
id: traces_tests
continue-on-error: true
run: |
go get go.uber.org/zap
go test -v ./tests/traces_e2e_test.go ./tests/common.go
- name: Check test results
run: |
if [ "${{ steps.logs_tests.outcome }}" == "failure" ] || \
[ "${{ steps.metrics_tests.outcome }}" == "failure" ] || \
[ "${{ steps.traces_tests.outcome }}" == "failure" ]; then
echo "One or more tests failed"
exit 1
fi
- name: Uninstall Helm Chart
if: always()
run: |
helm uninstall logzio-monitoring
- name: Delete Cluster
if: always()
run: |
eksctl delete cluster --name ${{ env.ENV_ID }}-${{ matrix.environment }} --region ${{ env.AWS_REGION }}