A practical example demonstrating how to implement a GitOps workflow using Tyk Operator, ArgoCD, and Kustomize to manage API deployments across multiple Kubernetes environments.
In this repo, we walk through setting up a GitOps workflow that automates the deployment of both applications and API configurations using Tyk Operator, ArgoCD, and Kustomize. By following the guide, you'll learn how to manage deployments efficiently in an organization using GitOps principles.
The repository is organized into three main directories:
tyk-operator-demo/
├── apps/
│ └── httpbin/
│ ├── base/
│ └── overlays/
│ ├── prod/
│ └── staging/
├── policies/
│ ├── prod/
│ └── staging/
└── argocd/
├── prod/
└── staging/
Contains Kubernetes manifests for deploying applications. In this example, we're focusing on the httpbin
application.
apps/httpbin/base/
: Base configuration common to all environments.apps/httpbin/overlays/prod/
: Production-specific customizations.apps/httpbin/overlays/staging/
: Staging-specific customizations.
Stores security policy manifests, governing security options and access rights.
policies/prod/
: Security policies for the production environment.policies/staging/
: Security policies for the staging environment.
Contains ArgoCD application manifests that automate the deployment process.
argocd/prod/
: ArgoCD applications for the production environment.argocd/staging/
: ArgoCD applications for the staging environment.
- Familiarity with Kubernetes and Kustomize.
- Basic understanding of Git.
- Access to two Kubernetes clusters (e.g., using Minikube).
-
Fork and Clone the Repository
Fork this repository to your own GitHub account and then clone it locally:
git clone https://github.com/your-username/tyk-operator-demo.git cd tyk-operator-demo
-
Set Up the Environment
Follow the instructions in the blog post to set up your staging and production environments using Minikube, Tyk Stack, and ArgoCD.
-
Update ArgoCD Applications
Modify the
repoURL
in the ArgoCD application manifests under theargocd/
directory to point to your forked repository.For example, in
argocd/staging/httpbin.yaml
:spec: source: repoURL: 'https://github.com/your-username/tyk-operator-demo'
-
Deploy with ArgoCD
Apply the ArgoCD application manifests to your clusters to deploy the applications and policies.
For Staging:
kubectl config use-context staging kubectl apply -f argocd/staging-apps.yaml
For Production:
kubectl config use-context production kubectl apply -f argocd/prod-apps.yaml
-
Experiment with Changes
Modify the
ApiDefinition
orSecurityPolicy
manifests in theapps/
orpolicies/
directories, then commit and push the changes to your repository.git add . git commit -m "Your commit message" git push origin main
ArgoCD will automatically detect and synchronize the changes from Git to Kubernetes. Tyk Operator automatically detect changes of the custom resources and update the live configurations in Tyk accordingly.
By following this guide and using this repository, you've:
- Set up a comprehensive GitOps workflow.
- Automated deployment of applications and API configurations across multiple environments.
- Utilized Tyk Operator to manage API definitions and security policies as Kubernetes resources.
- Employed ArgoCD for continuous deployment and observed live updates.
- Leveraged Kustomize for environment-specific configurations without duplicating code.
- Gained insights into organizing repositories for scalability and maintainability.
This setup enables efficient management of deployments in an organization, ensuring consistency, reducing manual errors, and accelerating the development workflow.
Contributions are welcome! Please open an issue or submit a pull request if you have suggestions for improvements.
Mozilla Public License Version 2.0
For questions on products, please use Tyk Community forum.
Clients can also use [email protected].
Prospects and evaluators, please use [email protected].