Skip to content

Commit

Permalink
docs: Sync from a Git Repository using GitHub App auth
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <[email protected]>
  • Loading branch information
stefanprodan committed Feb 21, 2025
1 parent 2d10024 commit 2709b46
Showing 1 changed file with 49 additions and 3 deletions.
52 changes: 49 additions & 3 deletions docs/operator/flux-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
registry: "ghcr.io/fluxcd"
sync:
kind: GitRepository
url: "https://github.com/my-org/my-fleet.git"
url: "https://gitlab.com/my-org/my-fleet.git"
ref: "refs/heads/main"
path: "clusters/my-cluster"
pullSecret: "flux-system"
Expand All @@ -36,11 +36,57 @@ and should contain the credentials to clone the repository:

```shell
flux create secret git flux-system \
--url=https://github.com/my-org/my-fleet.git \
--url=https://gitlab.com/my-org/my-fleet.git \
--username=git \
--password=$GITHUB_TOKEN
--password=$GITLAB_TOKEN
```

## Sync from a Git Repository using GitHub App auth

To sync the cluster state from a GitHub repository using GitHub App authentication:

```yaml
apiVersion: fluxcd.controlplane.io/v1
kind: FluxInstance
metadata:
name: flux
namespace: flux-system
spec:
distribution:
version: "2.x"
registry: "ghcr.io/fluxcd"
sync:
kind: GitRepository
url: "https://github.com/my-org/my-fleet.git"
ref: "refs/heads/main"
path: "clusters/my-cluster"
pullSecret: "flux-system"
kustomize:
patches:
- patch: |
- op: add
path: /spec/provider
value: github
target:
kind: GitRepository
```

The Kubernetes secret must be created in the `flux-system` namespace
and should contain the GitHub App private key:

```shell
flux create secret githubapp flux-system \
--app-id=1 \
--app-installation-id=2 \
--app-private-key=./path/to/private-key-file.pem
```

!!! tip "GitHub App Support"

Note that GitHub App support was added in Flux v2.5.0 and Flux Operator v0.15.0.
For more information on how to create a GitHub App see the
Flux [GitRepository API reference](https://fluxcd.io/flux/components/source/gitrepositories/#github).

## Sync from a Container Registry

To sync the cluster state from a container registry where the Kubernetes manifests
Expand Down

0 comments on commit 2709b46

Please sign in to comment.