GithubHelp home page GithubHelp logo

ardeshir / automated-test-environment-for-aks-applications Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure-samples/automated-test-environment-for-aks-applications

0.0 2.0 0.0 126 KB

Framework to create Automated Test Environment using kind (Kubernetes in Docker) for testing Azure Kubernetes Service (AKS) based applications in CI (Continuous Integration) Pipeline (Azure DevOps)

License: MIT License

Shell 100.00%

automated-test-environment-for-aks-applications's Introduction

Automated Test Environment for AKS Applications

Framework to create Automated Test Environment using KIND for testing Azure Kubernetes Service (AKS) based applications in CI (Continuous Integration) Pipeline (Azure DevOps), where required dependencies/infrastructure will be provisioned for executing automated tests and de-provisioned after completion.

Testing the applications to be deployed over Kubernetes means either the Cluster is already available or is to be deployed on the go before you test, in former case its a cost to keep the Cluster live and in later it takes a lot of time to bring up the kubernetes cluster.

This framework uses KIND which itself was primarily designed for testing Kubernetes itself. KIND is often used by developers to test their applications in local dev environments and can very well be used for automated testing.

Tools Used

  1. KIND - a tool for running local Kubernetes clusters using Docker container “nodes”
  2. helm - the package manager for Kubernetes
  3. kubectl - command line tool to control Kubernetes clusters
  4. bash - the GNU Project's shell

Features

This is a very simple Framework, that creates Automated Test Environment to enable automated testing of applications hosted in Azure Kubernetes Service (AKS) with the following features -

  1. Create/Delete KIND cluster in CI environment
  2. Optional - Azure Key Vault Provider for Secrets Store CSI Driver installation and configuration
  3. Optional - Azure Container Registry (ACR) Image Pull Secret
  4. Install helm charts of application (values needed for integration test environment can be overwritten easily)
  5. Validate if the respective Kubernetes pods are up and running (multiple pods can be provided that are having selector - app.kubernetes.io/name)
  6. Port-Forward the respective Kubernetes services needed to perform integration testing (multiple services can be provided and the respective local ports will be starting from 8080 to 808[number of services] maintaining the order as provided)

Getting Started

This framework contains the following script and their options -

  1. start.sh: Download all the dependencies and create kind cluster -
# Usage: bash -f ./start.sh
#        Supported Options -
#               --kind-cluster-name=<Kind Cluster Name> (default INTEGRATION_TEST_CLUSTER)
#               --kind-version (default v0.7.0)
#               --kubectl-version (default v1.18.0)
#               --helm-version (default v3.2.0)
  1. deploy.sh: Deploy/Port-Forward application helm chart and enables optional features -
# Usage: bash -f ./deploy.sh
#        Supported Options - 
#              --csi-driver-enabled=<yes/no> (default no, if yes provide following two parameters)
#              --csi-driver-sp-client-id=<Azure Service Principle ID, having access to Azure Key Vault>
#              --csi-driver-sp-client-secret=<Azure Service Principle Secret, having access to Azure Key Vault>
#              --acr-imagepullsecret-enabled=<yes/no> (default no, if yes provide following three parameters)
#              --acr-imagepullsecret-sp-client-id=<Azure Service Principle ID, having access to Azure Container Registry>
#              --acr-imagepullsecret-sp-client-secret=<Azure Service Principle Secret, having access to Azure Container Registry>
#              --acr-full-name=<Azure Container Registry full name ex. example.azurecr.io>
#              --helm-chart-path=<Helm Chart Folder Path or URL to .tgz file for the applications >
#              --helm-chart-release-name=<Helm Release Name>
#              --helm-chart-set-parameters=<","(comma) seprated Helm Set parameters needed to be overwritten for integration test env>
#              --kubectl-check-services=<","(comma) seprated Pod names needed to be check if up and running>
#              --kubectl-check-services-selector-label=<ex. app.kubernetes.io/name or name etc.> (default app.kubernetes.io/name)
#              --kubectl-port-forward-services=<","(comma) seprated Service names needed to port-forward for testing>
  1. stop.sh: Delete KIND cluster -
# Usage: bash -f ./stop.sh
#        Supported Options -
#               --kind-cluster-name=<Kind Cluster Name> (default INTEGRATION_TEST_CLUSTER)

Demo

For demonstrating the framework following setup has been used -

Expected Outcome

It is expected to get Integration Test executed from CI Pipeline independently without disturbing existing development. The below images represents the outcome of the sample for demonstrating the framework -

Sample Azure DevOps Pipeline Execution

Resources

Some additional points need to be considered -

  • While using Private Endpoint enabled Azure Key Vault (AKV) or Azure Container Registry (ACR) for applications, make sure the to use CI Pipeline Agent deployed in the same subnet where AKV or ACR endpoints are enabled

References

automated-test-environment-for-aks-applications's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.