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

Commit eefe4af

Browse files
committed
Use flux namespace in deploy/ examples
This is so that the configuration is not effected by e.g. a namespace context set in the `kubectl` config of the user, as this caused problems during the creation of the `ClusterRoleBinding` which was set to the `default` namespace, while the resources themselves would be created in the user their configured namespace. It also simplifies the 'Get started with Kustomize' guide, as a user does no longer need to create the namespace as a prerequisite but is still able to overwrite it by adding a `namespace: <targetNamespace>` to their `kustomization.yaml`.
1 parent 9b92416 commit eefe4af

9 files changed

+15
-18
lines changed

deploy/flux-account.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ metadata:
77
labels:
88
name: flux
99
name: flux
10+
namespace: flux
1011
---
1112
apiVersion: rbac.authorization.k8s.io/v1beta1
1213
kind: ClusterRole
@@ -34,4 +35,4 @@ roleRef:
3435
subjects:
3536
- kind: ServiceAccount
3637
name: flux
37-
namespace: default
38+
namespace: flux

deploy/flux-deployment.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apiVersion: apps/v1
33
kind: Deployment
44
metadata:
55
name: flux
6+
namespace: flux
67
spec:
78
replicas: 1
89
selector:

deploy/flux-ns.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: flux

deploy/flux-secret.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ apiVersion: v1
33
kind: Secret
44
metadata:
55
name: flux-git-deploy
6+
namespace: flux
67
type: Opaque

deploy/kustomization.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
resources:
2+
- flux-ns.yaml
23
- memcache-svc.yaml
34
- memcache-dep.yaml
45
- flux-account.yaml

deploy/memcache-dep.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ apiVersion: apps/v1
55
kind: Deployment
66
metadata:
77
name: memcached
8+
namespace: flux
89
spec:
910
replicas: 1
1011
selector:

deploy/memcache-svc.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apiVersion: v1
33
kind: Service
44
metadata:
55
name: memcached
6+
namespace: flux
67
spec:
78
ports:
89
- name: memcached

docs/tutorials/get-started-kustomize.md

+2-17
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,11 @@ First you'll need a git repository to store your cluster desired state.
2424
In our example we are going to use [`fluxcd/flux-get-started`](https://github.com/fluxcd/flux-get-started).
2525
If you want to use that too, be sure to create a fork of it on GitHub.
2626

27-
Create a directory and add the `flux` namespace definition to it:
28-
29-
```sh
30-
mkdir fluxcd
31-
32-
cat > fluxcd/namespace.yaml <<EOF
33-
apiVersion: v1
34-
kind: Namespace
35-
metadata:
36-
name: flux
37-
EOF
38-
```
39-
40-
Create a kustomization file and use the Flux deploy YAMLs as base:
27+
Create a directory, and add a `kustomization.yaml` file that uses the
28+
Flux deploy YAMLs as a base:
4129

4230
```sh
4331
cat > fluxcd/kustomization.yaml <<EOF
44-
namespace: flux
45-
resources:
46-
- namespace.yaml
4732
bases:
4833
- github.com/fluxcd/flux//deploy
4934
patchesStrategicMerge:

pkg/install/generate.go

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func main() {
4040
params := install.TemplateParameters{
4141
GitURL: "git@github.com:fluxcd/flux-get-started",
4242
GitBranch: "master",
43+
Namespace: "flux",
4344
}
4445
manifests, err := install.FillInTemplates(params)
4546
if err != nil {

0 commit comments

Comments
 (0)