Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions workspaces/backend/api/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ var _ = BeforeSuite(func() {
ctx, cancel = context.WithCancel(context.Background())

By("bootstrapping test environment")
path := filepath.Join("..", "..", "controller", "config", "crd", "bases")
path := filepath.Join("..", "..", "controller", "manifests", "kustomize", "base", "crd")
fmt.Println(path)
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{
filepath.Join("..", "..", "controller", "config", "crd", "bases"),
filepath.Join("..", "..", "controller", "manifests", "kustomize", "base", "crd"),
},
ErrorIfCRDPathMissing: true,

Expand Down
21 changes: 9 additions & 12 deletions workspaces/controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ help: ## Display this help.

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

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

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

##@ Deployment

ifndef ignore-not-found
Expand All @@ -132,20 +129,20 @@ endif

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

.PHONY: uninstall
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.
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
$(KUSTOMIZE) build manifests/kustomize/base/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -

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

.PHONY: undeploy
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.
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
$(KUBECTL) delete -k manifests/kustomize/overlays/istio --ignore-not-found=$(ignore-not-found)

##@ Dependencies

Expand Down
29 changes: 3 additions & 26 deletions workspaces/controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ make deploy IMG=<some-registry>/workspaces-controller:tag
privileges or be logged in as admin.

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

```sh
kubectl apply -k config/samples/
kubectl apply -k manifests/kustomize/samples/
```

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

```sh
kubectl delete -k config/samples/
kubectl delete -k manifests/kustomize/samples/
```

**Delete the APIs(CRDs) from the cluster:**
Expand All @@ -67,26 +67,3 @@ make uninstall
```sh
make undeploy
```

## Project Distribution

Following are the steps to build the installer and distribute this project to users.

1. Build the installer for the image built and published in the registry:

```sh
make build-installer IMG=<some-registry>/workspaces-controller:tag
```

NOTE: The makefile target mentioned above generates an 'install.yaml'
file in the dist directory. This file contains all the resources built
with Kustomize, which are necessary to install this project without
its dependencies.

2. Using the installer

Users can just run kubectl apply -f <URL for YAML BUNDLE> to install the project, i.e.:

```sh
kubectl apply -f https://raw.githubusercontent.com/<org>/workspaces-controller/<tag or branch>/dist/install.yaml
```
9 changes: 0 additions & 9 deletions workspaces/controller/config/certmanager/kustomization.yaml

This file was deleted.

121 changes: 0 additions & 121 deletions workspaces/controller/config/default/kustomization.yaml

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions workspaces/controller/config/default/webhookcainjection_patch.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions workspaces/controller/config/manager/kustomization.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions workspaces/controller/config/prometheus/kustomization.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions workspaces/controller/config/webhook/kustomization.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion workspaces/controller/internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var _ = BeforeSuite(func() {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "..", "manifests", "kustomize", "base", "crd")},
ErrorIfCRDPathMissing: true,

// The BinaryAssetsDirectory is only required if you want to run the tests directly without call the makefile target test.
Expand Down
4 changes: 2 additions & 2 deletions workspaces/controller/internal/webhook/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var _ = BeforeSuite(func() {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "..", "manifests", "kustomize", "base", "crd")},
ErrorIfCRDPathMissing: true,

// The BinaryAssetsDirectory is only required if you want to run the tests directly without call the makefile target test.
Expand All @@ -87,7 +87,7 @@ var _ = BeforeSuite(func() {
BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", fmt.Sprintf("1.31.0-%s-%s", runtime.GOOS, runtime.GOARCH)),

WebhookInstallOptions: envtest.WebhookInstallOptions{
Paths: []string{filepath.Join("..", "..", "config", "webhook")},
Paths: []string{filepath.Join("..", "..", "manifests", "kustomize", "base", "webhook", "manifests.yaml")},
},
}
var err error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# This kustomization.yaml is not intended to be run by itself,
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
# It should be run by manifests/kustomize/base
resources:
- bases/kubeflow.org_workspaces.yaml
- bases/kubeflow.org_workspacekinds.yaml
- kubeflow.org_workspaces.yaml
- kubeflow.org_workspacekinds.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- path: workspaces_webhook_patch.yaml
#- path: workspacekinds_webhook_patch.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
- path: patches/cainjection_in_workspaces.yaml
- path: patches/cainjection_in_workspacekinds.yaml
- path: workspaces_cainjection_patch.yaml
- path: workspacekinds_cainjection_patch.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# [WEBHOOK] To enable webhook, uncomment the following section
Expand Down
26 changes: 26 additions & 0 deletions workspaces/controller/manifests/kustomize/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Adds namespace to all resources.
namespace: kubeflow-workspaces

resources:
- crd
- manager
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
- webhook


# [WEBHOOK] Replacements to keep webhook-service name in sync for CRD conversion webhooks
# Uncomment when CRD conversion webhook patches are enabled in crd/kustomization.yaml
#replacements:
# - source:
# kind: Service
# version: v1
# name: webhook-service
# fieldPath: .metadata.name
# targets:
# - select:
# kind: CustomResourceDefinition
# fieldPaths:
# - .spec.conversion.webhook.clientConfig.service.name
# options:
# create: false
Loading