Skip to content

Commit

Permalink
Add boostrap migration guide
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
  • Loading branch information
stefanprodan committed Jun 11, 2024
1 parent 3c02330 commit 3240517
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
90 changes: 90 additions & 0 deletions docs/operator/flux-bootstrap-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Flux Bootstrap Migration

Assuming you have a cluster bootstrapped with the Flux CLI or the Terraform Provider,
you can migrate to an operator-managed Flux with zero downtime.

## Install the Flux Operator

Install the Flux Operator in the same namespace where Flux is deployed, for example using Helm:

```shell
helm install flux-operator oci://ghcr.io/controlplaneio-fluxcd/charts/flux-operator \
--namespace flux-system
```

Or by using an alternative installation method described in the [installation guide](install.md).

## Create a Flux Instance

Create a `FluxInstance` resource named **flux** in the `flux-system` namespace using
the same configuration as for `flux bootstrap`.

For example, if you have bootstrapped the cluster with the following command:

```shell
flux bootstrap github \
--owner=my-org \
--repository=my-fleet \
--branch=main \
--path=clusters/my-cluster
```

The equivalent `FluxInstance` configuration would look like this:

```yaml
apiVersion: fluxcd.controlplane.io/v1
kind: FluxInstance
metadata:
name: flux
namespace: flux-system
spec:
distribution:
version: "2.x"
registry: "ghcr.io/fluxcd"
components:
- source-controller
- kustomize-controller
- helm-controller
- notification-controller
cluster:
type: kubernetes
multitenant: false
networkPolicy: true
domain: "cluster.local"
sync:
kind: GitRepository
url: "ssh://git@github.com/my-org/my-fleet.git"
ref: "refs/heads/main"
path: "clusters/my-cluster"
pullSecret: "flux-system"
```
Apply the `FluxInstance` resource to the cluster:

```shell
kubectl apply -f flux-instance.yaml
```

Once the resource is reconciled, the operator will take over the management of the Flux components,
the Flux GitRepository and Kustomization.

To verify that the migration was successful, check the status of the `FluxInstance`:

```shell
kubectl -n flux-system get fluxinstance flux
```

Running the trace command should result in a "Not managed by Flux" message:

```shell
flux trace kustomization flux-system
```

## Cleanup the repository

To finalize the migration, remove the Flux manifests from the Git repository:

1. Checkout the main branch of the Flux repository that was used to bootstrap the cluster.
2. Delete the `flux-system` directory from the repository `clusters/my-cluster` directory.
3. Optionally, place the `FluxInstance` YAML manifest in the `clusters/my-cluster` directory.
4. Commit and push the changes to the Flux repository.
2 changes: 1 addition & 1 deletion docs/operator/flux-sync.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Flux Sync Configuration
# Flux Cluster Sync Configuration

The `FluxInstance` resource can be configured to instruct the operator to generate
a Flux source (`GitRepository`, `OCIRepository` or `Bucket`) and a Flux `Kustomization`
Expand Down
3 changes: 2 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ nav:
- Installation: operator/install.md
- Configuration:
- Flux Controllers: operator/flux-config.md
- Flux Sync: operator/flux-sync.md
- Flux Cluster Sync: operator/flux-sync.md
- Flux Bootstrap Migration: operator/flux-bootstrap-migration.md
- API Reference:
- FluxInstance CRD: operator/fluxinstance.md
- Pricing: pricing/index.md
Expand Down

0 comments on commit 3240517

Please sign in to comment.