Skip to content

Commit

Permalink
fix: scripts (#1263)
Browse files Browse the repository at this point in the history
  • Loading branch information
aneojgurhem authored Feb 19, 2024
2 parents 5b8717a + dff0483 commit ceae55f
Show file tree
Hide file tree
Showing 39 changed files with 192 additions and 193 deletions.
30 changes: 15 additions & 15 deletions infrastructure/utils/scripts/deploy-dev-test-infra.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#! /bin/bash
#! /usr/bin/env bash

BASEDIR=$(dirname "$0")
BASEDIR="$(dirname "$0")"
pushd "${BASEDIR}"
BASEDIR=$(pwd -P)
BASEDIR="$(pwd -P)"
popd

MODE=""
CLEAN=""
NAMESPACE="armonik"
HOST_PATH=$(realpath "${HOME}/data")
HOST_PATH="$(realpath "${HOME}/data")"
SERVER_NFS_IP=""
SHARED_STORAGE_TYPE="HostPath"
SOURCE_CODES_LOCALHOST_DIR=$(realpath "${BASEDIR}/../../quick-deploy/localhost")
MODIFY_PARAMETERS_SCRIPT=$(realpath "${BASEDIR}/../../../tools/modify_parameters.py")
SOURCE_CODES_LOCALHOST_DIR="$(realpath "${BASEDIR}/../../quick-deploy/localhost")"
MODIFY_PARAMETERS_SCRIPT="$(realpath "${BASEDIR}/../../../tools/modify_parameters.py")"
CONTROL_PLANE_IMAGE="dockerhubaneo/armonik_control"
POLLING_AGENT_IMAGE="dockerhubaneo/armonik_pollingagent"
WORKER_IMAGE="dockerhubaneo/armonik_worker_dll"
Expand Down Expand Up @@ -79,7 +79,7 @@ function execute() {
echo -e "${GREEN}[EXEC] : $@${NC}"
err=0
if [[ $DRY_RUN == 0 ]]; then
$@
"$@"
onexit
fi
}
Expand Down Expand Up @@ -198,7 +198,7 @@ set_envvars() {

# Create shared storage
create_host_path() {
STORAGE_TYPE=$(echo "${SHARED_STORAGE_TYPE}" | awk '{print tolower($0)}')
STORAGE_TYPE="$(echo "${SHARED_STORAGE_TYPE}" | awk '{print tolower($0)}')"
if [ "${STORAGE_TYPE}" == "hostpath" ]; then
mkdir -p "${HOST_PATH}"
fi
Expand All @@ -212,7 +212,7 @@ create_kubernetes_namespace() {

# Check if KEDA is deployed
check_keda_instance() {
KEDA=$(kubectl get deploy -A -l app=keda-operator --no-headers=true -o name)
KEDA="$(kubectl get deploy -A -l app=keda-operator --no-headers=true -o name)"
if [ -z "${KEDA}" ]; then
echo 0
else
Expand All @@ -222,7 +222,7 @@ check_keda_instance() {

# Check if Metrics server is deployed
check_metrics_server_instance() {
METRICS_SERVER=$(kubectl get deploy -A -l k8s-app=metrics-server --no-headers=true -o name)
METRICS_SERVER="$(kubectl get deploy -A -l k8s-app=metrics-server --no-headers=true -o name)"
if [ -z "${METRICS_SERVER}" ]; then
echo 0
else
Expand All @@ -232,7 +232,7 @@ check_metrics_server_instance() {

# Prepare storage parameters
prepare_storage_parameters() {
STORAGE_TYPE=$(echo "${SHARED_STORAGE_TYPE}" | awk '{print tolower($0)}')
STORAGE_TYPE="$(echo "${SHARED_STORAGE_TYPE}" | awk '{print tolower($0)}')"
python3 "${MODIFY_PARAMETERS_SCRIPT}" \
-kv shared_storage.file_storage_type="${STORAGE_TYPE}" \
-kv shared_storage.file_server_ip="${SERVER_NFS_IP}" \
Expand Down Expand Up @@ -321,7 +321,7 @@ deploy_armonik() {

# Deploy KEDA
deploy_keda() {
if [ $(check_keda_instance) -eq 0 ]; then
if [ "$(check_keda_instance)" -eq 0 ]; then
prepare_keda_parameters
cd "${SOURCE_CODES_LOCALHOST_DIR}"
echo "Deploying KEDA..."
Expand All @@ -333,7 +333,7 @@ deploy_keda() {

# Deploy Metrics server
deploy_metrics_server() {
if [ $(check_metrics_server_instance) -eq 0 ]; then
if [ "$(check_metrics_server_instance)" -eq 0 ]; then
prepare_metrics_server_parameters
cd "${SOURCE_CODES_LOCALHOST_DIR}"
echo "Deploying Metrics server..."
Expand Down Expand Up @@ -502,7 +502,7 @@ clean_all() {
# Main
function main() {
for i in "$@"; do
case $i in
case "$i" in
-h | --help)
usage
exit
Expand Down Expand Up @@ -740,4 +740,4 @@ function main() {
fi
}

main $@
main "$@"
8 changes: 4 additions & 4 deletions infrastructure/utils/scripts/get_node_ip.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /bin/bash
#! /bin/sh
# Exit if any of the intermediate steps fail
set -e

NODE_NAME=$(kubectl get pods --selector="service=$1" -n $2 -o custom-columns="NODE:.spec.nodeName" --no-headers=true)
NODE_IP=$(kubectl get nodes -o wide --no-headers=true | grep -w $NODE_NAME | awk '{print $6}')
NODE_NAME="$(kubectl get pods --selector="service=$1" -n $2 -o custom-columns="NODE:.spec.nodeName" --no-headers=true)"
NODE_IP="$(kubectl get nodes -o wide --no-headers=true | grep -w "$NODE_NAME" | awk '{print $6}')"

jq -n --arg node_ip "$NODE_IP" '{"node_ip":$node_ip}'
jq -n --arg node_ip "$NODE_IP" '{"node_ip":$node_ip}'
Empty file modified infrastructure/utils/scripts/installation/install-genie.sh
100644 → 100755
Empty file.
28 changes: 14 additions & 14 deletions infrastructure/utils/scripts/installation/prerequisites-installer.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /usr/bin/env bash

# Exit immediately if a command exits with a non-zero status.
set -e
Expand All @@ -10,66 +10,66 @@ lsb_release -d -s
DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"

# Get the pre-requisites directory
DIR=$DIR/prerequisites
DIR="$DIR/prerequisites"

# Update packages
echo "Updating packages"
$DIR/update-packages.sh
"$DIR/update-packages.sh"
echo "Packages updated"

# Install git
echo "Installing git"
$DIR/install-git.sh
"$DIR/install-git.sh"
echo "Git installed"

# Install jq
echo "Installing jq"
$DIR/install-jq.sh
"$DIR/install-jq.sh"
echo "Jq installed"

# Install make
echo "Installing make"
$DIR/install-make.sh
"$DIR/install-make.sh"
echo "Make installed"

# Install python3
echo "Installing python3"
$DIR/install-python3.sh
"$DIR/install-python3.sh"
echo "Python3 installed"

# Install pip3
echo "Installing pip3"
$DIR/install-pip3.sh
"$DIR/install-pip3.sh"
echo "Pip3 installed"

# Install helm
echo "Installing helm"
$DIR/install-helm.sh
"$DIR/install-helm.sh"
echo "Helm installed"

# Install docker
echo "Installing docker"
$DIR/install-docker.sh
"$DIR/install-docker.sh"
echo "Docker installed"

# Install kubectl
echo "Installing kubectl"
$DIR/install-kubectl.sh
"$DIR/install-kubectl.sh"
echo "Kubectl installed"

# Install terraform
echo "Installing terraform"
$DIR/install-terraform.sh
"$DIR/install-terraform.sh"
echo "Terraform installed"

# Install k3s
echo "Installing k3s"
$DIR/install-k3s.sh
"$DIR/install-k3s.sh"
echo "K3s installed"

# Install dotnet
echo "Installing dotnet"
$DIR/install-dotnet.sh
"$DIR/install-dotnet.sh"
echo "Dotnet installed"

# Remove unused packages
Expand Down
15 changes: 2 additions & 13 deletions infrastructure/utils/scripts/installation/prerequisites/install-docker.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
#!/bin/bash
#! /bin/sh
# This script is used to install docker

# https://docs.docker.com/engine/install/ubuntu/
sudo apt update

sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --yes --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update

sudo apt install -y docker-ce
sudo apt install docker.io
2 changes: 1 addition & 1 deletion infrastructure/utils/scripts/installation/prerequisites/install-dotnet.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /bin/sh
# This script is used to install dotnet.

# https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/utils/scripts/installation/prerequisites/install-git.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /bin/sh
# This script is used to install git.

sudo apt install -y git
2 changes: 1 addition & 1 deletion infrastructure/utils/scripts/installation/prerequisites/install-helm.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /bin/sh
# This script is used to install helm.

curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/utils/scripts/installation/prerequisites/install-jq.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /bin/sh

# This script is used to install jq.

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/utils/scripts/installation/prerequisites/install-k3s.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /bin/sh
# This script is used to install k3s.

curl -sfL https://get.k3s.io |sh -s - --write-kubeconfig-mode 644 --docker --write-kubeconfig ~/.kube/config --kubelet-arg cgroup-driver=systemd
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/utils/scripts/installation/prerequisites/install-kubectl.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /bin/sh
# This script is used to install kubectl.

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/utils/scripts/installation/prerequisites/install-make.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /bin/sh

# This script is used to install make.

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/utils/scripts/installation/prerequisites/install-pip3.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /bin/sh
# This script is used to install pip3.

sudo apt install -y python3-pip
2 changes: 1 addition & 1 deletion infrastructure/utils/scripts/installation/prerequisites/install-python3.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /bin/sh
# This script is used to install python3.

sudo apt install -y python3
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/utils/scripts/installation/prerequisites/install-terraform.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /bin/sh
# This script is used to install terraform.

# https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/utils/scripts/installation/prerequisites/update-packages.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#! /bin/sh
# This script is used to update packages.

sudo apt update && sudo apt -y upgrade
8 changes: 4 additions & 4 deletions infrastructure/utils/scripts/k8s_config.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /bin/bash
#! /usr/bin/env bash
# Exit if any of the intermediate steps fail
set -e

eval kubefilelocation=$1 # ~ expand does not work in terraform so we expend it manually
CONFIG_CONTEXT=$(kubectl --kubeconfig "$kubefilelocation" config current-context)
eval "kubefilelocation=$1" # ~ expand does not work in terraform so we expend it manually
CONFIG_CONTEXT="$(kubectl --kubeconfig "$kubefilelocation" config current-context)"

jq -n --arg k8s_config_context "$CONFIG_CONTEXT" '{"k8s_config_context":$k8s_config_context}'
jq -n --arg k8s_config_context "$CONFIG_CONTEXT" '{"k8s_config_context":$k8s_config_context}'
10 changes: 6 additions & 4 deletions tools/access-mongo-as-admin.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#! /bin/sh

# ACESS to monogodb as admin
MPASS=$(kubectl get secret -n armonik mongodb-admin -o jsonpath="{.data.password}" | base64 --decode)
MUSER=$(kubectl get secret -n armonik mongodb-admin -o jsonpath="{.data.username}" | base64 --decode)
MPASS="$(kubectl get secret -n armonik mongodb-admin -o jsonpath="{.data.password}" | base64 --decode)"
MUSER="$(kubectl get secret -n armonik mongodb-admin -o jsonpath="{.data.username}" | base64 --decode)"
kubectl get secret -n armonik mongodb-user-certificates -o jsonpath="{.data.chain\.pem}" | base64 --decode > ./mongodb_chain.pem
MONGO_IP=$(kubectl get svc mongodb-0 -n armonik -o custom-columns="IP:.spec.clusterIP" --no-headers=true)
docker run -it -v $(pwd)/mongodb_chain.pem:/chain.pem --rm rtsp/mongosh mongosh --tlsCAFile /chain.pem --tlsAllowInvalidCertificates --tlsAllowInvalidHostnames --tls -u $MUSER -p $MPASS mongodb://$MONGO_IP:27017
MONGO_IP="$(kubectl get svc mongodb-0 -n armonik -o custom-columns="IP:.spec.clusterIP" --no-headers=true)"
docker run -it -v "$(pwd)/mongodb_chain.pem:/chain.pem" --rm rtsp/mongosh mongosh --tlsCAFile /chain.pem --tlsAllowInvalidCertificates --tlsAllowInvalidHostnames --tls -u "$MUSER" -p "$MPASS" "mongodb://$MONGO_IP:27017"
10 changes: 6 additions & 4 deletions tools/access-mongo-as-user.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#! /bin/sh

# ACESS to monogodb as user
MPASS=$(kubectl get secret -n armonik mongodb-user -o jsonpath="{.data.password}" | base64 --decode)
MUSER=$(kubectl get secret -n armonik mongodb-user -o jsonpath="{.data.username}" | base64 --decode)
MPASS="$(kubectl get secret -n armonik mongodb-user -o jsonpath="{.data.password}" | base64 --decode)"
MUSER="$(kubectl get secret -n armonik mongodb-user -o jsonpath="{.data.username}" | base64 --decode)"
kubectl get secret -n armonik mongodb-user-certificates -o jsonpath="{.data.chain\.pem}" | base64 --decode > ./mongodb_chain.pem
MONGO_IP=$(kubectl get svc mongodb-0 -n armonik -o custom-columns="IP:.spec.clusterIP" --no-headers=true)
docker run -it -v $(pwd)/mongodb_chain.pem:/chain.pem --rm rtsp/mongosh mongosh --tlsCAFile /chain.pem --tlsAllowInvalidCertificates --tlsAllowInvalidHostnames --tls -u $MUSER -p $MPASS mongodb://$MONGO_IP:27017/database #--eval 'db.serverStatus()'
MONGO_IP="$(kubectl get svc mongodb-0 -n armonik -o custom-columns="IP:.spec.clusterIP" --no-headers=true)"
docker run -it -v "$(pwd)/mongodb_chain.pem:/chain.pem" --rm rtsp/mongosh mongosh --tlsCAFile /chain.pem --tlsAllowInvalidCertificates --tlsAllowInvalidHostnames --tls -u "$MUSER" -p "$MPASS" "mongodb://$MONGO_IP:27017/database" #--eval 'db.serverStatus()'
Empty file modified tools/access-mongo-from-kubernetes-as-admin.sh
100644 → 100755
Empty file.
Loading

0 comments on commit ceae55f

Please sign in to comment.