This guide assumes you already have a cluster configured with GitOps. If you need to set up GitOps first, see the GitOps File Reference.
Prerequisites
- An existing cluster with GitOps configuration
- Access to the source Git repository
- GitHub credentials configured in Ankra
- Permission to create new repositories or fork existing ones
Steps to Clone a Cluster
1. Identify the Source Repository
Locate the Git repository containing the cluster you want to clone:- Find the main GitOps YAML file (e.g.,
import-cluster.yaml) - Note any referenced manifests, add-ons, or include directories
- Check the repository structure and dependencies
2. Fork or Copy the Repository
Create a new repository for your cloned cluster: Option A: Fork the Repository3. Update Cluster Metadata
Edit the main GitOps YAML file to update cluster-specific information:4. Update GitOps Settings
Modify repository and credential settings:- Repository URL: Update to point to your new repository
- Credentials: Ensure
credential_namematches your Ankra setup - Branch: Change if using a different branch strategy
- Provider: Update if switching Git providers
5. Customize for Environment
Adapt the configuration for your target environment: For Single YAML Definition:6. Environment-Specific Customizations
Make necessary adjustments for different environments:- Resource Limits: Adjust CPU/memory for staging vs production
- Replicas: Scale down for non-production environments
- Secrets: Update secret references for environment-specific values
- Ingress: Change domain names or routing rules
- Storage: Modify storage classes or sizes
7. Commit and Push Changes
Save your changes to the new repository:8. Import the Cloned Cluster in Ankra
Deploy your cloned cluster through Ankra:- Navigate to Clusters in the Ankra dashboard
- Click Import Cluster
- Select GitOps import method
- Enter your new repository details:
- Repository URL:
https://github.com/YOUR_USERNAME/new-cluster-repo - Branch:
main - Credential: Select your configured GitHub credential
- Repository URL:
- Point to your main GitOps YAML file
- Review the configuration preview
- Click Import to deploy
9. Verify the Deployment
After import, monitor the cluster deployment:- Check the Operations tab for deployment status
- Verify all manifests and add-ons are applied correctly
- Test connectivity and functionality
- Validate environment-specific configurations
Best Practices
Organization Strategy
- Use Branches: Consider using different branches for different environments
- Environment Folders: Organize configurations in environment-specific directories
- Naming Conventions: Use clear naming patterns (e.g.,
app-staging,app-prod)
Configuration Management
- Environment Variables: Use ConfigMaps and Secrets for environment-specific values
- Helm Values: Leverage Helm’s values system for parameterization
- Kustomize: Consider using Kustomize for environment overlays
Version Control
- Tag Releases: Tag stable configurations before cloning
- Document Changes: Maintain clear commit messages and documentation
- Branch Protection: Use branch protection rules for production configurations
Testing Strategy
- Validation: Test cloned configurations in development first
- Rollback Plan: Ensure you can revert changes if needed
- Monitoring: Set up monitoring for the cloned environment
Common Patterns
Multi-Environment Repository
Structure your repository to support multiple environments:Shared Components
Use include paths to share common components:Troubleshooting
Common Issues
Repository Access: Ensure your GitHub credentials have access to the new repository. Missing Files: Verify all referenced files and directories are copied to the new repository. Namespace Conflicts: Update namespace names to avoid conflicts with existing clusters. Resource Conflicts: Check for naming conflicts with existing resources.Validation
Before importing, validate your GitOps file:Next Steps: Once your cluster is cloned and deployed, consider setting up monitoring and observability to track the health of your new environment.