Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): local installation procedure #5629

Merged
merged 2 commits into from
Jun 14, 2024
Merged
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
18 changes: 15 additions & 3 deletions docs/modules/ROOT/pages/contributing/local-development.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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` namespace) installation:

[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-k8s-global
----

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
Expand Down
71 changes: 71 additions & 0 deletions script/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
#####
Loading