7.7 KiB
7.7 KiB
Deployment Guide
This guide covers deploying online-boutique to Azure Kubernetes Service via Humanitec or ArgoCD.
Deployment Methods
1. Humanitec Platform Orchestrator (Primary)
Humanitec manages deployments using the score.yaml specification, automatically provisioning resources and handling promotions across environments.
Prerequisites
- Humanitec Organization:
kyn-cjot - Application registered in Humanitec
- Environments created (development, staging, production)
- Gitea Actions configured with HUMANITEC_TOKEN secret
Automatic Deployment (via Gitea Actions)
Push to trigger workflows:
git add .
git commit -m "feat: new feature"
git push origin main
Build & Push Workflow (.gitea/workflows/build-push.yml):
- Maven build & test
- Docker image build
- Push to Azure Container Registry (ACR)
- Tags:
latest,git-SHA,semantic-version
Deploy Workflow (.gitea/workflows/deploy-humanitec.yml):
- Parses image from build
- Updates score.yaml with image reference
- Deploys to Humanitec environment
- Triggers orchestration
Manual Deployment with humctl CLI
Install Humanitec CLI:
# macOS
brew install humanitec/tap/humctl
# Linux/Windows
curl -s https://get.humanitec.io/install.sh | bash
Login:
humctl login --org kyn-cjot
Deploy from Score:
humctl score deploy \
--org kyn-cjot \
--app online-boutique \
--env development \
--file score.yaml \
--image bstagecjotdevacr.azurecr.io/online-boutique:latest \
--message "Manual deployment from local"
Deploy specific version:
humctl score deploy \
--org kyn-cjot \
--app online-boutique \
--env production \
--file score.yaml \
--image bstagecjotdevacr.azurecr.io/online-boutique:v1.2.3 \
--message "Production release v1.2.3"
Environment Promotion
Promote from development → staging:
humctl deploy \
--org kyn-cjot \
--app online-boutique \
--env staging \
--from development \
--message "Promote to staging after testing"
Promote to production:
humctl deploy \
--org kyn-cjot \
--app online-boutique \
--env production \
--from staging \
--message "Production release"
Check Deployment Status
# List deployments
humctl get deployments \
--org kyn-cjot \
--app online-boutique \
--env development
# Get specific deployment
humctl get deployment <DEPLOYMENT_ID> \
--org kyn-cjot \
--app online-boutique \
--env development
# View deployment logs
humctl logs \
--org kyn-cjot \
--app online-boutique \
--env development
2. ArgoCD GitOps (Fallback)
If Humanitec is unavailable, use ArgoCD with Kubernetes manifests in deploy/.
Create ArgoCD Application
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: online-boutique
namespace: argocd
spec:
project: default
source:
repoURL: https://gitea.kyndemo.live/validate/online-boutique.git
targetRevision: main
path: deploy
destination:
server: https://kubernetes.default.svc
namespace:
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
Apply:
kubectl apply -f argocd-app.yaml
Manual Deploy with kubectl
Update image in deploy/kustomization.yaml:
images:
- name: app-image
newName: bstagecjotdevacr.azurecr.io/online-boutique
newTag: v1.2.3
Deploy:
kubectl apply -k deploy/
Verify:
kubectl -n get pods
kubectl -n get svc
kubectl -n get ing
Kubernetes Access
Get AKS Credentials
az aks get-credentials \
--resource-group bstage-cjot-dev \
--name bstage-cjot-dev-aks \
--overwrite-existing
View Application
# List pods
kubectl -n get pods
# Check pod logs
kubectl -n logs -f deployment/online-boutique
# Describe deployment
kubectl -n describe deployment online-boutique
# Port-forward for local access
kubectl -n port-forward svc/online-boutique-service 8080:80
Check Health
# Health endpoint
kubectl -n exec -it deployment/online-boutique -- \
curl http://localhost:8080/actuator/health
# Metrics endpoint
kubectl -n exec -it deployment/online-boutique -- \
curl http://localhost:8080/actuator/prometheus
Environment Configuration
Development
- Purpose: Active development, frequent deployments
- Image Tag:
latestorgit-SHA - Replicas: 1
- Resources: Minimal (requests: 256Mi RAM, 250m CPU)
- Monitoring: Prometheus scraping enabled
Staging
- Purpose: Pre-production testing, integration tests
- Image Tag: Semantic version (e.g.,
v1.2.3-rc.1) - Replicas: 2
- Resources: Production-like (requests: 512Mi RAM, 500m CPU)
- Monitoring: Full observability stack
Production
- Purpose: Live traffic, stable releases
- Image Tag: Semantic version (e.g.,
v1.2.3) - Replicas: 3+ (autoscaling)
- Resources: Right-sized (requests: 1Gi RAM, 1 CPU)
- Monitoring: Alerts enabled, SLO tracking
Rollback Procedures
Humanitec Rollback
# List previous deployments
humctl get deployments \
--org kyn-cjot \
--app online-boutique \
--env production
# Rollback to specific deployment
humctl deploy \
--org kyn-cjot \
--app online-boutique \
--env production \
--deployment-id <PREVIOUS_DEPLOYMENT_ID> \
--message "Rollback due to issue"
Kubernetes Rollback
# Rollback to previous revision
kubectl -n rollout undo deployment/online-boutique
# Rollback to specific revision
kubectl -n rollout undo deployment/online-boutique --to-revision=2
# Check rollout status
kubectl -n rollout status deployment/online-boutique
# View rollout history
kubectl -n rollout history deployment/online-boutique
Troubleshooting
Pod Not Starting
# Check pod events
kubectl -n describe pod <POD_NAME>
# Check logs
kubectl -n logs <POD_NAME>
# Check previous container logs (if restarting)
kubectl -n logs <POD_NAME> --previous
Image Pull Errors
# Verify ACR access
az acr login --name bstagecjotdevacr
# Check image exists
az acr repository show-tags --name bstagecjotdevacr --repository online-boutique
# Verify AKS ACR integration
az aks check-acr \
--resource-group bstage-cjot-dev \
--name bstage-cjot-dev-aks \
--acr bstagecjotdevacr.azurecr.io
Service Not Accessible
# Check service endpoints
kubectl -n get endpoints online-boutique-service
# Check ingress
kubectl -n describe ingress online-boutique-ingress
# Test internal connectivity
kubectl -n run curl-test --image=curlimages/curl:latest --rm -it --restart=Never -- \
curl http://online-boutique-service/actuator/health
Humanitec Deployment Stuck
# Check deployment status
humctl get deployment <DEPLOYMENT_ID> \
--org kyn-cjot \
--app online-boutique \
--env development
# View error logs
humctl logs \
--org kyn-cjot \
--app online-boutique \
--env development \
--deployment-id <DEPLOYMENT_ID>
# Cancel stuck deployment
humctl delete deployment <DEPLOYMENT_ID> \
--org kyn-cjot \
--app online-boutique \
--env development
Resource Issues
# Check resource usage
kubectl -n top pods
# Describe pod for resource constraints
kubectl -n describe pod <POD_NAME> | grep -A 10 "Conditions:"
# Check node capacity
kubectl describe nodes | grep -A 10 "Allocated resources:"
Blue-Green Deployments
For zero-downtime deployments with Humanitec:
- Deploy new version to staging
- Run smoke tests
- Promote to production with traffic splitting
- Monitor metrics
- Complete cutover or rollback