Architecture Overview
The flow works like this:- You push code to your GitLab application repository
- GitLab CI builds and pushes a container image to your registry
- GitLab CI updates the GitOps repo with the new image tag
- Ankra detects the change and triggers a deployment
- Ankra Agent deploys the updated manifest to your cluster
What You’ll Build
A complete CI/CD pipeline with:Prerequisites
- A cluster imported into Ankra with the agent connected
- A container registry (GitLab Container Registry, Google Artifact Registry, AWS ECR, Docker Hub, etc.)
- An application repository on GitLab with a Dockerfile
Step 1: Connect a GitLab Repository
First, connect a GitLab repository to your cluster. This enables GitOps and installs the necessary components on your cluster.Navigate to Integration Settings
Add a GitLab Credential
- Go to Credentials and create a new Git credential
- Select GitLab as the provider
- Provide your GitLab URL and a Personal Access Token with
apiandread_repositoryscopes
Select a Repository
Confirm Installation
- ArgoCD - GitOps continuous delivery
- Ankra Stack Builder - Declarative infrastructure management
- Ankra Resource Engine - Intelligent resource orchestration
- GitOps Monitoring - Continuous deployment from your repository
Step 2: Create a Stack for Your Application
In Ankra, manifests are organized into Stacks. A Stack is a collection of related Kubernetes resources that are deployed together.Open the Stacks Page
Create a New Stack
Name Your Stack
backend-services or production-apps.Add a Manifest Using AI
⌘+J (or Ctrl+J) to open the AI Assistant and describe your deployment:Create the Stack
Step 3: Set Up CI Deploy Key
Your GitLab CI pipeline needs write access to the GitOps repository to update image tags when new builds complete.Generate an SSH Key
deploy_key (private) and deploy_key.pub (public).Add Public Key to GitOps Repo
deploy_key.pub and check Grant write permissions to this key.Add Private Key to App Repo
- Key:
GITOPS_DEPLOY_KEY - Value: Contents of
deploy_key - Type: File
- Flags: Check Mask variable and Protect variable
Step 4: Create the GitLab CI Pipeline
Add a.gitlab-ci.yml file to your application repository that builds your container and updates the GitOps repo.
Create the Pipeline File
.gitlab-ci.yml at the root.Use the AI to Generate the Pipeline
⌘+J) and describe your pipeline:Add Registry Variables
Example Pipeline: GitLab Container Registry
Example Pipeline: GitLab Container Registry
Example Pipeline: Google Artifact Registry
Example Pipeline: Google Artifact Registry
Step 5: Configure Registry Access in Your Cluster
If your container registry is private, your cluster needs credentials to pull images.Open the AI Assistant
⌘+J to open the AI Assistant.Ask for an Image Pull Secret
Add the Secret Value
- For GitLab: Use a Deploy Token with
read_registryscope - For GCP: Use a service account JSON key with
Artifact Registry Readerrole - For AWS ECR: Use an IAM access key
Link to Your Deployment
Step 6: Test the Pipeline
Push a Code Change
Monitor CI Progress
Verify GitOps Update
Watch the Deployment
Step 7: Monitor GitOps Sync Status
Ankra provides visibility into your GitOps sync status.View GitOps Status
- Current sync status
- Recent sync history
- Any sync errors
Trigger Manual Sync
View in Operations
Adding More Services
To add CI/CD for additional services, use the AI Assistant to scaffold everything:Add to Existing Stack or Create New
Generate the Deployment Manifest
⌘+J) and describe your service:Generate the CI Pipeline
.gitlab-ci.yml or ask the AI:Add the Variables
GITOPS_DEPLOY_KEY, registry credentials) to the new project.Common AI Prompts
Use these prompts with the AI Assistant (⌘+J) to set up your CI/CD:
Create a Deployment
Create a Deployment
Create a Complete Service Stack
Create a Complete Service Stack
Add Image Pull Secret
Add Image Pull Secret
Generate GitLab CI Pipeline
Generate GitLab CI Pipeline
Troubleshoot Deployment
Troubleshoot Deployment
Best Practices
Use GitLab Deploy Tokens for Pull Access
Use GitLab Deploy Tokens for Pull Access
read_registry scope for image pull secrets. They’re scoped to a project and easy to rotate.Add Health Checks
Add Health Checks
Set Resource Limits
Set Resource Limits
Use SOPS for Secrets
Use SOPS for Secrets
Protect CI/CD Variables
Protect CI/CD Variables
Troubleshooting
Having issues? Open the AI Assistant (⌘+J) and describe your problem:
CI Can't Push to GitOps Repo
CI Can't Push to GitOps Repo
- Deploy key doesn’t have write permissions on the GitOps repo
GITOPS_DEPLOY_KEYvariable is not set as File typessh-keyscanis missing for the GitLab host
Image Not Updating
Image Not Updating
Pods Can't Pull Image
Pods Can't Pull Image
read_registry scope.Pipeline Fails on Docker Build
Pipeline Fails on Docker Build
- Use
docker:27as the job image - Add
docker:27-dindas a service - If using Kubernetes executors, ensure privileged mode is enabled or use Kaniko instead
GitOps Sync Not Triggering
GitOps Sync Not Triggering
- Verify the GitLab repository is still connected in Settings → Integration
- Check that your commit was pushed to the correct branch
- Look for webhook configuration issues in the GitOps status