Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Use flux namespace in deploy/ examples (#2475)
Browse files Browse the repository at this point in the history
Use `flux` namespace in `deploy/` examples
  • Loading branch information
hiddeco authored Sep 25, 2019
2 parents 9b92416 + bdb197e commit bf83c71
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 18 deletions.
3 changes: 2 additions & 1 deletion deploy/flux-account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metadata:
labels:
name: flux
name: flux
namespace: flux
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
Expand Down Expand Up @@ -34,4 +35,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: flux
namespace: default
namespace: flux
1 change: 1 addition & 0 deletions deploy/flux-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: flux
namespace: flux
spec:
replicas: 1
selector:
Expand Down
5 changes: 5 additions & 0 deletions deploy/flux-ns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: flux
1 change: 1 addition & 0 deletions deploy/flux-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ apiVersion: v1
kind: Secret
metadata:
name: flux-git-deploy
namespace: flux
type: Opaque
1 change: 1 addition & 0 deletions deploy/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resources:
- flux-ns.yaml
- memcache-svc.yaml
- memcache-dep.yaml
- flux-account.yaml
Expand Down
1 change: 1 addition & 0 deletions deploy/memcache-dep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: memcached
namespace: flux
spec:
replicas: 1
selector:
Expand Down
1 change: 1 addition & 0 deletions deploy/memcache-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Service
metadata:
name: memcached
namespace: flux
spec:
ports:
- name: memcached
Expand Down
63 changes: 46 additions & 17 deletions docs/tutorials/get-started-kustomize.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,14 @@ 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 `flux` namespace definition to it:

```sh
mkdir fluxcd

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

Create a kustomization file and use the Flux deploy YAMLs as base:
Create a directory, and add a `kustomization.yaml` file that uses the
Flux deploy YAMLs as a base:

```sh
cat > fluxcd/kustomization.yaml <<EOF
namespace: flux
resources:
- namespace.yaml
bases:
- github.com/fluxcd/flux//deploy
- github.com/fluxcd/flux//deploy
patchesStrategicMerge:
- patch.yaml
EOF
Expand Down Expand Up @@ -88,6 +74,49 @@ 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.

### Overwriting the default namespace

Overwriting the default (`flux`) namespace is possible by defining
your own namespace resource and a patch to remove the default from
the base.

Create your own namespace definition:

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

Create a patch to remove the default namespace from the base:

```sh
cat > fluxcd/patch-default-ns.yaml <<EOF
apiVersion: v1
kind: Namespace
metadata:
name: flux
$patch: delete
EOF
```

Adapt your `fluxcd/kustomization.yaml` to include your own namespace
resource, patch, and change the namespace:

```yaml
namespace: <namespace>
resources:
- namespace.yaml
bases:
- github.com/fluxcd/flux//deploy
patchesStrategicMerge:
- patch-default-ns.yaml
- patch.yaml
```
## Install Flux with Kustomize
In the next step, deploy Flux to the cluster (you'll need kubectl **1.14** or newer):
Expand Down
1 change: 1 addition & 0 deletions pkg/install/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func main() {
params := install.TemplateParameters{
GitURL: "git@github.com:fluxcd/flux-get-started",
GitBranch: "master",
Namespace: "flux",
}
manifests, err := install.FillInTemplates(params)
if err != nil {
Expand Down

0 comments on commit bf83c71

Please sign in to comment.