Skip to content

Commit cf7e15f

Browse files
authored
Unify kustomize setup and reduce duplication (#1084)
* Unify kustomize setup and reduce duplication
1 parent f52a98a commit cf7e15f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+572
-809
lines changed

Diff for: Makefile

+23-8
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ GO_SRC=$(shell find . -name "*.go" -not -name "zz_generated.*.go")
5858
GENERATED_GO=api/v1beta2/zz_generated.deepcopy.go
5959
GO_ALL=${GO_SRC} ${GENERATED_GO}
6060
MANIFESTS=config/crd/bases/apps.foundationdb.org_foundationdbbackups.yaml config/crd/bases/apps.foundationdb.org_foundationdbclusters.yaml config/crd/bases/apps.foundationdb.org_foundationdbrestores.yaml
61+
SAMPLES=config/samples/deployment.yaml config/samples/cluster.yaml config/samples/backup.yaml config/samples/restore.yaml config/samples/client.yaml
6162

6263
ifeq "$(TEST_RACE_CONDITIONS)" "1"
6364
go_test_flags := $(go_test_flags) -race -timeout=30m
6465
endif
6566

66-
6767
all: deps generate fmt vet manager plugin manifests samples documentation test_if_changed
6868

6969
.PHONY: clean all manager samples documentation run install uninstall deploy manifests fmt vet generate container-build container-push rebuild-operator bounce lint
@@ -75,7 +75,8 @@ clean:
7575
find api -type f -name "zz_generated.*.go" -delete
7676
mkdir -p bin
7777
rm -r bin
78-
find config/samples -type f -name deployment.yaml -delete
78+
rm -f $(SAMPLES)
79+
rm -f config/rbac/role.yaml
7980
find . -name "cover.out" -delete
8081

8182
clean-deps:
@@ -127,14 +128,17 @@ uninstall: manifests
127128

128129
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
129130
deploy: install manifests
130-
cd config/manager && kustomize edit set image controller=${IMG}
131-
kustomize build config/default | kubectl apply -f -
131+
cd config/development && kustomize edit set image foundationdb/fdb-kubernetes-operator=${IMG}
132+
kustomize build config/development | kubectl apply -f -
132133

133134
# Generate manifests e.g. CRD, RBAC etc.
134135
manifests: ${MANIFESTS}
135136

136137
${MANIFESTS}: ${CONTROLLER_GEN} ${GO_SRC}
137138
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
139+
# Per default controller-gen will generate a ClusterRole for our example we want to use a Role and the namespace marker doesn't
140+
# work since it requires a namespace and kustomize doesn't support to change the Kind.
141+
@sed -i 's/kind: ClusterRole/kind: Role/g' ./config/rbac/role.yaml
138142

139143
# Run go fmt against code
140144
fmt: bin/fmt_check
@@ -172,10 +176,22 @@ rebuild-operator: container-build deploy bounce
172176
bounce:
173177
kubectl delete pod -l app=fdb-kubernetes-operator-controller-manager
174178

175-
samples: config/samples/deployment.yaml
179+
samples: ${SAMPLES}
180+
181+
config/samples/deployment.yaml: config/deployment/*.yaml
182+
kustomize build ./config/deployment > $@
183+
184+
config/samples/cluster.yaml: config/tests/base/*.yaml
185+
kustomize build ./config/tests/base/ > $@
176186

177-
config/samples/deployment.yaml: config/samples/deployment/*.yaml
178-
kustomize build config/samples/deployment > config/samples/deployment.yaml
187+
config/samples/backup.yaml: config/tests/backup/base/*.yaml
188+
kustomize build ./config/tests/backup/base > $@
189+
190+
config/samples/restore.yaml: config/tests/backup/base/*.yaml
191+
kustomize build ./config/tests/backup/restore > $@
192+
193+
config/samples/client.yaml: config/tests/client/*.yaml
194+
kustomize build ./config/tests/client > $@
179195

180196
bin/po-docgen: cmd/po-docgen/*.go
181197
go build -o bin/po-docgen cmd/po-docgen/main.go cmd/po-docgen/api.go
@@ -193,4 +209,3 @@ documentation: docs/cluster_spec.md docs/backup_spec.md docs/restore_spec.md
193209

194210
lint:
195211
golangci-lint run ./...
196-

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ You can test your setup with `SKIP_TEST=1 make container-build` which will build
8383
After the command successfully finished you can verify with `nerdctl -n k8s.io images fdb-kubernetes-operator:latest` that the image is available.
8484

8585
### Known Limitations
86+
8687
1. Support for backups in the operator is still in development, and there are significant missing features.
8788
2. The unified image is still experimental, and is not recommended outside of development environments.
8889
3. Additional limitations can be found under [Warnings](docs/manual/warnings.md).

Diff for: config/default/kustomization.yaml

-69
This file was deleted.

Diff for: config/default/manager_auth_proxy_patch.yaml

-24
This file was deleted.

Diff for: config/default/manager_webhook_patch.yaml

-23
This file was deleted.

Diff for: config/default/webhookcainjection_patch.yaml

-15
This file was deleted.

Diff for: config/samples/deployment/kustomization.yaml renamed to config/deployment/kustomization.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
kind: Kustomization
2+
apiVersion: kustomize.config.k8s.io/v1beta1
13
# Adds namespace to all resources.
24

35
# Value of this field is prepended to the
@@ -13,6 +15,6 @@ namePrefix: fdb-kubernetes-operator-
1315
# YAML string, with resources separated by document
1416
# markers ("---").
1517
resources:
16-
- rbac_role.yaml
18+
- ../rbac
1719
- rbac_role_binding.yaml
18-
- manager.yaml
20+
- manager.yaml
File renamed without changes.

Diff for: config/samples/deployment/rbac_role_binding.yaml renamed to config/deployment/rbac_role_binding.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
roleRef:
77
apiGroup: rbac.authorization.k8s.io
88
kind: Role
9-
name: manager-role
9+
name: fdb-kubernetes-operator-manager-role
1010
subjects:
1111
- kind: ServiceAccount
12-
name: controller-manager
12+
name: fdb-kubernetes-operator-controller-manager
File renamed without changes.

Diff for: config/development/kustomization.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
patchesStrategicMerge:
5+
- test_certs.yaml
6+
- backup_credentials.yaml
7+
8+
resources:
9+
- ../deployment
10+
- ../minio
11+
12+
images:
13+
- name: foundationdb/fdb-kubernetes-operator
14+
newName: fdb-kubernetes-operator
15+
newTag: latest
File renamed without changes.

Diff for: config/manager/kustomization.yaml

-9
This file was deleted.

Diff for: config/manager/manager.yaml

-94
This file was deleted.

Diff for: config/prometheus/kustomization.yaml

-2
This file was deleted.

Diff for: config/prometheus/monitor.yaml

-12
This file was deleted.

Diff for: config/rbac/auth_proxy_role.yaml

-13
This file was deleted.

0 commit comments

Comments
 (0)