diff --git a/.gitignore b/.gitignore index f483d594..e5d9190c 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,5 @@ vendor .vscode # modularization generated files -moduletemplate-k3d.yaml -moduletemplate.yaml warden-manifest.yaml module-config.yaml diff --git a/Makefile b/Makefile index 2b58d53d..5e0ded9d 100644 --- a/Makefile +++ b/Makefile @@ -108,15 +108,15 @@ docker-buildx: test ## Build and push docker image for the manager for cross-pla ##@ Module .PHONY: module-build -module-build: kyma helm ## create moduletemplate and push manifest artifacts - @KYMA=${KYMA} HELM=${HELM} RELEASE_SUFFIX=${MODULE_SHA} ./hack/create-module.sh +module-build: helm ## renders warden-manifest.yaml + ${HELM} template --namespace kyma-system warden charts/warden --set admission.enabled=true > warden-manifest.yaml ##@ CI .PHONY: ci-module-build ci-module-build: configure-git-origin module-build - @echo "=======MODULE TEMPLATE=======" - @cat moduletemplate.yaml + @echo "=======WARDEN MANIFEST=======" + @cat warden-manifest.yaml @echo "=============================" .PHONY: configure-git-origin @@ -127,13 +127,18 @@ configure-git-origin: git remote add origin https://github.com/kyma-project/warden -.PHONY: k3d-lm-integration-test -k3d-lm-integration-test: ## Run integration tests on self-prepared k3d cluster with lifecycle-manager. -k3d-lm-integration-test: run-with-lifecycle-manager verify-status run-integration-tests +.PHONY: k3d-integration-test +k3d-integration-test: ## Run integration tests on self-prepared k3d cluster. +k3d-integration-test: run-on-k3d verify-status run-integration-tests -.PHONY: run-with-lifecycle-manager -run-with-lifecycle-manager: kyma helm configure-git-origin - @KYMA=${KYMA} HELM=${HELM} ./hack/run-module-locally.sh +.PHONY: create-k3d +create-k3d: ## Create k3d + ${KYMA} provision k3d --ci -p 6080:8080@loadbalancer -p 6433:8433@loadbalancer + kubectl create namespace kyma-system + +.PHONY: run-on-k3d +run-on-k3d: kyma create-k3d configure-git-origin module-build + kubectl apply -f warden-manifest.yaml .PHONY: verify-status verify-status: diff --git a/hack/create-module.sh b/hack/create-module.sh deleted file mode 100755 index 90ac57a5..00000000 --- a/hack/create-module.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -# require envs -KYMA=${KYMA?"Define KYMA env"} -HELM=${HELM?"Define HELM env"} -MODULE_REGISTRY=${MODULE_REGISTRY?"Define MODULE_REGISTRY env"} - -# optional envs -SEC_SCANNERS_CONFIG=${SEC_SCANNERS_CONFIG:-} - -CHANNEL="${CHANNEL:-fast}" - -DEFAULT_NAME=$(cat sec-scanners-config.yaml | grep module-name | sed 's/module-name: //g') -NAME="${NAME:-$DEFAULT_NAME}" - -DEFAULT_RELEASE=$(cat sec-scanners-config.yaml | grep rc-tag | sed 's/rc-tag: //g') -RELEASE_SUFFIX="${RELEASE_SUFFIX:-}" -RELEASE="${RELEASE:-$DEFAULT_RELEASE}" -if [[ -n "${RELEASE_SUFFIX}" ]]; then - RELEASE="$RELEASE-${RELEASE_SUFFIX}" -fi - -CREATE_MODULE_EXTRA_ARGS="${CREATE_MODULE_EXTRA_ARGS:-}" - -## generate manifest -printf "Generate manifest to the warden-manifest.yaml file\n" -${HELM} template --namespace kyma-system warden charts/warden --set admission.enabled=true > warden-manifest.yaml - -## generate module-config.yaml template -printf "Generate the module-config.yaml from template\n" -cat module-config-template.yaml | - sed "s/{{.Name}}/kyma-project.io\/module\/${NAME}/g" | - sed "s/{{.Channel}}/${CHANNEL}/g" | - sed "s/{{.Version}}/${RELEASE}/g" > module-config.yaml - -## create module -printf "Create module\n" -${KYMA} alpha create module --path . --output=moduletemplate.yaml \ - --sec-scanners-config="$SEC_SCANNERS_CONFIG" \ - --module-config-file=module-config.yaml \ - --registry ${MODULE_REGISTRY} ${CREATE_MODULE_EXTRA_ARGS} --module-archive-version-overwrite diff --git a/hack/run-module-locally.sh b/hack/run-module-locally.sh deleted file mode 100755 index 89cbd506..00000000 --- a/hack/run-module-locally.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# script creates k3d cluster with lifecycle-manager, -# installs self prepared moduletemplate on it and enables warden module - -set -eo pipefail - - -# k3d config -K3D_CLUSTER_NAME="kyma" -K3D_REGISTRY_PORT=5001 -K3D_REGISTRY_NAME="${K3D_CLUSTER_NAME}-registry" -K3D_REGISTRY_ADDRESS="localhost:${K3D_REGISTRY_PORT}" - -# programs -export KYMA="${KYMA:-$(which kyma)}" -export HELM="${HELM:-$(which helm)}" - -## create k3d cluster and registry -printf "[ 1 ] Create k3d cluster and registry\n" -${KYMA} provision k3d --registry-port ${K3D_REGISTRY_PORT} --name ${K3D_CLUSTER_NAME} --ci -kubectl create namespace kyma-system - -printf "\n[ 2 ] Create module template\n" -export MODULE_REGISTRY=$K3D_REGISTRY_ADDRESS -export CREATE_MODULE_EXTRA_ARGS="--insecure" -./hack/create-module.sh - - -## fix moduletemplate (to able pulling artifacts by the k8s internally) -printf "\n[ 3 ] Fix moduletemplate\n" -cat moduletemplate.yaml \ - | sed -e "s/remote/control-plane/g" \ - -e "s/${K3D_REGISTRY_PORT}/5000/g" \ - -e "s/localhost/k3d-${K3D_REGISTRY_NAME}.localhost/g" \ - > moduletemplate-k3d.yaml - -## deploy LM -printf "\n[ 4 ] Deploy LM\n" -${KYMA} alpha deploy --ci --force-conflicts - -## apply moduletemplate -printf "\n[ 5 ] Apply moduletemplate\n" -kubectl apply -f moduletemplate-k3d.yaml - -## enable warden module -printf "\n[ 6 ] Enable warden module\n" -${KYMA} alpha enable module warden -c fast - -## verify -printf "\n[ 7 ] Verify\n" -printf "to verify use 'kubectl get kyma -A -w'"