This is an automated email from the ASF dual-hosted git repository. pcongiusti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit fa69414ee39a3066db12bd87ae5456bfa59c20e6 Author: Pasquale Congiusti <[email protected]> AuthorDate: Thu Jun 13 10:18:16 2024 +0200 feat(ci): local installation procedure Closes #5460 --- .../ROOT/pages/contributing/local-development.adoc | 18 +++++- script/Makefile | 71 ++++++++++++++++++++++ 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/docs/modules/ROOT/pages/contributing/local-development.adoc b/docs/modules/ROOT/pages/contributing/local-development.adoc index 0ccece2b7..89fa4e1ef 100644 --- a/docs/modules/ROOT/pages/contributing/local-development.adoc +++ b/docs/modules/ROOT/pages/contributing/local-development.adoc @@ -24,14 +24,26 @@ For other cluster types you may check the specific documentation. As soon as you make images ---- -This command will build and publish your actual Camel K development version to the container registry. At this stage installing the Camel K development version will be as easy as a typical installation: +This command will build and publish your actual Camel K development version to the container registry. At this stage installing the Camel K development version will be as easy as a typical installation. We are supporting a series of makefile targets to let you easily install the operator on your local cluster in one single line. These targets are though to cover plain Kubernetes and Openshift cluster in either global (default in `camel-k` namespace) and namespaced (default in `default` n [...] [source] ---- -./kamel install +make install-k8s-global (default in camel-k namespace) +make install-k8s-ns (default in default namespace) +make install-openshift-global (default in camel-k namespace) +make install-openshift-ns (default in default namespace) ---- -You can provide any customization required such as `--log-level`, `--operator-id`, etcetera. Mind that you need to use `./kamel` in order to use the development binary you've just built, as tipically, `kamel` is the production CLI you have installed in your binary path. +Those targets may use two variables, `NAMESPACE` and `REGISTRY` in order to let you specify the namespace where to install the operator and the container registry to use. For instance: + +[source] +---- +NAMESPACE=test REGISTRY=1.2.3.4 make install +---- + +Will install a global operator in the `test` namespace with the registry located at IP 1.2.3.4. Mind that when you're using Minikube, the target will be able to automatically detect any existing local registry and set it up for you. For more complex customization you'll need to use the regular Kustomization installation procedure. + +In order to uninstall the local operator you can also run `make uninstall` (will keep CRDs) and `make uninstall-all` (will remove CRDs and consequently any running Integration). You can use variable `NAMESPACE` as well if the operator was installed in a namespace different than default. [[local-camel-k-runtime]] === Local Camel K runtime diff --git a/script/Makefile b/script/Makefile index d8290f535..6ba3626bc 100644 --- a/script/Makefile +++ b/script/Makefile @@ -762,3 +762,74 @@ $(GOIMPORT): $(LOCALBIN) @test -s $(LOCALBIN)/goimport || \ GOBIN=$(LOCALBIN) go install golang.org/x/tools/cmd/goimports@latest +##### +# START Local installation procedure. Handy for development purpose +##### + +KUSTOMIZE_DIR = "install/overlays/kubernetes/descoped" +MINIKUBE_REGISTRY = "$(shell kubectl -n kube-system get service registry -o jsonpath='{.spec.clusterIP}')" +DEFAULT_NS = "camel-k" + +.PHONY: install install-k8s-global install-k8s-ns install-openshift-global install-openshift-ns + +install-operator: +ifndef NAMESPACE + @echo "WARN: no namespace specified, using default namespace $(DEFAULT_NS)" + $(eval NAMESPACE=$(DEFAULT_NS)) +endif + cd $(KUSTOMIZE_DIR) && kustomize edit set namespace $(NAMESPACE) + cd install/overlays/platform && kustomize edit set namespace $(NAMESPACE) + kubectl apply -k $(KUSTOMIZE_DIR) --server-side + +install-registry: +ifdef REGISTRY + @echo "INFO: Setting IntegrationPlatform container registry to $(REGISTRY)" + @sed -i 's/address: .*/address: $(REGISTRY)/' install/overlays/platform/integration-platform.yaml + kubectl apply -k install/overlays/platform --server-side -n $(NAMESPACE) +else +# verify if a minikube registry is existing by any chance, and set it automatically in such a case +ifneq ($(MINIKUBE_REGISTRY), "") + @echo "INFO: Looks like you're on Minikube. Setting IntegrationPlatform container registry to $(MINIKUBE_REGISTRY)" + @sed -i 's/address: .*/address: $(MINIKUBE_REGISTRY)/' install/overlays/platform/integration-platform.yaml + kubectl apply -k install/overlays/platform --server-side -n $(NAMESPACE) +endif +endif + +install-clean-kustomize: +# we must revert any change done by Kustomize in order to avoid they are committed by mistake in source code repository + @echo "INFO: reverting changes done by Kustomization" + git checkout -- install/overlays/platform/kustomization.yaml + git checkout -- install/overlays/platform/integration-platform.yaml + git checkout -- $(KUSTOMIZE_DIR)/kustomization.yaml + +install-k8s-global: DEFAULT_NS="camel-k" +install-k8s-global: KUSTOMIZE_DIR="install/overlays/kubernetes/descoped" +install-k8s-global: install-operator install-registry install-clean-kustomize + +install-k8s-ns: DEFAULT_NS="default" +install-k8s-ns: KUSTOMIZE_DIR="install/overlays/kubernetes/namespaced" +install-k8s-ns: install-operator install-registry install-clean-kustomize + +install-openshift-global: DEFAULT_NS="camel-k" +install-openshift-global: KUSTOMIZE_DIR="install/overlays/openshift/descoped" +install-openshift-global: install-operator install-clean-kustomize + +install-openshift-ns: DEFAULT_NS="default" +install-openshift-ns: KUSTOMIZE_DIR="install/overlays/openshift/namespaced" +install-openshift-ns: install-operator install-clean-kustomize + +uninstall: +ifdef NAMESPACE + kubectl delete deploy,configmap,secret,sa,rolebindings,clusterrolebindings,roles,clusterroles,integrationplatform -l app=camel-k -n $(NAMESPACE) +else + kubectl delete deploy,configmap,secret,sa,rolebindings,clusterrolebindings,roles,clusterroles,integrationplatform -l app=camel-k +endif + +uninstall-crds: + kubectl delete crd -l app=camel-k + +uninstall-all: uninstall uninstall-crds + +##### +# END Local installation procedure. Handy for development purpose +#####
