EKS fargate support in automatic helm tests #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Logzio Monitoring Helm Chart on EKS Kubernetes Environments | |
on: | |
pull_request: | |
branches: | |
- master | |
paths: | |
- 'charts/logzio-monitoring/**' | |
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] | |
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=t3.medium" >> $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 secrets.logType='test' \ | |
--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'" | |
fi | |
HELM_CMD="$HELM_CMD logzio-monitoring ." | |
eval $HELM_CMD | |
kubectl rollout status deployment/logzio-monitoring-otel-collector-standalone --timeout=300s | |
kubectl rollout status deployment/logzio-monitoring-otel-collector-spm --timeout=300s | |
- 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: Sleep | |
run: sleep 180 | |
- name: Run linux logs tests | |
id: linux_logs_tests | |
continue-on-error: true | |
if: matrix.environment == 'eks-linux' | |
run: | | |
go get go.uber.org/zap | |
go test -v ./tests/logs_e2e_test.go ./tests/common.go | |
- name: Run fargate logs tests | |
id: fargate_logs_tests | |
continue-on-error: true | |
if: matrix.environment == 'eks-fargate' | |
run: | | |
go get go.uber.org/zap | |
go test -v ./tests/fargate_logs_e2e_test.go ./tests/common.go | |
- 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.linux_logs_tests.outcome }}" == "failure" ] || \ | |
[ "${{ steps.fargate_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 }} | |