-
Notifications
You must be signed in to change notification settings - Fork 30
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: Add Scripts to Automate Tasks in KLM #2061
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,177 +1,171 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Delete Test Clusters", | ||
"type": "shell", | ||
"command": "k3d cluster rm kcp skr", | ||
}, | ||
{ | ||
"label": "Ensure Test Clusters", | ||
"type": "shell", | ||
"command": "${cwd}/scripts/tests/create_test_clusters.sh", | ||
}, | ||
{ | ||
"label": "Create New Test Clusters", | ||
"type": "shell", | ||
"command": "${cwd}/scripts/tests/create_test_clusters.sh", | ||
"dependsOn": [ | ||
"Delete Test Clusters" | ||
] | ||
}, | ||
// re-run if encountering error that the watcher CRD is missing | ||
{ | ||
"label": "Deploy KLM from sources", | ||
"type": "shell", | ||
"command": "TAG=\"$(date +%Y%m%d%H%M%S)\" && make docker-build IMG=${LOCAL_IMG}:${TAG}; make docker-push IMG=${LOCAL_IMG}:${TAG}; make local-deploy-with-watcher IMG=${CLUSTER_IMG}:${TAG}", | ||
"options": { | ||
"env": { | ||
"LOCAL_IMG": "localhost:5111/lifecycle-manager", | ||
"CLUSTER_IMG": "k3d-kcp-registry.localhost:5000/lifecycle-manager", | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml" | ||
|
||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Delete Test Clusters", | ||
"type": "shell", | ||
"command": "k3d cluster rm kcp skr" | ||
}, | ||
{ | ||
"label": "Ensure Test Clusters", | ||
"type": "shell", | ||
"command": "${cwd}/scripts/tests/create_test_clusters.sh" | ||
}, | ||
{ | ||
"label": "Create New Test Clusters", | ||
"type": "shell", | ||
"command": "${cwd}/scripts/tests/create_test_clusters.sh", | ||
"dependsOn": ["Delete Test Clusters"] | ||
}, | ||
// re-run if encountering error that the watcher CRD is missing | ||
{ | ||
"label": "Deploy KLM from sources", | ||
"type": "shell", | ||
"command": "TAG=\"$(date +%Y%m%d%H%M%S)\" && make docker-build IMG=${LOCAL_IMG}:${TAG}; make docker-push IMG=${LOCAL_IMG}:${TAG}; make local-deploy-with-watcher IMG=${CLUSTER_IMG}:${TAG}", | ||
"options": { | ||
"env": { | ||
"LOCAL_IMG": "localhost:5111/lifecycle-manager", | ||
"CLUSTER_IMG": "k3d-kcp-registry.localhost:5000/lifecycle-manager", | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml" | ||
} | ||
} | ||
}, | ||
// re-run if encountering error that the watcher CRD is missing | ||
{ | ||
"label": "Deploy KLM from registry", | ||
"type": "shell", | ||
"command": "make local-deploy-with-watcher IMG=${IMG_REGISTRY_HOST}/${input:klmImageRegistry}/${IMG_NAME}:${input:klmImageTag}", | ||
"options": { | ||
"env": { | ||
"IMG_REGISTRY_HOST": "europe-docker.pkg.dev/kyma-project", | ||
"IMG_NAME": "lifecycle-manager", | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Deploy template-operator", | ||
"type": "shell", | ||
"command": "kubectl apply -f ${cwd}/tests/e2e/moduletemplate/${input:templateOperatorVersion}", | ||
"options": { | ||
"env": { | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Deploy kyma", | ||
"type": "shell", | ||
"command": "export SKR_HOST=${input:skrHost} && ${cwd}/scripts/tests/deploy_kyma.sh", | ||
"options": { | ||
"env": { | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Un-Deploy kyma", | ||
"type": "shell", | ||
"command": "kubectl -n kcp-system delete kyma kyma-sample; kubectl -n kcp-system delete secret kyma-sample", | ||
"options": { | ||
"env": { | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "E2E Tests", | ||
"type": "shell", | ||
"command": "make -C ${cwd}/tests/e2e ${input:e2eTestTarget}", | ||
"group": { | ||
"kind": "test" | ||
}, | ||
"options": { | ||
"env": { | ||
"KCP_KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml", | ||
"SKR_KUBECONFIG": "${env:HOME}/.k3d/skr-local.yaml" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Install CRDs", | ||
"type": "shell", | ||
"command": "make install", | ||
"options": { | ||
"env": { | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
// re-run if encountering error that the watcher CRD is missing | ||
{ | ||
"label": "Deploy KLM from registry", | ||
"type": "shell", | ||
"command": "make local-deploy-with-watcher IMG=${IMG_REGISTRY_HOST}/${input:klmImageRegistry}/${IMG_NAME}:${input:klmImageTag}", | ||
"options": { | ||
"env": { | ||
"IMG_REGISTRY_HOST": "europe-docker.pkg.dev/kyma-project", | ||
"IMG_NAME": "lifecycle-manager", | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml", | ||
], | ||
"inputs": [ | ||
{ | ||
// not all of the options work OOTB, see deploy-lifecycle-manager-e2e action.yaml for specific patches | ||
"id": "e2eTestTarget", | ||
"type": "pickString", | ||
"description": "E2E test target", | ||
"options": [ | ||
"watcher-enqueue", | ||
"rbac-privileges", | ||
"kyma-deprovision-with-foreground-propagation", | ||
"kyma-deprovision-with-background-propagation", | ||
"module-status-decoupling-with-statefulset", | ||
"module-status-decoupling-with-deployment", | ||
"kyma-metrics", | ||
"module-without-default-cr", | ||
"module-consistency", | ||
"non-blocking-deletion", | ||
"upgrade-under-deletion", | ||
"purge-controller", | ||
"purge-metrics", | ||
"module-upgrade-channel-switch", | ||
"module-upgrade-new-version", | ||
"unmanage-module", | ||
"skip-manifest-reconciliation", | ||
"ca-certificate-rotation", | ||
"self-signed-certificate-rotation", | ||
"mandatory-module", | ||
"mandatory-module-metrics", | ||
"misconfigured-kyma-secret", | ||
"ocm-compatible-module-template" | ||
] | ||
}, | ||
{ | ||
"id": "templateOperatorVersion", | ||
"type": "pickString", | ||
"description": "Template-operator manifest", | ||
"options": [ | ||
"mandatory_moduletemplate_template_operator_v1.yaml", | ||
"mandatory_moduletemplate_template_operator_v2.yaml", | ||
"moduletemplate_template_operator_regular_new_ocm.yaml", | ||
"moduletemplate_template_operator_v1_regular.yaml", | ||
"moduletemplate_template_operator_v2_fast.yaml", | ||
"moduletemplate_template_operator_v2_regular_new_version.yaml" | ||
] | ||
}, | ||
{ | ||
"id": "klmImageRegistry", | ||
"type": "pickString", | ||
"description": "Registry of KLM image", | ||
"options": ["dev", "prod"] | ||
}, | ||
{ | ||
"id": "klmImageTag", | ||
"type": "promptString", | ||
"description": "Tag of the KLM image, e.g. 'latest'" | ||
}, | ||
{ | ||
"id": "skrHost", | ||
"type": "pickString", | ||
"description": "Host of the SKR", | ||
"options": [ | ||
// use host.k3d.internal when deploying KLM into the cluster | ||
"host.k3d.internal", | ||
// use localhost when running KLM locally on the machine | ||
"localhost" | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Deploy template-operator", | ||
"type": "shell", | ||
"command": "kubectl apply -f ${cwd}/tests/e2e/moduletemplate/${input:templateOperatorVersion}", | ||
"options": { | ||
"env": { | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Deploy kyma", | ||
"type": "shell", | ||
"command": "export SKR_HOST=${input:skrHost} && ${cwd}/scripts/tests/deploy_kyma.sh", | ||
"options": { | ||
"env": { | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml", | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Un-Deploy kyma", | ||
"type": "shell", | ||
"command": "kubectl -n kcp-system delete kyma kyma-sample; kubectl -n kcp-system delete secret kyma-sample", | ||
"options": { | ||
"env": { | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml", | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "E2E Tests", | ||
"type": "shell", | ||
"command": "make -C ${cwd}/tests/e2e ${input:e2eTestTarget}", | ||
"group": { | ||
"kind": "test" | ||
}, | ||
"options": { | ||
"env": { | ||
"KCP_KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml", | ||
"SKR_KUBECONFIG": "${env:HOME}/.k3d/skr-local.yaml" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Install CRDs", | ||
"type": "shell", | ||
"command": "make install", | ||
"options": { | ||
"env": { | ||
"KUBECONFIG": "${env:HOME}/.k3d/kcp-local.yaml", | ||
} | ||
} | ||
} | ||
], | ||
"inputs": [ | ||
{ | ||
// not all of the options work OOTB, see deploy-lifecycle-manager-e2e action.yaml for specific patches | ||
"id": "e2eTestTarget", | ||
"type": "pickString", | ||
"description": "E2E test target", | ||
"options": [ | ||
"watcher-enqueue", | ||
"rbac-privileges", | ||
"kyma-deprovision-with-foreground-propagation", | ||
"kyma-deprovision-with-background-propagation", | ||
"module-status-decoupling-with-statefulset", | ||
"module-status-decoupling-with-deployment", | ||
"kyma-metrics", | ||
"module-without-default-cr", | ||
"module-consistency", | ||
"non-blocking-deletion", | ||
"upgrade-under-deletion", | ||
"purge-controller", | ||
"purge-metrics", | ||
"module-upgrade-channel-switch", | ||
"module-upgrade-new-version", | ||
"unmanage-module", | ||
"skip-manifest-reconciliation", | ||
"ca-certificate-rotation", | ||
"self-signed-certificate-rotation", | ||
"mandatory-module", | ||
"mandatory-module-metrics", | ||
"misconfigured-kyma-secret", | ||
"ocm-compatible-module-template", | ||
] | ||
}, | ||
{ | ||
"id": "templateOperatorVersion", | ||
"type": "pickString", | ||
"description": "Template-operator manifest", | ||
"options": [ | ||
"mandatory_moduletemplate_template_operator_v1.yaml", | ||
"mandatory_moduletemplate_template_operator_v2.yaml", | ||
"moduletemplate_template_operator_regular_new_ocm.yaml", | ||
"moduletemplate_template_operator_v1_regular.yaml", | ||
"moduletemplate_template_operator_v2_fast.yaml", | ||
"moduletemplate_template_operator_v2_regular_new_version.yaml" | ||
] | ||
}, | ||
{ | ||
"id": "klmImageRegistry", | ||
"type": "pickString", | ||
"description": "Registry of KLM image", | ||
"options": [ | ||
"dev", | ||
"prod" | ||
] | ||
}, | ||
{ | ||
"id": "klmImageTag", | ||
"type": "promptString", | ||
"description": "Tag of the KLM image, e.g. 'latest'", | ||
}, | ||
{ | ||
"id": "skrHost", | ||
"type": "pickString", | ||
"description": "Host of the SKR", | ||
"options": [ | ||
// use host.k3d.internal when deploying KLM into the cluster | ||
"host.k3d.internal", | ||
// use localhost when running KLM locally on the machine | ||
"localhost" | ||
] | ||
}, | ||
] | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
amritanshusikdar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this is a script now, we can reference it in the tasks.json as well as the Delete Test Clusters.run.xml instead of running the command there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I try to run this script (and the new ones), I get permission denied. I think you need to run chmod +x <script_name> for each |
||
# Remove the k3d cluster and the skr cluster | ||
k3d cluster rm kcp skr | ||
|
||
echo "[$(basename $0)] Cleanup completed" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,15 @@ | |
# Change to the directory where the script is located | ||
cd "$(dirname "$0")" | ||
|
||
./../version.sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this should be optional, may be add a new argument to the script to have the option to validate the version or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since version incompatibility issues are quite common and not always the most intuitive to detect, I'd rather have this as the implied way and instead introduce a flag |
||
if [ $? -ne 0 ]; then | ||
echo "[$(basename $0)] Versioning check failed. Exiting..." | ||
exit 1 | ||
fi | ||
|
||
# create SKR cluster | ||
if k3d cluster list | grep -q "^skr\s"; then | ||
echo "Reusing existing SKR cluster..." | ||
echo "[$(basename $0)] Reusing existing SKR cluster..." | ||
else | ||
k3d cluster create skr \ | ||
-p 10080:80@loadbalancer \ | ||
|
@@ -19,7 +25,7 @@ fi | |
|
||
# create KCP cluster | ||
if k3d cluster list | grep -q "^kcp\s"; then | ||
echo "Reusing existing KCP cluster..." | ||
echo "[$(basename $0)] Reusing existing KCP cluster..." | ||
else | ||
k3d cluster create kcp \ | ||
-p 9443:443@loadbalancer \ | ||
|
@@ -51,3 +57,6 @@ fi | |
# export kubeconfigs | ||
k3d kubeconfig get skr > ~/.k3d/skr-local.yaml | ||
k3d kubeconfig get kcp > ~/.k3d/kcp-local.yaml | ||
echo "[$(basename $0)] Kubeconfig for SKR and KCP exported successfully" | ||
|
||
echo "[$(basename $0)] Test clusters created successfully" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are the changes here?