Integrating Popular CI/CD Tools
Learn how to integrate popular CI/CD tools with your edge platform to create seamless deployment pipelines.
Supported Tools Overview
GitHub Actions
- Best for: GitHub-hosted repositories.
- Strengths: Native integration, extensive marketplace.
- Use case: Open source and enterprise projects.
GitLab CI/CD
- Best for: GitLab-hosted repositories.
- Strengths: Built-in container registry, comprehensive DevOps platform.
- Use case: End-to-end DevOps workflows.
Jenkins
- Best for: On-premises or hybrid deployments.
- Strengths: Highly customizable, extensive plugin ecosystem.
- Use case: Legacy systems integration.
CircleCI
- Best for: Fast build times and parallel execution.
- Strengths: Docker-first approach, advanced caching.
- Use case: Performance-critical pipelines.
GitHub Actions Integration
Basic Workflow
name: Deploy to Edge Platform
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.24.0'
- name: Configure kubeconfig
run: |
echo "${{ secrets.KUBECONFIG }}" | base64 -d > kubeconfig
export KUBECONFIG=kubeconfig
- name: Deploy application
run: |
kubectl apply -f k8s/
kubectl rollout status deployment/myapp
Advanced Features
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
myregistry/myapp:latest
myregistry/myapp:${{ github.sha }}
GitLab CI/CD Integration
Basic Pipeline
# .gitlab-ci.yml
stages:
- build
- test
- deploy
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "/certs"
build:
stage: build
image: docker:20.10.16
services:
- docker:20.10.16-dind
script:
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
deploy:
stage: deploy
image: bitnami/kubectl:latest
script:
- kubectl set image deployment/myapp myapp=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- kubectl rollout status deployment/myapp
only:
- main
Jenkins Integration
Jenkinsfile Example
pipeline {
agent any
environment {
DOCKER_REGISTRY = 'myregistry.com'
IMAGE_NAME = 'myapp'
KUBECONFIG = credentials('kubeconfig')
}
stages {
stage('Build') {
steps {
script {
docker.build("${DOCKER_REGISTRY}/${IMAGE_NAME}:${BUILD_NUMBER}")
}
}
}
stage('Test') {
steps {
sh 'docker run --rm ${DOCKER_REGISTRY}/${IMAGE_NAME}:${BUILD_NUMBER} npm test'
}
}
stage('Deploy') {
steps {
sh '''
kubectl set image deployment/myapp myapp=${DOCKER_REGISTRY}/${IMAGE_NAME}:${BUILD_NUMBER}
kubectl rollout status deployment/myapp
'''
}
}
}
}
Tool-Specific Best Practices
GitHub Actions
- Use reusable workflows for common patterns.
- Implement proper secret management.
- Leverage matrix builds for multi-environment deployments.
GitLab CI/CD
- Use GitLab Container Registry for image storage.
- Implement review apps for feature branches.
- Leverage GitLab environments for deployment tracking.
Jenkins
- Use shared libraries for common functionality.
- Implement blue-green deployments with plugins.
- Use Jenkins agents for distributed builds.
Security Integration
Secret Management
# GitHub Actions
- name: Deploy with secrets
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
API_KEY: ${{ secrets.API_KEY }}
run: |
envsubst < deployment-template.yaml | kubectl apply -f -
Image Scanning
# GitLab CI/CD
container_scanning:
stage: test
image: docker:stable
services:
- docker:stable-dind
script:
- docker run --rm -v /var/run/docker.sock:/var/run/docker.sock
-v $PWD:/tmp/.cache/ aquasec/trivy image $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
Monitoring and Notifications
Slack Integration
# GitHub Actions
- name: Notify Slack
if: always()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
channel: '#deployments'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
Email Notifications
// Jenkins
post {
always {
emailext (
subject: "Build ${env.BUILD_NUMBER} - ${currentBuild.result}",
body: "Build details: ${env.BUILD_URL}",
to: "${env.CHANGE_AUTHOR_EMAIL}"
)
}
}
Troubleshooting Common Issues
Authentication Problems
- Verify service account permissions
- Check token expiration dates
- Validate kubeconfig format
Build Failures
- Check resource quotas and limits
- Verify image registry access
- Review build logs for specific errors
Deployment Issues
- Validate Kubernetes manifest syntax
- Check namespace and resource names
- Verify image pull policies