Skip to content
Snippets Groups Projects
Verified Commit 7982718d authored by Lucas Briese's avatar Lucas Briese
Browse files

Merge branch 'dev' into feat/trivyEndpoint

parents 5cee8b49 5b350ad0
No related branches found
No related tags found
1 merge request!52feat/trivyEndpoint
......@@ -68,19 +68,20 @@ IntelliJ Ultimate provides support for Spring Boot and has the best support for
### setup kubernetes
1. [Get the kubernetes version of our cluster:](https://kommone.cva-12889ja7.wizardtales.net/dashboard/c/c-gqst2/explorer#cluster-events)
- e.g. Kubernetes Version: v1.25.12
- the used provider could be relevant later, e.g. RKE1 = Rancher Kubernetes Engine 1
- E.g. Kubernetes Version: v1.25.12
- The used provider could be relevant later, e.g. RKE1 = Rancher Kubernetes Engine 1
2. K8s support only one minor version step, so for 1.25 you can at max use kubectl 1.26 (e.g. v1.26.15)
- install via: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
- depending on your installation route you may need: [github release](https://github.com/kubernetes/kubernetes/releases)
- Install via: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
- Depending on your installation route you may need: [github release](https://github.com/kubernetes/kubernetes/releases)
3. download the KubeConfig file `subcluster1.yaml` from [Rancher dashboard](https://kommone.cva-12889ja7.wizardtales.net/dashboard/c/c-gqst2/explorer)
- use your config via `export KUBECONFIG=/$HOME/Downloads/subcluster1.yaml`
- or providing it via: `--kubeconfig`
- or move/rename this file to `~/.kube/config`
- Easiest way will be to follow the [folder structure](#setup-local-folder-structure) and using the venv which will set KUBECONFIG variable.
- Else use your config via `export KUBECONFIG=/$HOME/Downloads/subcluster1.yaml`
- Or providing it via: `--kubeconfig`
- Or move/rename this file to `~/.kube/config`
4. validate if your config got picked up, is this command successful?: `kubectl --namespace fraunhofer get pods`
- if you using the OpenCoDE venv just use `dev get pods` or `prod get pods`
- If you using the OpenCoDE venv just use `dev get pods` or `prod get pods`
5. (optional) [install bash completion for kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#enable-shell-autocompletion)
- global installation `kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl-1.26`
- Global installation `kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl-1.26`
### verify setup is fine
......
......@@ -47,9 +47,11 @@
else
# need to be manually saved
# live object contains keys which can't be "applied"
liveObject=$("${kctl[@]}" get -f "$file" -o json)
rmKeys='del(.metadata.creationTimestamp, .metadata.managedFields, .metadata.resourceVersion, .metadata.uid, .metadata.selfLink, .metadata.annotations)'
echo "$liveObject" | jq "$rmKeys" > "$backup/${file:2}"
if "${kctl[@]}" get -f "$file"; then # if objects exists in the cluster
liveObject=$("${kctl[@]}" get -f "$file" -o json)
rmKeys='del(.metadata.creationTimestamp, .metadata.managedFields, .metadata.resourceVersion, .metadata.uid, .metadata.selfLink, .metadata.annotations)'
echo "$liveObject" | jq "$rmKeys" > "$backup/${file:2}"
fi
fi
done
}
......@@ -64,11 +66,15 @@
updateImage
# finally deploy
"${kctl[@]}" apply -f .
"${kctl[@]}" annotate -f . kubernetes.io/change-cause="$reason" --overwrite=true
if ! "${kctl[@]}" rollout status -f ./deployment.yaml --watch=true --timeout 300s; then
echo "[warning][deploy.sh] deploy failed"
"$rollback" "$target" "$backup"
exit 1
if "${kctl[@]}" apply -f .; then
"${kctl[@]}" annotate -f . kubernetes.io/change-cause="$reason" --overwrite=true
if ! "${kctl[@]}" rollout status -f ./deployment.yaml --watch=true --timeout 300s; then
echo "[warning][deploy.sh] deploy failed"
"$rollback" "$target" "$backup"
exit 1
fi
else
echo "critical error during deploy, you need to manually revert changes!"
exit 2
fi
)
......@@ -55,6 +55,8 @@ set_alias gradlew "\"$OPENCODE_DATAPROVIDER_FOLDER/gradlew\" --project-dir \"$OP
set_alias compose "docker compose"
set_alias dev "kubectl --namespace=fraunhofer"
set_alias prod "kubectl --namespace=fraunhoferprod"
# else would overwrite bash internal local
set_alias loc "minikube -p opencode kubectl -- --namespace=fraunhofer"
info "reload-venv reload venv file"
function reload-venv() {
......@@ -91,10 +93,15 @@ function venv_exec() {
function namespace-status() {
IFS=':' read -r namespace object < <(venv_parse_args "$@")
echo -e "Namespace:\tPod:\t\t\t\tContainer:\tready:"
venv_exec kubectl --namespace="$namespace" get pods -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{range .status.containerStatuses[*]}{.name}{"\t"}{.ready}{"\n"}{end}{end}'
if [ 'local' = "$1" ]; then
venv_exec minikube -p opencode kubectl -- --namespace="$namespace" get pods -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{range .status.containerStatuses[*]}{.name}{"\t"}{.ready}{"\n"}{end}{end}'
else
venv_exec kubectl --namespace="$namespace" get pods -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{range .status.containerStatuses[*]}{.name}{"\t"}{.ready}{"\n"}{end}{end}'
fi
}
set_alias "dev-status" "namespace-status dev" "show namespace, pods, containers and state"
set_alias "prod-status" "namespace-status prod" "show namespace, pods, containers and state"
set_alias "loc-status" "namespace-status local" "show namespace, pods, containers and state"
function namespace-exec-type() {
IFS=':' read -r namespace object < <(venv_parse_args "$@")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.