- Exporting existing Kubernetes resources to YAML
- Cleaning up and reapplying manifests
- Deleting old imperative resources
- Redeploying declaratively
- Designing a push-based CI/CD workflow with Azure DevOps
Preparing Your Environment
- Log in to your Azure subscription (local machine or Cloud Shell).
- Fetch and merge your AKS credentials into
kubeconfig:
- Verify your existing Service and Deployment:
Make sure your current context points to the correct AKS cluster. Use
kubectl config current-context to check.1. Export the Deployment to YAML
Run the following command to export thekodekloudapp Deployment manifest:
deployment.yaml:
Tip: Customizereplicas,strategy, and container resources to match your production requirements.
2. Export the Service to YAML
Export the Service object:service.yaml:
clusterIPstatus.loadBalancer.ingressspec.ports[*].nodePort
service.yaml should look like:
If you switch to
type: NodePort, ensure nodePort values are in the 30000–32767 range.3. Delete Imperative Resources
Remove the existing Deployment and Service:4. Redeploy Declaratively
Apply your YAML manifests:5. Push-Based CI/CD Pipeline Overview
Below is a sample push-based pipeline in Azure DevOps. You can adapt these stages for GitHub Actions, GitLab CI, or other tools.| Stage | Description | Example Tools |
|---|---|---|
| Source Control | Push code & manifests to Git repo | Azure Repos, GitHub, GitLab |
| Continuous Integration | Build container image and run unit tests | Azure Pipelines, GitHub Actions |
| Artifact Publishing | Push Docker image to registry | ACR, Docker Hub, ECR |
| Continuous Deployment | Detect new image; apply YAML to AKS | kubectl apply, Helm, Flux CD |
| Monitoring & Feedback | Collect logs/metrics, update backlog | Azure Monitor, Application Insights |
- Commit & Push your application code and
deployment.yaml+service.yamlto your repo. - CI Pipeline: Build the container image, run tests, and publish to Azure Container Registry (ACR).
- CD Trigger: ACR webhook invokes the CD pipeline upon new image push.
- Deploy: Execute
kubectl apply -fon your manifests to update AKS. - Monitor: Use Azure Monitor or Application Insights for observability.