Skip to content

Commit 175f162

Browse files
committed
chore: standardize controller kustomize implementation
Motivation: This refactoring aligns the controller's kustomize configuration with best practices and ensures consistency with other components (backend, frontend). The primary goals were: - Remove nested subdirectories (bases/, patches/) to match the flat structure used in other base directories - Ensure components are only included in overlays, not the base - Improve maintainability through consistent naming conventions - Better organize resources by their purpose and dependencies Changes Made: 1. Flattened CRD directory structure: - Moved CRD base files from crd/bases/ to crd/ - Moved patch files from crd/patches/ to crd/ - Updated all references in Makefile and test files 2. Standardized patch file naming: - Renamed cainjection_in_*.yaml → *_cainjection_patch.yaml - Renamed webhook_in_*.yaml → *_webhook_patch.yaml - Provides consistent naming pattern across all patches 3. Component organization: - Moved metrics_service.yaml to prometheus component (only included when prometheus is enabled) - Moved manager_webhook_patch.yaml to certmanager component (only needed when cert-manager is enabled) - Extracted namespace.yaml from manager.yaml for explicit definition 4. Updated references: - Makefile: Changed controller-gen output path from crd/bases to crd - Test files: Updated CRDDirectoryPaths in controller, webhook, and backend test suites 5. Removed unused build-installer target: - Removed from Makefile and README as it's not used and kustomize provides better facilities for vendoring Expected Manifest Output Differences: 1. webhook-service port now has name attribute: - Added `name: webhook` to the port definition - This enables replacements to reference the port by name, improving maintainability and keeping port values in sync between Service and Deployment 2. workspaces-controller-metrics-service is missing: - This is expected as metrics_service.yaml was moved to the prometheus component - The service will only appear when the prometheus component is explicitly enabled in an overlay 3. kubeflow-workspaces-istio-config ConfigMap labels: - Common labels were added (app.kubernetes.io/managed-by, app.kubernetes.io/name, app.kubernetes.io/part-of) due to reordering of components in the overlay - The common component is now applied last to ensure its labels are applied to all resources consistently 4. All other resources remain functionally equivalent: - CRDs, Deployments, Services, RBAC, and webhook configurations are unchanged in functionality - Only structural and organizational improvements were made Signed-off-by: Andy Stoneberg <[email protected]>
1 parent 84a1c72 commit 175f162

File tree

62 files changed

+337
-252
lines changed

Some content is hidden

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

62 files changed

+337
-252
lines changed

workspaces/backend/api/suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ var _ = BeforeSuite(func() {
8282
ctx, cancel = context.WithCancel(context.Background())
8383

8484
By("bootstrapping test environment")
85-
path := filepath.Join("..", "..", "controller", "config", "crd", "bases")
85+
path := filepath.Join("..", "..", "controller", "manifests", "kustomize", "base", "crd")
8686
fmt.Println(path)
8787
testEnv = &envtest.Environment{
8888
CRDDirectoryPaths: []string{
89-
filepath.Join("..", "..", "controller", "config", "crd", "bases"),
89+
filepath.Join("..", "..", "controller", "manifests", "kustomize", "base", "crd"),
9090
},
9191
ErrorIfCRDPathMissing: true,
9292

workspaces/controller/Makefile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ help: ## Display this help.
4848

4949
.PHONY: manifests
5050
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
51-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
51+
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." \
52+
output:crd:artifacts:config=manifests/kustomize/base/crd \
53+
output:webhook:artifacts:config=manifests/kustomize/base/webhook \
54+
output:rbac:artifacts:config=manifests/kustomize/base/manager
5255

5356
.PHONY: generate
5457
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
@@ -118,12 +121,6 @@ docker-build-multi-arch:
118121
docker-build-push-multi-arch:
119122
docker buildx build --platform ${ARCH} --tag ${IMG} --push .
120123

121-
.PHONY: build-installer
122-
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
123-
mkdir -p dist
124-
cd config/manager && $(KUSTOMIZE) edit set image workspaces-controller=${IMG}
125-
$(KUSTOMIZE) build config/default > dist/install.yaml
126-
127124
##@ Deployment
128125

129126
ifndef ignore-not-found
@@ -132,20 +129,20 @@ endif
132129

133130
.PHONY: install
134131
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
135-
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
132+
$(KUSTOMIZE) build manifests/kustomize/base/crd | $(KUBECTL) apply -f -
136133

137134
.PHONY: uninstall
138135
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
139-
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
136+
$(KUSTOMIZE) build manifests/kustomize/base/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
140137

141138
.PHONY: deploy
142139
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
143-
cd config/manager && $(KUSTOMIZE) edit set image workspaces-controller=${IMG}
144-
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
140+
cd manifests/kustomize/overlays/istio && $(KUSTOMIZE) edit set image workspaces-controller=${IMG}
141+
$(KUBECTL) apply -k manifests/kustomize/overlays/istio
145142

146143
.PHONY: undeploy
147144
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
148-
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
145+
$(KUBECTL) delete -k manifests/kustomize/overlays/istio --ignore-not-found=$(ignore-not-found)
149146

150147
##@ Dependencies
151148

workspaces/controller/README.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ make deploy IMG=<some-registry>/workspaces-controller:tag
4141
privileges or be logged in as admin.
4242

4343
**Create instances of your solution**
44-
You can apply the samples (examples) from the config/sample:
44+
You can apply the samples (examples) from the manifests/kustomize/samples:
4545

4646
```sh
47-
kubectl apply -k config/samples/
47+
kubectl apply -k manifests/kustomize/samples/
4848
```
4949

5050
>**NOTE**: Ensure that the samples has default values to test it out.
@@ -53,7 +53,7 @@ kubectl apply -k config/samples/
5353
**Delete the instances (CRs) from the cluster:**
5454

5555
```sh
56-
kubectl delete -k config/samples/
56+
kubectl delete -k manifests/kustomize/samples/
5757
```
5858

5959
**Delete the APIs(CRDs) from the cluster:**
@@ -67,26 +67,3 @@ make uninstall
6767
```sh
6868
make undeploy
6969
```
70-
71-
## Project Distribution
72-
73-
Following are the steps to build the installer and distribute this project to users.
74-
75-
1. Build the installer for the image built and published in the registry:
76-
77-
```sh
78-
make build-installer IMG=<some-registry>/workspaces-controller:tag
79-
```
80-
81-
NOTE: The makefile target mentioned above generates an 'install.yaml'
82-
file in the dist directory. This file contains all the resources built
83-
with Kustomize, which are necessary to install this project without
84-
its dependencies.
85-
86-
2. Using the installer
87-
88-
Users can just run kubectl apply -f <URL for YAML BUNDLE> to install the project, i.e.:
89-
90-
```sh
91-
kubectl apply -f https://raw.githubusercontent.com/<org>/workspaces-controller/<tag or branch>/dist/install.yaml
92-
```

workspaces/controller/config/certmanager/kustomization.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

workspaces/controller/config/default/kustomization.yaml

Lines changed: 0 additions & 121 deletions
This file was deleted.

workspaces/controller/config/default/manager_config_patch.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

workspaces/controller/config/default/webhookcainjection_patch.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

workspaces/controller/config/manager/kustomization.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

workspaces/controller/config/prometheus/kustomization.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

workspaces/controller/config/webhook/kustomization.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)