This is my final project submission for the She Code Africa Cloud School Bootcamp (Cohort 4). My topic is Containers & Kubernetes.
I created the infrastructure:
- Azure managed Kubernetes service (AKS)
- Storage account (to keep my Terraform state files, Helm repo) using Terraform, then I deployed a web app on AKS via Azure Pipelines (CI/CD).
Every time I make a push to my git repo, the image is re-built, stored as a build artifact, and then deployed to my AKS cluster.
The application fetches and displays a GitHub user's profile. It calls the Github API, to display the profile of any username typed in the search box.
$ python3-m venv venv
$ source venv/bin/activate
$ pip install --upgrade pip
$ pip install -r requirements.txt
$ python3 main.py
http://127.0.0.1:5500/
$ docker login
$ docker build -t <docker-hub-username>/<image-name>:tag .
$ docker push <docker-hub-username>/<image-name>:tag
- Create a project in your workspace.
- Run the scripts in the
infrastructure
folder.
$ cd terraform
$ az login
$ terraform init
$ terraform fmt
$ terraform validate
$ terraform plan
$ terraform apply
- Create an Azure Resource Manager service connection.
- Guide. This means the tasks and jobs will be executed on your local machine. This allows you to leverage the resources and capabilities of your local machine for building, testing, and deploying your applications.
I did this because I had to request for free parallelism
and it will take some days before my request is approved.
- Builds the Docker image and saves it as an artifact. Run the command below (to start the agent pool) before making a push to GitHub. Also, ensure Docker desktop is running in the backgrouund.
$ ./run.sh
- Connect your GitHub Repo to Azure DevOps
- Configuring my CI pipeline: start with a simple workflow option and add extra configuration as needed.
Use Helm to deploy your image on the AKS cluster.
- First, install Helm, the config files can be found in the
myhelm
folder. - Create and apply a
secrets.yaml
file in themyhelm/templates
folder.
$ touch secrets.yaml
$ kubectl -f apply myhelm/templates secrets.yaml
- Then create a Helm repo and add a Chart to the repo:
$ cd myhelm
$ helm package .
$ helm repo index .
- Upload the
index.yaml
and the folder with the.tgz
extension, to your Azure storage container created above. Then run:
$ helm repo add <repository-name> <repository-url>
Notes:
- The is the URL of the
index.yaml
file stored in the storage container. - For every change made to the config files, push the index and zip to storage account
- Verify chart is available
$ helm search repo <chart-name>
- Fetch chart information
$ helm repo update
- Configuring the CD pipeline Stage 1
- Setting the trigger
- Whenever a push is made to the GitHub repository, the CI pipeline is triggered, once the build is successful, the CD pipeline kicks off.
- You can access your cluster's external IP and port by running:
$ kubectl get services
Live link: http://52.189.27.203:5500/