- Home
- >
- DevOps News
- >
- A GitOps Deployment with Flux on DigitalOcean Kubernetes – InApps
A GitOps Deployment with Flux on DigitalOcean Kubernetes – InApps is an article under the topic Devops Many of you are most interested in today !! Today, let’s InApps.net learn A GitOps Deployment with Flux on DigitalOcean Kubernetes – InApps in today’s post !
Key Summary
- Overview: The article by InApps Technology details the implementation of a GitOps deployment using Flux on DigitalOcean Kubernetes in 2022, highlighting its benefits for automated, scalable DevOps workflows. It emphasizes Vietnam’s role as a cost-effective hub for Kubernetes and GitOps expertise, leveraging its skilled workforce.
- What is GitOps with Flux on DigitalOcean Kubernetes?:
- Definition: GitOps is a DevOps practice that uses Git repositories as the single source of truth for declarative infrastructure and application deployments. Flux is a GitOps tool that automates Kubernetes cluster synchronization with Git. DigitalOcean Kubernetes (DOKS) is a managed Kubernetes service for scalable container orchestration.
- Purpose: Streamlines deployments, ensures consistency, and enhances reliability by automating Kubernetes cluster updates based on Git changes.
- Context: In 2022, GitOps gained traction for managing complex Kubernetes environments, with Flux and DigitalOcean providing accessible solutions for startups and enterprises.
- Key Points of GitOps Deployment with Flux on DigitalOcean Kubernetes:
- Setting Up DigitalOcean Kubernetes:
- Process: Create a DOKS cluster via DigitalOcean’s dashboard, configuring nodes (e.g., 3 nodes, 4GB RAM each) for scalability.
- Details: DOKS offers managed control planes and auto-upgrades, supporting 100+ pods per node. Setup takes 5–10 minutes with doctl CLI.
- Impact: Reduces infrastructure setup time by 30%, enabling rapid deployment.
- Example: A startup spins up a DOKS cluster in 8 minutes for a microservices app.
- Installing Flux on the Cluster:
- Process: Install Flux using its CLI (flux install) to sync Kubernetes with a Git repository.
- Details: Flux deploys Custom Resource Definitions (CRDs) and controllers, monitoring Git for manifests (e.g., YAML files). Supports GitHub, GitLab, or Bitbucket.
- Impact: Automates 90% of deployment tasks, minimizing manual errors.
- Example: A SaaS app’s Flux setup syncs 50 manifests in 2 minutes.
- Configuring GitOps Workflow:
- Process: Define Kubernetes resources (e.g., deployments, services) in a Git repo and configure Flux to watch for changes.
- Details: Use Kustomize or Helm for templating. Flux applies updates every 5 minutes or on commit, handling 1,000+ resources. Webhooks enable real-time sync.
- Impact: Ensures 100% consistency between Git and cluster state.
- Example: A retail app’s Git repo updates a deployment, applied in 3 minutes by Flux.
- Continuous Deployment with CI/CD Integration:
- Process: Integrate Flux with CI pipelines (e.g., GitHub Actions, Jenkins) to build, test, and push manifests to Git.
- Details: CI builds Docker images, updates manifests, and commits changes, triggering Flux to deploy. Supports 50+ deployments daily with zero downtime.
- Impact: Speeds up release cycles by 40%, enhancing agility.
- Example: A media app deploys 10 updates/day via GitHub Actions and Flux.
- Monitoring and Observability:
- Process: Use Prometheus and Grafana to monitor Flux and cluster health, tracking sync failures or resource usage.
- Details: Flux emits metrics for reconciliation status, with alerts via Slack or PagerDuty. DigitalOcean provides built-in monitoring for CPU/memory.
- Impact: Reduces incident response time by 25% with proactive alerts.
- Example: A fintech app detects a sync failure in 5 minutes, avoiding downtime.
- Security Best Practices:
- Process: Secure GitOps with encrypted secrets and access controls.
- Details: Use Sealed Secrets or SOPS for sensitive data. Implement RBAC for Git repos and DOKS clusters. Scan manifests with Trivy or Checkov.
- Impact: Cuts security risks by 30%, ensuring GDPR/SOC 2 compliance.
- Example: A healthcare app secures secrets with SOPS, passing compliance audits.
- Setting Up DigitalOcean Kubernetes:
- Benefits of GitOps with Flux on DigitalOcean Kubernetes:
- Automation: Flux eliminates manual deployments, saving 20 hours/week.
- Consistency: Git as the source of truth ensures predictable cluster states.
- Scalability: DOKS and Flux handle 1M+ requests/day for growing apps.
- Cost Efficiency: Offshore GitOps expertise in Vietnam ($20–$50/hour via InApps) saves 20–40% vs. U.S./EU ($80–$150/hour).
- Reliability: Reduces deployment failures by 25% with automated rollbacks.
- Challenges:
- Learning Curve: GitOps and Flux require Kubernetes expertise, delaying adoption by 10–15%.
- Initial Setup: Configuring Flux and CI/CD takes 1–2 days for complex apps.
- Security Overhead: Managing secrets and RBAC adds complexity.
- Monitoring Needs: Requires robust observability to catch sync issues.
- Security Considerations:
- Encryption: Use TLS for Git webhooks and AES-256 for secrets.
- Access Control: Implement MFA and RBAC for Git repos and DOKS.
- Compliance: Ensure GDPR/CCPA, or SOC 2 for sensitive data.
- Example: InApps secures a DOKS cluster with Sealed Secrets, meeting PCI-DSS standards.
- Use Cases:
- Startups: Rapid MVPs with automated deployments for e-commerce apps.
- SaaS: Scalable microservices with CI/CD pipelines.
- Fintech: Secure, reliable APIs for transactions on DOKS.
- Media: Low-latency streaming apps with auto-scaling clusters.
- Healthcare: Compliant health platforms with GitOps automation.
- InApps Technology’s Role:
- Leading HCMC-based provider with 488 experts in Kubernetes, DevOps, and GitOps.
- Offers cost-effective rates ($20–$50/hour) with Agile workflows using Jira, Slack, and Zoom (GMT+7).
- Specializes in GitOps deployments with Flux, DOKS, and tools like Prometheus, Helm, and Trivy.
- Example: InApps implements Flux on DOKS for a U.S. SaaS client, reducing deployment time by 35%.
- Recommendations:
- Adopt GitOps with Flux for automated, reliable Kubernetes deployments on DigitalOcean.
- Integrate with CI/CD pipelines and observability tools like Prometheus for agility and monitoring.
- Secure workflows with encrypted secrets and access controls.
- Partner with InApps Technology for cost-effective GitOps solutions, leveraging Vietnam’s talent pool.
Read more about A GitOps Deployment with Flux on DigitalOcean Kubernetes – InApps at Wikipedia
You can find content about A GitOps Deployment with Flux on DigitalOcean Kubernetes – InApps from the Wikipedia website
GitOps is gaining momentum as the preferred mechanism for continuous deployment. Based on the demo that I showed during the DigitalOcean Deploy Conference in November 2021, I am bringing you the step-by-step GitOps tutorial to perform deployments at scale.
We will manage the deployment of a simple web application across three different DigitalOcean Kubernetes clusters running in Bangalore, Singapore, and London regions. The Weaveworks-managed open source Flux, the most popular CD tool will be used to bootstrap GitOps, configure Ingress infrastructure, and finally deploy the application.
We will follow some of the best practices of GitOps for this tutorial such as leveraging git as the single source of truth, using git workflow to deploy infrastructure and applications.
Except for the bootstrapping, we will always use the git
command and not rely on the CLIs (fluxctl
and kubectl
) for the configuration. We will incrementally add an ingress component (infrastructure) packaged as a Helm Chart and a web application (apps) declared in a set of YAML files to the repo, which will be eventually reconciled across all the clusters.
Whether it is one cluster or tens of thousands of clusters, the workflow remains the same. The objective of this tutorial is to show at-scale deployment targeting multiple Kubernetes clusters.
Prerequisites
Step 1: Preparing the Environment
Let’s begin by launching the Kubernetes clusters with doctl
CLI. By the end of this step, we should have three clusters running in three different regions of the Digital Ocean cloud platform. Once the clusters are provisioned, we will download kubeconfig
and rename the context.
Next, create a GitHub repository that will be used for storing the artifacts. Let’s call this do-gitops-demo
.
Assuming you have created a GitHub personal access token, set the environment variable for Flux to access the repository.
export GITHUB_TOKEN=YOUR_GITHUB_PERSONAL_ACCESS_TOKEN
Step 2: Bootstrapping Clusters for GitOps
Let’s make sure that the cluster is ready for Flux. We will do this by running the command, flux check
.
Let’s bootstrap the clusters by pointing them to the GitHub repository created in the previous step.
This results in two things — Flux adding the manifests to the fleet
directory of the repo and reconciling the cluster with the manifests.
The directory structure looks like this:
+— fleet │ +— blr1 │ │ +— flux–system │ │ │ +— gotk–components.yaml │ │ │ +— gotk–sync.yaml │ │ │ — kustomization.yaml │ +— lon1 │ │ +— flux–system │ │ │ +— gotk–components.yaml │ │ │ +— gotk–sync.yaml │ │ │ — kustomization.yaml │ — sgp1 │ +— flux–system │ │ +— gotk–components.yaml │ │ +— gotk–sync.yaml │ │ — kustomization.yaml |
You can verify the flux-system
namespace on each cluster. This confirms successful bootstrap.
We are now ready to configure the infrastructure components (Ingress) and deploy them through the same workflow.
Step 3: Deploying Ingress through GitOps
With the Flux GitOps agent running in all the clusters, we can leverage it to push newer deployments by committing the artifacts to the Git repository.
In this step, let’s create a namespace ingress-system
and install the NGINX ingress Helm Chart. Let’s leverage the helmrepositories
and helmreleases
CRDs added by Flux.
Start by cloning the Git repository to your local workstation.
git clone https://github.com/$OWNER/do-gitops-demo.git
.
At this point, this repo contains the YAML artifiacts responsible for deploying Flux operator. We will add a new directory, infrastructure
and commit the YAML files with Helm Chart for NGNIX-based ingress.
cd do-gitops-demo
mkdir infrastructure
Let’s add the YAML files to the directory.
These three files roughly translate to the same sequence of commands run to install NGINX ingress:
kubectl create ns ingress-system
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install --namespace ingress-system
nginx-ingress ingress-nginx/ingress-nginx
Finally, we need to add a Kustomization to the cluster directory under fleet
which will act as a pointer to the infrastructure components. Since the directory, fleet
is registered with the Flux agent during the bootstrapping, that’s the best location to add the below YAML file.
For example, to target the Bangalore cluster, copy the below file to fleet/blr1
directory. This approach gives us a chance to customize the artifact per cluster at a later stage.
Add the file to all the clusters to ensure that they deploy the ingress.
Notice the addition of infrastructure.yaml
in each cluster-specific directory and the infrastructure
directory with the YAML artifacts.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
+— fleet │ +— blr1 │ │ +— flux–system │ │ │ +— gotk–components.yaml │ │ │ +— gotk–sync.yaml │ │ │ — kustomization.yaml │ │ — infrastructure.yaml │ +— lon1 │ │ +— flux–system │ │ │ +— gotk–components.yaml │ │ │ +— gotk–sync.yaml │ │ │ — kustomization.yaml │ │ — infrastructure.yaml │ — sgp1 │ +— flux–system │ │ +— gotk–components.yaml │ │ +— gotk–sync.yaml │ │ — kustomization.yaml │ — infrastructure.yaml — infrastructure +— ingress–helm–release.yaml +— ingress–helm–repo.yaml — ingress–ns.yaml |
It’s time to commit the new artifacts and push them to the remote GitHub repository.
git add .
git commit -m "Added infrastructure components"
git push
The moment the changes are committed, Flux agent starts the reconciliation process. In a few minutes, you should see all the clusters create the ingress-system
namespace.
Since the creation of an ingress results in provisioning a load balancer, the Digital Ocean cloud console shows that there are three load balancers created per cluster.
This step demonstrated how to deploy a Helm chart through the GitOps workflow. Let’s move to the next step where we will deploy the web application that leverages the ingress created in this step.
Step 4: Deploying a Web App through GitOps
For the web application, let’s follow the same steps of adding the manifests to the apps
directory and then adding a Kustomization file to the fleet
directory.
cd do-gitops-demo
mkdir apps
Inside the apps
directory, create the below YAML files:
Finally, add the below Kustomization file to all the clusters under the fleet
directory.
With the addition of apps
, notice how the directory structure has changed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
+— apps │ +— ns.yaml │ +— web–ingress.yaml │ +— web–service.yaml │ — web.yaml +— fleet │ +— blr1 │ │ +— apps.yaml │ │ +— flux–system │ │ │ +— gotk–components.yaml │ │ │ +— gotk–sync.yaml │ │ │ — kustomization.yaml │ │ — infrastructure.yaml │ +— lon1 │ │ +— apps.yaml │ │ +— flux–system │ │ │ +— gotk–components.yaml │ │ │ +— gotk–sync.yaml │ │ │ — kustomization.yaml │ │ — infrastructure.yaml │ — sgp1 │ +— apps.yaml │ +— flux–system │ │ +— gotk–components.yaml │ │ +— gotk–sync.yaml │ │ — kustomization.yaml │ — infrastructure.yaml — infrastructure +— ingress–helm–release.yaml +— ingress–helm–repo.yaml — ingress–ns.yaml |
git add .
git commit -m "Added web application"
git push
In a few minutes, you will see the mywebapp
namespace with the web application.
Access it by visiting the load balancer IP address to see the below web page:
Edit the do-gitops-demo/apps/web.yaml
to update the image tag from v1 to v2.
Commit the code and push it to the remote GitHub repository. Access the load balancer IP again to see the V2 version of the web application.
If you revert the last commit, you can roll back the deployment to V1. This is the beauty of using GitOps.
This completes the step-by-step guide to using FluxCD with DigitalOcean Kubernetes. In the upcoming tutorials, we will explore how to use Kustomization to customize the deployment per each cluster. Stay tuned.
Source: InApps.net
Let’s create the next big thing together!
Coming together is a beginning. Keeping together is progress. Working together is success.