|
| 1 | +# Enable GitOps Deployments with FluxCD |
| 2 | + |
| 3 | +{% hint style="info" %} |
| 4 | +### Prerequisite |
| 5 | + |
| 6 | +Make sure to install: |
| 7 | + |
| 8 | +1. [Build and Deploy (CI/CD) integration](../integrations/build-and-deploy-ci-cd.md) |
| 9 | + |
| 10 | +2. [GitOps (ArgoCD) integration](../integrations/argocd.md) |
| 11 | + |
| 12 | +{% endhint %} |
| 13 | + |
| 14 | +Devtron supports FluxCD to enable GitOps-based deployments. With FluxCD, you can: |
| 15 | + |
| 16 | +* Deploy applications via GitOps (via FluxCD). |
| 17 | + |
| 18 | +* Deploy Helm charts via FluxCD. |
| 19 | + |
| 20 | +* Migrate existing FluxCD applications into Devtron. |
| 21 | + |
| 22 | +Your Git repository becomes the single source of truth for your Kubernetes workloads. Any changes you make in Git are automatically applied to your Kubernetes cluster by FluxCD. Refer to the [FluxCD documentation](https://fluxcd.io/flux/) to learn more. |
| 23 | + |
| 24 | + |
| 25 | +## Installation |
| 26 | + |
| 27 | +{% hint style="warning" %} |
| 28 | +### Who Can Perform This Action? |
| 29 | +The user must have permissions to: |
| 30 | + * Edit the ConfigMaps of 'default-cluster' |
| 31 | + * Restart the pods |
| 32 | +{% endhint %} |
| 33 | + |
| 34 | +To enable deployments through GitOps via FluxCD, you need to enable a specific feature flag for the `default_cluster` in Devtron. |
| 35 | + |
| 36 | + |Feature|Flag|Description| |
| 37 | + |:---|:---|:---| |
| 38 | + |**Deployments via FluxCD**|`FEATURE_FLUX_DEPLOYMENTS_ENABLE: "true"`|This flag will enable deployments through GitOps via FluxCD.<ul><li> After enabling this flag, you also need to install FluxCD controller in order to deploy applications successfully. Refer [Installing FluxCD Controller](#installing-fluxcd-controller-only-for-deployments) to know more.</li></ul>| |
| 39 | + |**Migrating existing FluxCD applications**|`FEATURE_LINK_EXTERNAL_FLUX_ENABLE: "true"`|This flag will enable migrations for external FluxCD apps into Devtron.| |
| 40 | + |
| 41 | + {% hint style="warning" %} |
| 42 | + ### Deployment Strategies for FluxCD Deployments |
| 43 | + |
| 44 | + Application deployments through GitOps (via FluxCD) are supported only when using the `Deployment` or `Rollout` deployment strategies with the latest chart versions. Other deployment strategies are currently not supported. |
| 45 | + {% endhint %} |
| 46 | + |
| 47 | +### Enabling Feature Flags |
| 48 | + |
| 49 | +1. Navigate to Devtron's **Resource Browser**. |
| 50 | + |
| 51 | +  |
| 52 | + |
| 53 | +2. Select the `default_cluster` to enable the feature flags. |
| 54 | + |
| 55 | +  |
| 56 | + |
| 57 | +3. Go to Config & Storage → ConfigMap, and click `dashboard-cm` ConfigMap |
| 58 | + |
| 59 | +  |
| 60 | + |
| 61 | +4. Edit the `dashboard-cm` ConfigMap by clicking **Edit live manifest**. |
| 62 | + |
| 63 | +  |
| 64 | + 1. To enable deployments via FluxCD, check if the below entries are present in the ConfigMap (create one if it doesn't exist) and select **Apply changes**.<br> |
| 65 | + |
| 66 | + ```yaml |
| 67 | + FEATURE_FLUX_DEPLOYMENTS_ENABLE: "true" |
| 68 | + ``` |
| 69 | + |
| 70 | + 2. To enable migration for external FluxCD applications, check if the below entries are present in the ConfigMap (create one if it doesn't exist) and select **Apply changes**.<br> |
| 71 | + |
| 72 | + ```yaml |
| 73 | + FEATURE_LINK_EXTERNAL_FLUX_ENABLE: "true" |
| 74 | + ``` |
| 75 | + |
| 76 | + <br> |
| 77 | +
|
| 78 | +  |
| 79 | +
|
| 80 | +5. Restart the deployment: |
| 81 | + 1. **For OSS Users:** |
| 82 | + 1. Navigate to Devtron's Resource Browser. |
| 83 | +
|
| 84 | + 2. Select the cluster for which you have enabled the feature flags. |
| 85 | +
|
| 86 | + 3. Click the **Terminal** tab. |
| 87 | + |
| 88 | + 4. Restart the deployment using the following command: |
| 89 | +
|
| 90 | + ```yaml |
| 91 | + kubectl rollout restart deployment dashboard -n devtroncd |
| 92 | + ``` |
| 93 | + |
| 94 | +  |
| 95 | + 2. **For Enterprise Users:** |
| 96 | + 1. Go to **Resource Browser** → (select the cluster in which you have enabled the feature flags) → **Workloads** → **Deployment** |
| 97 | + |
| 98 | + 2. Click the checkbox next to the `dashboard` Deployment workloads and restart them using the `⟳` button. |
| 99 | + |
| 100 | +  |
| 101 | + |
| 102 | +6. Perform a hard refresh of the browser to clear the cache: |
| 103 | + |
| 104 | + * **Mac**: Hold down Cmd and Shift and then press R. |
| 105 | + |
| 106 | + * **Windows/Linux**: Hold down Ctrl and then press F5. |
| 107 | + |
| 108 | +### Installing FluxCD Controller (Only for Deployments) |
| 109 | + |
| 110 | +After enabling the feature flag for deployments, the next step is to install FluxCD Controller in every cluster (including the default cluster) in which you want to deploy the FluxCD applications. |
| 111 | + |
| 112 | +You can install FluxCD Controller by any of the following ways: |
| 113 | + |
| 114 | + 1. [Install FluxCD controller via Cluster Terminal](#install-fluxcd-controller-via-cluster-terminal) (Recommended) |
| 115 | + |
| 116 | + 2. [Install FluxCD controller via Chart Store](#install-fluxcd-controller-via-chart-store) |
| 117 | + |
| 118 | + |
| 119 | +#### Install FluxCD controller via Cluster Terminal. |
| 120 | + |
| 121 | +1. Navigate to Devtron's Resource Browser. |
| 122 | + |
| 123 | +2. Select the cluster for which you have enabled the feature flags. |
| 124 | + |
| 125 | +3. Click the **Terminal** tab. |
| 126 | + |
| 127 | +4. Run the following command to install the FluxCD Controller: |
| 128 | + |
| 129 | + ```yaml |
| 130 | + kubectl apply -f https://github.com/fluxcd/flux2/releases/download/v0.35.0/install.yaml |
| 131 | + ``` |
| 132 | + |
| 133 | +  |
| 134 | + |
| 135 | +5. After the command is executed successfully, you can deploy or migrate your applications in that cluster through GitOps (via FluxCD). |
| 136 | + |
| 137 | +#### Install FluxCD controller via Chart Store. |
| 138 | + |
| 139 | +To install FluxCD controller via Chart Store, follow the below steps. |
| 140 | + |
| 141 | + 1. Add FluxCD controller repository, `https://fluxcd-community.github.io/helm-charts` in the chart repositories (if not already added) in Global Configurations. Refer [Chart Repositories](../global-configurations/chart-repo.md#add-chart-repository) to learn more. |
| 142 | + |
| 143 | +  |
| 144 | + |
| 145 | + 2. Add a new environment in the cluster in which you want to deploy the application via FluxCD linked to namespace as `flux-system`. Refer [Clusters and Environments](../global-configurations/cluster-and-environments.md#add-environment-to-a-cluster) to lean more. |
| 146 | + |
| 147 | +  |
| 148 | + |
| 149 | + 3. Navigate to **Chart Store** and select the `flux2` chart. |
| 150 | + |
| 151 | +  |
| 152 | + |
| 153 | + 4. Click **Configure and Deploy**. |
| 154 | + |
| 155 | +  |
| 156 | + |
| 157 | + 5. Configure the following configurations: |
| 158 | + |
| 159 | + |Field Name|Description| |
| 160 | + |:---|:---| |
| 161 | + |**App Name**|Define a name for the chart.| |
| 162 | + |**Project**|Select a project from the dropdown| |
| 163 | + |**Deploy to Environment**|Select the environment which you have created in your preferred cluster linked to `flux-system` namespace.| |
| 164 | + |
| 165 | +  |
| 166 | + |
| 167 | + 6. Click **Deploy** and the chart will be deployed. |
| 168 | + |
| 169 | +After the chart is successfully deployed, you can deploy applications though GitOps (via FluxCD). |
0 commit comments