<commit_before># Get started with Flux

This short guide shows a self-contained example of Flux and just
takes a couple of minutes to get set up. By the end you will
have Flux running in your cluster and it will be deploying any
code changes for you.

> **Note:** If you would like to install Flux using Helm, refer to the
> [Helm section](get-started-helm.md).

## Prerequisites

You will need to have Kubernetes set up. For a quick local test,
you can use `minikube` or `kubeadm`. Any other Kubernetes setup
will work as well though.

### A note on GKE with RBAC enabled

If working on e.g. GKE with RBAC enabled, you will need to add a clusterrolebinding:

```sh
kubectl create clusterrolebinding "cluster-admin-$(whoami)" --clusterrole=cluster-admin --user="$(gcloud config get-value core/account)"
```

to avoid an error along the lines of:

```sh
Error from server (Forbidden): error when creating "deploy/flux-account.yaml":
clusterroles.rbac.authorization.k8s.io "flux" is forbidden: attempt to grant
extra privileges:
```

## Set up Flux

First you'll need a git repository to store your cluster desired state.
In our example we are going to use [`fluxcd/flux-get-started`](https://github.com/fluxcd/flux-get-started).
If you want to use that too, be sure to create a fork of it on GitHub.

Create a directory and add the `fluxcd` namespace definition to it:

```sh
mkdir fluxcd

cat > fluxcd/namespace.yaml <<EOF
apiVersion: v1
kind: Namespace
metadata:
  name: fluxcd
EOF
```

Create a kustomization file and use the Flux deploy YAMLs as base:

```sh
cat > fluxcd/kustomization.yaml <<EOF
namespace: fluxcd
bases:
 - github.com/fluxcd/flux//deploy
patchesStrategicMerge:
  - patch.yaml
EOF
```

> **Note:** If you want to install a specific Flux release,
> add the version number to the base URL:
> `github.com/fluxcd/flux//deploy?ref=v1.14.0`

Create a patch file for Flux deployment and set the `--git-url`
parameter to point to the config repository
(replace `YOURUSER` with your GitHub username):

```sh
cat > fluxcd/patch.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  name: flux
spec:
  template:
    spec:
      containers:
        - name: flux
          args:
            - --manifest-generation=true
            - --memcached-hostname=memcached.fluxcd
            - --memcached-service=
            - --git-poll-interval=5m
            - --sync-interval=5m
            - --ssh-keygen-dir=/var/fluxd/keygen
            - --git-branch=master
            - --git-path=namespaces,workloads
            - --git-url=<EMAIL>:YOURUSER/flux-get-started
EOF
```

We set `--git-path=namespaces,workloads` to exclude Helm manifests.
If you want to get started with Helm, please refer to the
["Get started with Flux using Helm"](get-started-helm.md) tutorial.

## Deploying Flux to the cluster

In the next step, deploy Flux to the cluster (you'll need kubectl **1.14** or newer):

```sh
kubectl apply -k fluxcd
```

Wait for Flux to start:

```sh
kubectl -n fluxcd rollout status deployment/flux
```<commit_msg>Add git user and email flags to install docs<commit_after># Get started with Flux

This short guide shows a self-contained example of Flux and just
takes a couple of minutes to get set up. By the end you will
have Flux running in your cluster and it will be deploying any
code changes for you.

> **Note:** If you would like to install Flux using Helm, refer to the
> [Helm section](get-started-helm.md).

## Prerequisites

You will need to have Kubernetes set up. For a quick local test,
you can use `minikube` or `kubeadm`. Any other Kubernetes setup
will work as well though.

### A note on GKE with RBAC enabled

If working on e.g. GKE with RBAC enabled, you will need to add a clusterrolebinding:

```sh
kubectl create clusterrolebinding "cluster-admin-$(whoami)" --clusterrole=cluster-admin --user="$(gcloud config get-value core/account)"
```

to avoid an error along the lines of:

```sh
Error from server (Forbidden): error when creating "deploy/flux-account.yaml":
clusterroles.rbac.authorization.k8s.io "flux" is forbidden: attempt to grant
extra privileges:
```

## Set up Flux

First you'll need a git repository to store your cluster desired state.
In our example we are going to use [`fluxcd/flux-get-started`](https://github.com/fluxcd/flux-get-started).
If you want to use that too, be sure to create a fork of it on GitHub.

Create a directory and add the `fluxcd` namespace definition to it:

```sh
mkdir fluxcd

cat > fluxcd/namespace.yaml <<EOF
apiVersion: v1
kind: Namespace
metadata:
  name: fluxcd
EOF
```

Create a kustomization file and use the Flux deploy YAMLs as base:

```sh
cat > fluxcd/kustomization.yaml <<EOF
namespace: fluxcd
bases:
 - github.com/fluxcd/flux//deploy
patchesStrategicMerge:
  - patch.yaml
EOF
```

> **Note:** If you want to install a specific Flux release,
> add the version number to the base URL:
> `github.com/fluxcd/flux//deploy?ref=v1.14.0`

Create a patch file for Flux deployment and set the `--git-url`
parameter to point to the config repository
(replace `YOURUSER` with your GitHub username):

```sh
export GHUSER="YOURUSER"
cat > fluxcd/patch.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  name: flux
spec:
  template:
    spec:
      containers:
        - name: flux
          args:
            - --manifest-generation=true
            - --memcached-hostname=memcached.fluxcd
            - --memcached-service=
            - --ssh-keygen-dir=/var/fluxd/keygen
            - --git-branch=master
            - --git-path=namespaces,workloads
            - --git-user=${GHUSER}
            - --git-email=${<EMAIL>
            - --git-url=<EMAIL>:${GHUSER}/flux-get-started
EOF
```

We set `--git-path=namespaces,workloads` to exclude Helm manifests.
If you want to get started with Helm, please refer to the
["Get started with Flux using Helm"](get-started-helm.md) tutorial.

## Deploying Flux to the cluster

In the next step, deploy Flux to the cluster (you'll need kubectl **1.14** or newer):

```sh
kubectl apply -k fluxcd
```

Wait for Flux to start:

```sh
kubectl -n fluxcd rollout status deployment/flux
```
{'fraction_non_alphanumeric': 0.10486769029728847, 'fraction_numerical': 0.0035935968637700096, 'mean_word_length': 3.3735714285714287, 'pattern_counts': {'":': 2, '<': 18, '<?xml version=': 0, '>': 22, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '749955', 'n_tokens_mistral': 2013, 'n_tokens_neox': 1892, 'n_words': 752}