- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
Secure Workload Identity and Secrets Using OIDC and Azure Key Vault
You’re the DevSecOps engineer for an AKS-hosted microservice app that currently renders placeholder data because it has no database connectivity. Your goal is to configure secure secret synchronization with Azure Key Vault so the app can connect to Azure Cosmos DB (MongoDB API). You will enable AKS OIDC Workload Identity to authenticate the pod to Key Vault , store the Cosmos DB connection string (which includes the password) in Azure Key Vault, sync that secret into Kubernetes via the Secrets Store CSI driver, and update the deployment to consume the connection string so the frontend can connect to the database.
Lab Info
Table of Contents
-
Challenge
Review the existing configuration
Retrieve the details of the Kubernetes service named
frontendin thesimple-grocery-storenamespace, and access the Public IP address. -
Challenge
Configure AKS cluster with OIDC and Key Vault secrets provider
- Enable OIDC issuer and Workload Identity on the AKS cluster
- Enable Azure Key Vault Secrets Provider on the AKS cluster
-
Challenge
Retrieve and store Cosmos DB connection string in Azure Key Vault
Retrieve the Cosmos DB connection string and store it in the Key Vault in a secret named
MongoDb-Connection-String. -
Challenge
Set up workload identity federation for AKS using the managed identity
- Create a Service account in the
simple-grocery-storenamespace with an annotation that links it the existing managed identityid-aks-secrets - Create a federated identity credential that links the Kubernetes service account to the managed identity
- Create a SecretProviderClass to sync secrets from Azure Key Vault
- Create a Service account in the
-
Challenge
Update product service deployment to use workload identity and Key Vault secrets
- Update the
product-servicedeployment in thesimple-grocery-storenamespace to use the new service account and mount the secrets from the SecretProviderClass - Mount the the
mongodb-connection-stringsecret using thesecretProviderClassas an environment variable namedMONGO_URI
- Update the
-
Challenge
Verify secret configuration and connectivity to Cosmos DB
- Confirm the rollout of the updated deployment
- Retrieve the deployment logs to confirm connectivity to the database
- Review the web application to confirm products are loaded from the database
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.