@@ -4,39 +4,77 @@ linkTitle: Generic Git server
44description : " How to bootstrap Flux with a generic Git server"
55weight : 20
66---
7- ### Generic Git Server
87
9- The ` bootstrap git ` command takes an existing Git repository, clones it and
10- commits the Flux components manifests to the specified branch. Then it
11- configures the target cluster to synchronize with that repository.
8+ The [ flux bootstrap git] ( /flux/cmd/flux_bootstrap_git/ ) command deploys the Flux controllers
9+ on a Kubernetes cluster and configures the controllers to sync the cluster state from a Git repository.
10+ Besides installing the controllers, the bootstrap command pushes the Flux manifests to the Git repository
11+ and configures Flux to update itself from Git.
1212
13- {{% alert color="warning" %}}
14- :warning : Note that if set, your SSH hostname and port could be overwritten by your [ ssh_config] ( https://linux.die.net/man/5/ssh_config ) .
13+ After running the bootstrap command, any operation on the cluster (including Flux upgrades)
14+ can be done via Git push, without the need to connect to the Kubernetes cluster.
15+
16+ {{% alert color="danger" title="Required permissions" %}}
17+ To bootstrap Flux, the person running the command must have ** cluster admin rights** for the target Kubernetes cluster.
18+ It is also required that the person running the command to have ** push rights** to the Git repository.
1519{{% /alert %}}
1620
17- Run bootstrap for a Git repository and authenticate with your SSH agent:
21+ ## SSH Private Key
22+
23+ Run bootstrap for an exiting Git repository and authenticate with a SSH key which has pull and push access:
1824
1925``` sh
2026flux bootstrap git \
2127 --url=ssh://git@< host> /< org> /< repository> \
22- --branch=< my-branch> \
28+ --branch=main \
29+ --private-key-file=< path/to/private.key> \
30+ --password=< key-passphrase> \
2331 --path=clusters/my-cluster
2432```
2533
26- The above command will generate an SSH key (defaults to ECDSA P-384 but can be changed with ` --ssh-key-algorithm ` and
27- ` --ssh-ecdsa-curve ` ), and it will prompt you to add the SSH public key as a deploy key to your repository .
34+ The private key is stored in the cluster as a Kubernetes secret named ` flux-system `
35+ inside the ` flux-system ` namespace .
2836
29- If you want to use your own SSH key, you can provide a private key using
30- ` --private-key-file=<path/to/private.key> ` (you can supply the passphrase with ` --password=< key-passphrase> ` ).
31- This option can also be used if no SSH agent is available on your machine.
37+ {{% alert color="info" title=" SSH Key rotation" %}}
38+ To regenerate the SSH private key and known hosts keys,
39+ delete the ` flux-system ` secret from the cluster and run:
3240
33- {{% alert color="info" title="Bootstrap options" %}}
34- There are many options available when bootstrapping Flux, such as installing a subset of Flux components,
35- setting the Kubernetes context, changing the Git author name and email, enabling Git submodules, and more.
36- To list all the available options run ` flux bootstrap git --help ` .
41+ ``` shell
42+ flux create secret git flux-system \
43+ --url=ssh://git@< host> /< org> /< repository> \
44+ --ssh-key-algorithm=rsa \
45+ --ssh-rsa-bits=4096
46+ ```
47+
48+ The CLI will prompt you to add the SSH public key as a deploy key to your repository.
3749{{% /alert %}}
3850
39- If your Git server doesn't support SSH, you can run bootstrap for Git over HTTPS:
51+ ## SSH Agent
52+
53+ Run bootstrap for an exiting Git repository and authenticate with your SSH agent:
54+
55+ ``` sh
56+ flux bootstrap git \
57+ --url=ssh://git@< host> /< org> /< repository> \
58+ --branch=main \
59+ --path=clusters/my-cluster
60+ ```
61+
62+ {{% alert color="warning" title="SSH hostname" %}}
63+ If the Flux CLI must connect to a different SSH endpoint
64+ than your cluster, you can set the SSH hostname and port for the CLI
65+ with ` --ssh-hostname=<host:port> ` .
66+ Note that if set, your SSH hostname and port could be overwritten by
67+ your [ ssh_config] ( https://linux.die.net/man/5/ssh_config ) .
68+ {{% /alert %}}
69+
70+ When using the SSH Agent, the bootstrap command will generate a new SSH private key for the cluster,
71+ and it will prompt you to add the SSH public key as a deploy key to your repository.
72+
73+ The generated SSH key defaults to ` ECDSA P-384 ` , to change the format use ` --ssh-key-algorithm ` and ` --ssh-ecdsa-curve ` .
74+
75+ ## HTTPS basic auth
76+
77+ If your Git server has basic auth enabled, you can bootstrap Flux over HTTPS with:
4078
4179``` sh
4280flux bootstrap git \
@@ -47,9 +85,13 @@ flux bootstrap git \
4785 --path=clusters/my-cluster
4886```
4987
88+ You can also supply the password or Git token using a pipe e.g. ` echo "<my-pass>" | flux bootstrap git ` .
89+
5090If your Git server uses a self-signed TLS certificate, you can specify the CA file with
5191` --ca-file=<path/to/ca.crt> ` .
5292
93+ ## Boostrap multiple clusters
94+
5395With ` --path ` you can configure the directory which will be used to reconcile the target cluster.
5496To control multiple clusters from the same Git repository, you have to set a unique path per
5597cluster e.g. ` clusters/staging ` and ` clusters/production ` :
@@ -65,10 +107,8 @@ cluster e.g. `clusters/staging` and `clusters/production`:
65107 └── flux-system
66108```
67109
68- After running bootstrap you can place Kubernetes YAMLs inside a dir under path
69- e.g. ` clusters/staging/my-app ` , and Flux will reconcile them on your cluster.
70-
71- For examples on how you can structure your Git repository see:
72-
73- * [ flux2-kustomize-helm-example] ( https://github.com/fluxcd/flux2-kustomize-helm-example )
74- * [ flux2-multi-tenancy] ( https://github.com/fluxcd/flux2-multi-tenancy )
110+ {{% alert color="info" title="Bootstrap options" %}}
111+ There are many options available when bootstrapping Flux, such as installing a subset of Flux components,
112+ setting the Kubernetes context, changing the Git author name and email, enabling Git submodules, and more.
113+ To list all the available options run ` flux bootstrap git --help ` .
114+ {{% /alert %}}
0 commit comments