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

Use flux namespace in deploy/ examples #2475

Merged
merged 1 commit into from Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion deploy/flux-account.yaml
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
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
@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: flux
1 change: 1 addition & 0 deletions deploy/flux-secret.yaml
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
@@ -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
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
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
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
hiddeco marked this conversation as resolved.
Show resolved Hide resolved
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
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