CI Integration
OpenChoreo seamlessly integrates with existing CI/CD pipelines to automate application deployment and management. This guide demonstrates how to incorporate OpenChoreo into popular CI systems for streamlined development workflows.
Overviewβ
OpenChoreo's CI integration enables:
- Automated deployments triggered by code changes
- Environment promotion through deployment pipelines
- Configuration validation before deployment
- Rollback capabilities for failed deployments
- Integration testing in isolated environments
Supported CI Systemsβ
GitHub Actionsβ
OpenChoreo provides official GitHub Actions for seamless integration:
name: Deploy to OpenChoreo
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup OpenChoreo CLI
uses: openchoreo/setup-choreo@v1
with:
version: 'latest'
- name: Deploy Application
run: |
choreo auth login --token ${{ secrets.CHOREO_TOKEN }}
choreo deploy --environment production
env:
CHOREO_TOKEN: ${{ secrets.CHOREO_TOKEN }}
GitLab CIβ
Integration with GitLab CI using Docker containers:
stages:
- build
- test
- deploy
deploy_production:
stage: deploy
image: openchoreo/cli:latest
script:
- choreo auth login --token $CHOREO_TOKEN
- choreo deploy --environment production
only:
- main
variables:
CHOREO_TOKEN: $CHOREO_API_TOKEN
Jenkinsβ
Jenkins pipeline integration using the OpenChoreo CLI:
pipeline {
agent any
environment {
CHOREO_TOKEN = credentials('choreo-api-token')
}
stages {
stage('Deploy') {
steps {
sh '''
curl -sSL https://install.openchoreo.dev | sh
choreo auth login --token ${CHOREO_TOKEN}
choreo deploy --environment production
'''
}
}
}
}
CI Workflow Patternsβ
Feature Branch Deploymentβ
Deploy feature branches to ephemeral environments:
name: Feature Branch Deploy
on:
pull_request:
types: [opened, synchronize]
jobs:
deploy-feature:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create Feature Environment
run: |
choreo env create --name "feature-${{ github.head_ref }}" \
--template development
- name: Deploy to Feature Environment
run: |
choreo deploy --environment "feature-${{ github.head_ref }}"
Multi-Environment Promotionβ
Promote applications through environments:
name: Multi-Environment Deploy
on:
push:
branches: [main]
jobs:
deploy-staging:
runs-on: ubuntu-latest
steps:
- name: Deploy to Staging
run: choreo deploy --environment staging
deploy-production:
needs: deploy-staging
runs-on: ubuntu-latest
environment: production
steps:
- name: Deploy to Production
run: choreo deploy --environment production
Build Integrationβ
Container Image Buildingβ
Integrate with container registries:
- name: Build and Push Image
run: |
docker build -t ${{ env.REGISTRY }}/app:${{ github.sha }} .
docker push ${{ env.REGISTRY }}/app:${{ github.sha }}
- name: Update OpenChoreo Configuration
run: |
choreo component update app \
--image ${{ env.REGISTRY }}/app:${{ github.sha }}
Cloud Native Buildpacksβ
Use Buildpacks for automatic image creation:
- name: Build with Buildpacks
run: |
pack build ${{ env.REGISTRY }}/app:${{ github.sha }} \
--builder paketobuildpacks/builder:base
docker push ${{ env.REGISTRY }}/app:${{ github.sha }}
Testing Integrationβ
Integration Testingβ
Run tests against deployed environments:
- name: Deploy Test Environment
run: choreo deploy --environment test
- name: Run Integration Tests
run: |
export API_URL=$(choreo env get test --output json | jq -r '.endpoints.api.url')
npm run test:integration
- name: Cleanup Test Environment
run: choreo env delete test
if: always()
Load Testingβ
Automated performance testing:
- name: Load Testing
run: |
export APP_URL=$(choreo component get api --environment staging -o json | jq -r '.url')
k6 run --env API_URL=$APP_URL load-test.js
Security and Secrets Managementβ
API Token Managementβ
Secure token handling across CI systems:
- name: Configure OpenChoreo Auth
run: |
echo "${{ secrets.CHOREO_TOKEN }}" | choreo auth login --stdin
- name: Verify Authentication
run: choreo auth whoami
Secrets Injectionβ
Automatic secrets deployment:
- name: Deploy Application Secrets
run: |
choreo secret create database-url \
--value "${{ secrets.DATABASE_URL }}" \
--environment production
Monitoring and Notificationsβ
Deployment Statusβ
Track deployment progress:
- name: Monitor Deployment
run: |
choreo deploy --environment production --wait
- name: Verify Health Checks
run: |
choreo component status api --environment production
Slack Integrationβ
Notify teams of deployment status:
- name: Notify Deployment Success
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
text: "Deployment to production completed successfully"
if: success()
Troubleshootingβ
Common Issuesβ
Authentication Failures
- Verify API token permissions
- Check token expiration
- Ensure proper secret configuration
Deployment Timeouts
- Increase timeout values
- Check resource availability
- Monitor application startup logs
Environment Conflicts
- Use unique environment names
- Implement proper cleanup strategies
- Validate environment state before deployment
Debug Modeβ
Enable verbose logging for troubleshooting:
choreo deploy --environment production --debug --verbose
Best Practicesβ
- Use environment-specific configurations
- Implement proper secret management
- Enable deployment monitoring and alerting
- Use feature flags for gradual rollouts
- Maintain deployment history and rollback capabilities
- Test deployments in staging environments first