Merge pull request #1398 from splunk/CSPL_3085 #440
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: Helm Test WorkFlow | |
on: | |
push: | |
branches: | |
- develop | |
- main | |
- feature** | |
jobs: | |
build-operator-image: | |
runs-on: ubuntu-latest | |
env: | |
SPLUNK_ENTERPRISE_IMAGE: ${{ secrets.SPLUNK_ENTERPRISE_IMAGE }} | |
SPLUNK_OPERATOR_IMAGE_NAME: splunk/splunk-operator | |
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }} | |
S3_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Dotenv Action | |
id: dotenv | |
uses: falti/dotenv-action@d4d12eaa0e1dd06d5bdc3d7af3bf4c8c93cb5359 | |
- name: Setup Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ steps.dotenv.outputs.GO_VERSION }} | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Install Operator SDK | |
run: | | |
export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac) | |
export OS=$(uname | awk '{print tolower($0)}') | |
export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/${{ steps.dotenv.outputs.OPERATOR_SDK_VERSION }} | |
sudo curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH} | |
sudo chmod +x operator-sdk_${OS}_${ARCH} | |
sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Make Splunk Operator Image | |
run: | | |
make docker-build IMG=${{ secrets.ECR_REPOSITORY }}/${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA | |
- name: Push Splunk Operator Image to ECR | |
run: | | |
echo "Uploading Image to ECR:: ${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA" | |
make docker-push IMG=${{ secrets.ECR_REPOSITORY }}/${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA | |
int-tests: | |
strategy: | |
fail-fast: false | |
runs-on: ubuntu-latest | |
needs: build-operator-image | |
env: | |
SPLUNK_ENTERPRISE_IMAGE: ${{ secrets.SPLUNK_ENTERPRISE_IMAGE }} | |
SPLUNK_OPERATOR_IMAGE_NAME: splunk/splunk-operator | |
SPLUNK_OPERATOR_IMAGE_FILENAME: splunk-operator | |
TEST_CLUSTER_PLATFORM: eks | |
EKS_VPC_PRIVATE_SUBNET_STRING: ${{ secrets.EKS_VPC_PRIVATE_SUBNET_STRING }} | |
EKS_VPC_PUBLIC_SUBNET_STRING: ${{ secrets.EKS_VPC_PUBLIC_SUBNET_STRING }} | |
TEST_BUCKET: ${{ secrets.TEST_BUCKET }} | |
TEST_INDEXES_S3_BUCKET: ${{ secrets.TEST_INDEXES_S3_BUCKET }} | |
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }} | |
PRIVATE_REGISTRY: ${{ secrets.ECR_REPOSITORY }} | |
S3_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
ENTERPRISE_LICENSE_LOCATION: ${{ secrets.ENTERPRISE_LICENSE_LOCATION }} | |
CLUSTER_WIDE: "true" | |
DEPLOYMENT_TYPE: "helm" | |
HELM_REPO_PATH: "../../../../helm-chart" | |
INSTALL_OPERATOR: "true" | |
TEST_VPC_ENDPOINT_URL: ${{ secrets.TEST_VPC_ENDPOINT_URL }} | |
steps: | |
- uses: chrisdickinson/setup-yq@3d931309f27270ebbafd53f2daee773a82ea1822 | |
- name: Checking YQ installation | |
run: | | |
yq --help | |
- name: Set Test Cluster Name | |
run: | | |
echo "TEST_CLUSTER_NAME=eks-integration-test-cluster-${{ matrix.test }}-$GITHUB_RUN_ID" >> $GITHUB_ENV | |
- name: Set Test Cluster Nodes and Parallel Runs | |
run: >- | |
if grep -q "appframework" <<< "${{ matrix.test }}"; then | |
echo "CLUSTER_WORKERS=5" >> $GITHUB_ENV | |
echo "CLUSTER_NODES=2" >> $GITHUB_ENV | |
fi | |
- name: Chekcout code | |
uses: actions/checkout@v2 | |
- name: Dotenv Action | |
id: dotenv | |
uses: falti/dotenv-action@d4d12eaa0e1dd06d5bdc3d7af3bf4c8c93cb5359 | |
- name: Change splunk enterprise to release image on main branches | |
if: github.ref == 'refs/heads/main' | |
run: | | |
echo "SPLUNK_ENTERPRISE_IMAGE=${{ steps.dotenv.outputs.SPLUNK_ENTERPRISE_RELEASE_IMAGE }}" >> $GITHUB_ENV | |
echo "HELM_REPO_PATH=splunk" >> $GITHUB_ENV | |
- name: Set GITHUB SHA value | |
run: | | |
echo "HELM_GITHUB_SHA=$GITHUB_SHA" >> $GITHUB_ENV | |
- name: Install Kubectl | |
uses: Azure/setup-kubectl@v3 | |
with: | |
version: ${{ steps.dotenv.outputs.KUBECTL_VERSION }} | |
- name: Install kuttl | |
run: | | |
sudo curl -LO https://github.com/kudobuilder/kuttl/releases/download/v0.12.0/kuttl_0.12.0_linux_x86_64.tar.gz | |
sudo tar -xvzf kuttl_0.12.0_linux_x86_64.tar.gz | |
sudo chmod +x kubectl-kuttl | |
sudo mv kubectl-kuttl /usr/local/bin/kubectl-kuttl | |
- name: Install Python | |
uses: actions/setup-python@v2 | |
- name: Install AWS CLI | |
run: | | |
curl "${{ steps.dotenv.outputs.AWSCLI_URL}}" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install --update | |
aws --version | |
- name: Setup Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ steps.dotenv.outputs.GO_VERSION }} | |
- name: Install Helm | |
run: | | |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | |
chmod 700 get_helm.sh | |
./get_helm.sh | |
DESIRED_VERSION=v3.8.2 bash get_helm.sh | |
- name: Install EKS CTL | |
run: | | |
curl --silent --insecure --location "https://github.com/weaveworks/eksctl/releases/download/${{ steps.dotenv.outputs.EKSCTL_VERSION }}/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp | |
sudo mv /tmp/eksctl /usr/local/bin | |
eksctl version | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Configure Docker Hub credentials | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN}} | |
- name: Pull Splunk Enterprise Image | |
run: docker pull ${{ env.SPLUNK_ENTERPRISE_IMAGE }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Pull Splunk Operator Image Locally and change name | |
run: | | |
docker pull ${{ secrets.ECR_REPOSITORY }}/${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA | |
docker tag ${{ secrets.ECR_REPOSITORY }}/${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA ${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA | |
- name: Tag and Push Splunk Enterprise Image to ECR | |
run: | | |
docker tag ${{ env.SPLUNK_ENTERPRISE_IMAGE }} ${{ secrets.ECR_REPOSITORY }}/${{ env.SPLUNK_ENTERPRISE_IMAGE }} | |
docker push ${{ secrets.ECR_REPOSITORY }}/${{ env.SPLUNK_ENTERPRISE_IMAGE }} | |
- name: Pull Splunk Operator Image Locally | |
run: | | |
docker pull ${{ secrets.ECR_REPOSITORY }}/${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA | |
- name: Change Operator Image Tag to latest | |
run: | | |
docker tag ${{ secrets.ECR_REPOSITORY }}/${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:$GITHUB_SHA ${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:latest | |
- name: Create EKS cluster | |
run: | | |
export EKS_CLUSTER_K8_VERSION=${{ steps.dotenv.outputs.EKS_CLUSTER_K8_VERSION }} | |
make cluster-up | |
- name: install metric server | |
run: | | |
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml | |
- name: install k8s dashboard | |
run: | | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.5/aio/deploy/recommended.yaml | |
- name: Add splunk helm repo for main branch | |
if: github.ref == 'refs/heads/main' | |
run: | | |
helm repo add splunk https://splunk.github.io/splunk-operator/ | |
- name: Run helm test | |
env: | |
KUTTL_SPLUNK_ENTERPRISE_IMAGE: ${{ secrets.ECR_REPOSITORY }}/${{ env.SPLUNK_ENTERPRISE_IMAGE }} | |
KUTTL_SPLUNK_OPERATOR_IMAGE: ${{ secrets.ECR_REPOSITORY }}/${{ env.SPLUNK_OPERATOR_IMAGE_NAME }}:${{ env.HELM_GITHUB_SHA }} | |
INSTALL_OPERATOR: true | |
S3_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
AWS_S3_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
TEST_S3_BUCKET: ${{ secrets.TEST_BUCKET }} | |
TEST_VPC_ENDPOINT_URL: ${{ secrets.TEST_VPC_ENDPOINT_URL }} | |
run: | | |
kubectl kuttl test --config kuttl/kuttl-test-helm.yaml --report xml | |
- name: Publish Results | |
uses: mikepenz/action-junit-report@v3 | |
if: always() | |
with: | |
report_paths: '*/kuttl-artifacts/.xml' | |
detailed_summary: true | |
- name: Cleanup Test Case artifacts | |
if: ${{ always() }} | |
run: | | |
make cleanup | |
make clean | |
- name: Cleanup up EKS cluster | |
if: ${{ always() }} | |
run: | | |
make cluster-down |