Table of Contents:
This project is about creating an simple python app that list the blob files inside an Azure Blob Storage Container. The app will use an App registration(service principal) for authorization/authentication to the azure API. The app will expose an endpoint where a REST API will be served.
List any major frameworks/libraries used:
Flask web framework Azure Python SDK for communicating with Azure's API Flasgger for the Swagger UI
Follow the steps below to install the application on your Kubernetes cluster.
In oder to deploy the application you must have
- a Kubernetes cluster you can access (see Creating the Azure resources section)
- kubectl installed and a valid kubeconfig with which to connect to the cluster
- helm installed
- the azure service principal credentials, azure storage account url and azure Blob storage container name (see Creating the Azure resources section)
-
Login to your azure account via azure-cli:
- install azure-cli
- sign in with azure-cli
-
Create a Blob Storage
- create a resource group
# Set Resource Group Name RGNAME="rkubes-rg" # Set Region (Location) or any other location LOCATION="westeurope" # Create Resource Group az group create -n $RGNAME -l $LOCATION
- create the blob
#Set Storage Account Name. SA_NAME="rkubesblobstorage" # Must be globaly unique. If already in use try adding a random number as a suffix (ex. SA_NAME="rkubesblobstorage${RANDOM}") az storage account create --name $SA_NAME --resource-group $RGNAME --location $LOCATION --sku Standard_ZRS --encryption-services blob
- create a container
# Set container name CONTAINER_NAME="democontainer" az storage container create --account-name $SA_NAME --name $CONTAINER_NAME --auth-mode login
- create a resource group
-
Create a service principal
- create a service principal
# Set the service principal name SP_NAME="rkubesapp-sp" az ad sp create-for-rbac --name $SP_NAME
- note down the outputted credentials, will use them later
- create a role
# Get the blob storage resource id SA_ID=$(az storage account list --query "[?name=='${SA_NAME}'].id" -otsv) # Set AZURE_CLIENT_ID. It was outputed in Step 3.1 when creating the Service principal # It can also be printed via az cli as showed below AZURE_CLIENT_ID=$(az ad app list --query "[?displayName=='${SP_NAME}'].appId" -otsv) # Set the role name ROLE_NAME='rkubes_app_role' az role assignment create --assignee $AZURE_CLIENT_ID --scope $SA_ID --role $ROLE_NAME ```
- create a service principal
-
Create the AKS Cluster:
# Set Resource Group Name AKS_RGNAME=otomi # Create Resource Group az group create -n $RGNAME -l $LOCATION # Set Cluster name NAME=quickstart CLUSTER_NAME=otomi-aks-$NAME # Create AKS cluster az aks create --name $CLUSTER_NAME \ --resource-group $AKS_RGNAME \ --location $LOCATION \ --vm-set-type VirtualMachineScaleSets \ --nodepool-name otomipool \ --node-count 1 \ --node-vm-size Standard_F8s_v2 \ --kubernetes-version 1.23.8 \ --enable-cluster-autoscaler \ --min-count 1 \ --max-count 3 \ --max-pods 100 \ --network-plugin azure \ --network-policy calico \ --outbound-type loadBalancer \ --uptime-sla \ --generate-ssh-keys
-
Configure kubectl
# Get the kubeconfig az aks get-credentials --overwrite-existing --admin -g $AKS_RGNAME -n $CLUSTER_NAME # Test it kubectl get ns # It should show the default k8s namespaces
- Add the helm repo
helm repo add redkubes https://ani.al/charts
- Update the helm repo
helm repo update
- Create a values file to configure the app
- run this command to create a values file called myvalues.yaml
helm show values rkubesapp/rkubesapp > myvalues.yaml
- edit the myvalues.yaml file by updating the desired values. The app needs this values to work:
azureClientID, azureClientSecret, azureTenantID, storageAccountUrl,containerName
- run this command to create a values file called myvalues.yaml
- Install the helm chart
helm install rkubes rkubesapp/rkubesapp -f myvalues.yaml
The app will will create a service of type clusterIP. One way to access the app is by port-forwarding the service to a local port by running kubectl port-forward services/rkubes-rkubesapp 8080:80
. Now the app is reachable through localhost:8080
. Browse localhost:8080/files
to get the list of file inside the azure container.
- MVP Python Rest API
- Docker image uploaded to docker hub
- Helm chart created
- Helm repository created
- Helm chart available publicly
- Deployed and tested in Azure
- Write a AKS installation guide
- Deploy and test on minikube
- Write a minikube installation guide
- Deploy on top of OTOMI
- Update the app with functional swagger UI
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Your Name - [email protected]
Project Link: https://github.com/Ani1357/rkubeAssesment