From 914b05911c6a5c69f2918a97e3d44b7906e8a694 Mon Sep 17 00:00:00 2001 From: Daniel Mikula Date: Mon, 15 May 2023 09:44:07 +0200 Subject: [PATCH 1/9] added basic interface --- setup.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 setup.sh diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..b25526f --- /dev/null +++ b/setup.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# Author : NTT Data AG +# Date : 11-05-2023 + +show_help () { + echo "Usage: $0 [-m helm_install: bool] [-a app_name: str]" +} + +helm_install=false +app_name="" + +while getopts "hm:a:" option; do + case $option in + h) + show_help + exit 1 + ;; + m) + helm_install="$OPTARG" + ;; + a) + app_name="$OPTARG" + ;; + *) + show_help + exit 1 + ;; + esac +done + +if [ "$helm_install" = "true" ]; then + echo "Installing helm" +fi + +if [ -z "$app_name" ]; then + echo "Please specify app" +else + echo "Installing $app_name" +fi \ No newline at end of file From fb4deeea451280fe1fe8fdf0a01f4caad0798321 Mon Sep 17 00:00:00 2001 From: Daniel Mikula Date: Mon, 15 May 2023 09:51:47 +0200 Subject: [PATCH 2/9] updated help function --- setup.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index b25526f..7aab52a 100755 --- a/setup.sh +++ b/setup.sh @@ -3,8 +3,11 @@ # Author : NTT Data AG # Date : 11-05-2023 -show_help () { - echo "Usage: $0 [-m helm_install: bool] [-a app_name: str]" +show_help() { + echo "Usage: $0 [-m] [-a ]" + echo "Options:" + echo " -m Install helm" + echo " -a Specify the app name" } helm_install=false From dc16660e00bcaf616d79c2588906cd84268aa924 Mon Sep 17 00:00:00 2001 From: Daniel Mikula Date: Mon, 15 May 2023 10:03:26 +0200 Subject: [PATCH 3/9] updated help --- setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index 7aab52a..230eccb 100755 --- a/setup.sh +++ b/setup.sh @@ -4,9 +4,9 @@ # Date : 11-05-2023 show_help() { - echo "Usage: $0 [-m] [-a ]" + echo "Usage: $0 [-m ] [-a ]" echo "Options:" - echo " -m Install helm" + echo " -m Install helm" echo " -a Specify the app name" } @@ -17,7 +17,7 @@ while getopts "hm:a:" option; do case $option in h) show_help - exit 1 + exit 0 ;; m) helm_install="$OPTARG" From 8f3e5f14c789d70771644d2a089af5002d9ea675 Mon Sep 17 00:00:00 2001 From: Daniel Mikula Date: Mon, 15 May 2023 11:26:38 +0200 Subject: [PATCH 4/9] added short options --- setup.sh | 66 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/setup.sh b/setup.sh index 230eccb..89291ea 100755 --- a/setup.sh +++ b/setup.sh @@ -3,41 +3,75 @@ # Author : NTT Data AG # Date : 11-05-2023 -show_help() { - echo "Usage: $0 [-m ] [-a ]" - echo "Options:" - echo " -m Install helm" - echo " -a Specify the app name" -} - helm_install=false app_name="" -while getopts "hm:a:" option; do - case $option in - h) +# fetch helm resources +# docs: https://helm.sh/docs/intro/install/ +install_helm () { + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh +} + +show_help() { + cat < Specify the app name +EOF +} + +while [ "$#" -gt 0 ]; do + case "$1" in + -h|--help) show_help exit 0 ;; - m) - helm_install="$OPTARG" + -m|--helm) + helm_install=true + shift ;; - a) - app_name="$OPTARG" + -a|--app) + if [ "$2" ]; then + app_name="$2" + shift 2 + else + echo "Error: Missing argument for $1 option" + show_help + exit 1 + fi ;; *) + echo "Error: Unrecognized option $1" show_help exit 1 ;; esac done -if [ "$helm_install" = "true" ]; then +# Check if --helm was set +if [ "$helm_install" = true ]; then echo "Installing helm" + # install_helm +else + echo "Skipping helm" fi +# Validate app names if [ -z "$app_name" ]; then echo "Please specify app" else - echo "Installing $app_name" + case $app_name in + "socks_shop") + echo "installing sock shop" + ;; + *) + echo "Only following apps allowed" + exit 1 + ;; + esac fi \ No newline at end of file From 0f232626f2e29e20c52f9262f6cfe1aa799c2848 Mon Sep 17 00:00:00 2001 From: Daniel Mikula Date: Mon, 15 May 2023 15:26:59 +0200 Subject: [PATCH 5/9] flow setup. not tested yet --- setup.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/setup.sh b/setup.sh index 89291ea..6ae5833 100755 --- a/setup.sh +++ b/setup.sh @@ -9,9 +9,43 @@ app_name="" # fetch helm resources # docs: https://helm.sh/docs/intro/install/ install_helm () { - curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 - chmod 700 get_helm.sh - ./get_helm.sh + # curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + # chmod 700 get_helm.sh + # ./get_helm.sh + echo "Helm not support yet." + exit 1 +} + +# install resources +# TODO: check if this works +install_k3s () { + sudo dnf install -y container-selinux + sudo dnf install -y https://rpm.rancher.io/k3s/stable/common/centos/8/noarch/k3s-selinux-1.2-2.el8.noarch.rpm + + get_k3s +} + +# install k3s +# docs: https://docs.k3s.io/installation/configuration +get_k3s () { + sudo curl -sfL https://get.k3s.io | INSTALL_K3S_SYMLINK="skip" K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik" sh - + export KUBECONFIG=/etc/rancher/k3s/k3s.yaml + kubectl get pods -A +} + +# install git +install_git () { + sudo dnf -y update + sudo dnf -y install git +} + +install_sock_shop () { + git clone https://github.com/microservices-demo/microservices-demo.git + cd deploy/kubernetes + kubectl create namespace sock-shop + kubectl apply -f complete-demo.yaml + echo "Getting Pods from sock-shop namespace" + k3s kubectl get pods -n sock-shop } show_help() { @@ -55,22 +89,29 @@ done # Check if --helm was set if [ "$helm_install" = true ]; then - echo "Installing helm" - # install_helm + install_helm else echo "Skipping helm" fi +echo "Installing GIT" +# install_git + +echo "Installing K3S" +# install_k3s + # Validate app names if [ -z "$app_name" ]; then echo "Please specify app" else case $app_name in - "socks_shop") - echo "installing sock shop" + "sock_shop") + echo "Installing sock shop" + install_sock_shop ;; *) echo "Only following apps allowed" + echo "- sock_shop" exit 1 ;; esac From 98583695c4bd7fe432ce4602ba2fe1027c43fcc2 Mon Sep 17 00:00:00 2001 From: Daniel Mikula Date: Mon, 15 May 2023 15:28:41 +0200 Subject: [PATCH 6/9] flow setup. not tested yet --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 6ae5833..5bd5d55 100755 --- a/setup.sh +++ b/setup.sh @@ -45,7 +45,7 @@ install_sock_shop () { kubectl create namespace sock-shop kubectl apply -f complete-demo.yaml echo "Getting Pods from sock-shop namespace" - k3s kubectl get pods -n sock-shop + kubectl get pods -n sock-shop } show_help() { From 9acb0b9bb033ad43452644b891d5283112b18d37 Mon Sep 17 00:00:00 2001 From: Daniel Mikula Date: Mon, 15 May 2023 15:33:19 +0200 Subject: [PATCH 7/9] flow setup. not tested yet --- setup.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 5bd5d55..054810b 100755 --- a/setup.sh +++ b/setup.sh @@ -59,6 +59,14 @@ Options: EOF } +show_allowed_apps () { + cat < Date: Tue, 16 May 2023 06:34:03 +0200 Subject: [PATCH 8/9] added todos --- setup.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 054810b..9ebe99d 100755 --- a/setup.sh +++ b/setup.sh @@ -3,6 +3,8 @@ # Author : NTT Data AG # Date : 11-05-2023 +# TODO: create check for flags. needs to be run first. + helm_install=false app_name="" @@ -41,11 +43,12 @@ install_git () { install_sock_shop () { git clone https://github.com/microservices-demo/microservices-demo.git - cd deploy/kubernetes + cd microservices-demo/deploy/kubernetes kubectl create namespace sock-shop kubectl apply -f complete-demo.yaml echo "Getting Pods from sock-shop namespace" kubectl get pods -n sock-shop + # TODO: create check if list with pods returns and if they are ready } show_help() { @@ -54,7 +57,7 @@ Usage: $0 [options] Options: -h, --help Show help information - -m, --helm Install Helm + -m, --helm Install Helm. Set flag when you want to install helm. -a, --app Specify the app name EOF } From dd880dfa808b18e62d01fe5014990737b172c00d Mon Sep 17 00:00:00 2001 From: Daniel Mikula Date: Tue, 16 May 2023 07:13:41 +0200 Subject: [PATCH 9/9] removed comment --- setup.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/setup.sh b/setup.sh index 9ebe99d..d72e22c 100755 --- a/setup.sh +++ b/setup.sh @@ -3,8 +3,6 @@ # Author : NTT Data AG # Date : 11-05-2023 -# TODO: create check for flags. needs to be run first. - helm_install=false app_name=""