Compare commits
9 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
bd42907508 | |
|
|
b08fc0bf45 | |
|
|
e7758b5c7f | |
|
|
aeaa2140ab | |
|
|
f19b1d8d5c | |
|
|
153cda919c | |
|
|
e630ba5f8f | |
|
|
ae34e938ce | |
|
|
a5d6439164 |
|
|
@ -0,0 +1,15 @@
|
||||||
|
# New Relic Agent Installer
|
||||||
|
|
||||||
|
Only k8s supported so far. Docker, Linux, Helm already in place but not activated.
|
||||||
|
|
||||||
|
Usage for k8s
|
||||||
|
```
|
||||||
|
./setup.sh -e k8s -a <account_id> -k <api_key> -r <region(EU)> -n <cluster_name>
|
||||||
|
```
|
||||||
|
|
||||||
|
Help:
|
||||||
|
```
|
||||||
|
./setup.sh -h
|
||||||
|
```
|
||||||
|
|
||||||
|
By default the agent gets installed in the ```newrelic``` namespace.
|
||||||
96
script.sh
96
script.sh
|
|
@ -1,96 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
|
|
||||||
# Author : NTT Data AG
|
|
||||||
# Date : 11-05-2023
|
|
||||||
|
|
||||||
|
|
||||||
# update resources
|
|
||||||
function update {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# install necessary packages
|
|
||||||
function install_resources {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# install k3s
|
|
||||||
# docs: https://docs.k3s.io/installation/configuration
|
|
||||||
function 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
|
|
||||||
k3s kubectl get pods -A
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# fetch helm resources
|
|
||||||
# docs: https://helm.sh/docs/intro/install/
|
|
||||||
function 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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
git
|
|
||||||
https://www.liquidweb.com/kb/how-to-install-and-configure-git-on-fedora-22/#:~:text=1%20Introduction.%20Git%20is%20a%20widely%20adopted%2C%20distributed,for%20git.%20Using%20the%20%E2%80%93global%20option...%20More%20
|
|
||||||
|
|
||||||
sudo dnf -y update
|
|
||||||
sudo dnf -y install git
|
|
||||||
|
|
||||||
|
|
||||||
checkout sockshop
|
|
||||||
https://microservices-demo.github.io/deployment/kubernetes-start.html
|
|
||||||
|
|
||||||
git clone https://github.com/microservices-demo/microservices-demo.git
|
|
||||||
k3s kubectl create namespace sock-shop
|
|
||||||
k3s kubectl apply -f complete-demo.yaml
|
|
||||||
|
|
||||||
|
|
||||||
other
|
|
||||||
k3s kubectl get pods -n sock-shop
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function get_k3s {
|
|
||||||
|
|
||||||
write_progress "Installing K3s (${K3SVERSION}) with NGINX instead of Traefik Ingress"
|
|
||||||
|
|
||||||
curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL="${K3SVERSION}" INSTALL_K3S_SYMLINK="skip" K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik" sh -
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set the kubeconfig
|
|
||||||
|
|
||||||
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
|
||||||
|
|
||||||
kubectl get pods -A
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# install ingress nginx
|
|
||||||
|
|
||||||
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
|
|
||||||
|
|
||||||
helm repo update
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "####### EW "
|
|
||||||
|
|
||||||
helm install ingress-nginx ingress-nginx/ingress-nginx --version="${NGINX_INGRESS_VERSION}"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# wait for nginx to be ready
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
245
setup.sh
245
setup.sh
|
|
@ -1,86 +1,107 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Author : NTT Data AG
|
# Author : NTT Data AG
|
||||||
# Date : 11-05-2023
|
# Date : 16-05-2023
|
||||||
|
|
||||||
helm_install=false
|
# Installs New Relic agent on target machine
|
||||||
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
|
|
||||||
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 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() {
|
show_help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $0 [options]
|
Usage: $0 [options]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show help information
|
-h, --help Show help information
|
||||||
-m, --helm Install Helm. Set flag when you want to install helm.
|
-e, --enironment <environment> Set environment for New Relic installation (k8s | helm | docker | linux)
|
||||||
-a, --app <app_name> Specify the app name
|
-a, --account <account_number> Set account id (int)
|
||||||
|
-k, --api-key <api_key> Set API key
|
||||||
|
-r, --region <region> Set New Relic Region (EU)
|
||||||
|
-n, --cluster-name <cluster-name> Set cluster name. Required for k8s
|
||||||
|
-l, --license-key <license-key> Set license key
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
show_allowed_apps () {
|
show_allowed_environments () {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Supported apps:
|
Supported Environments:
|
||||||
- socks_shop
|
- k8s
|
||||||
|
- helm not supported yet
|
||||||
|
- docker not supported yet
|
||||||
|
- linux not supported yet
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environment=""
|
||||||
|
account_id=""
|
||||||
|
api_key=""
|
||||||
|
region=""
|
||||||
|
cluster_name=""
|
||||||
|
license_key=""
|
||||||
|
|
||||||
|
setup_k8s () {
|
||||||
|
curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh \
|
||||||
|
| bash && NEW_RELIC_CLI_SKIP_CORE=1 NR_CLI_CLUSTERNAME=$cluster_name \
|
||||||
|
NR_CLI_NAMESPACE=newrelic NR_CLI_PRIVILEGED=true NR_CLI_LOW_DATA_MODE=true \
|
||||||
|
NR_CLI_KSM=true NR_CLI_KUBE_EVENTS=true NR_CLI_PROMETHEUS_AGENT=true \
|
||||||
|
NR_CLI_PROMETHEUS_AGENT_LOW_DATA_MODE=true NR_CLI_CURATED=false NR_CLI_LOGGING=true \
|
||||||
|
NR_CLI_LOGGING_LOW_DATA_MODE=true NEW_RELIC_API_KEY=$api_key \
|
||||||
|
NEW_RELIC_ACCOUNT_ID=$account_id NEW_RELIC_REGION=$region\
|
||||||
|
/usr/local/bin/newrelic install -n kubernetes-open-source-integration
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_docker () {
|
||||||
|
# docker run \
|
||||||
|
# -d \
|
||||||
|
# --name newrelic-infra \
|
||||||
|
# --network=host \
|
||||||
|
# --cap-add=SYS_PTRACE \
|
||||||
|
# --privileged \
|
||||||
|
# --pid=host \
|
||||||
|
# -v "/:/host:ro" \
|
||||||
|
# -v "/var/run/docker.sock:/var/run/docker.sock" \
|
||||||
|
# -e NRIA_LICENSE_KEY=$license_key \
|
||||||
|
# newrelic/infrastructure:latest
|
||||||
|
echo "Docker not supported yet"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_linux () {
|
||||||
|
# curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash && sudo NEW_RELIC_API_KEY=$api_key NEW_RELIC_ACCOUNT_ID=$account_id NEW_RELIC_REGION=$region /usr/local/bin/newrelic install -y
|
||||||
|
echo "Linux not supported yet"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_helm () {
|
||||||
|
# function ver { printf "%03d%03d" $(echo "$1" | tr '.' ' '); } && \
|
||||||
|
# K8S_VERSION=$(kubectl version --short 2>&1 | grep 'Server Version' | awk -F' v' '{ print $2; }' | awk -F. '{ print $1"."$2; }') && \
|
||||||
|
# if [[ $(ver $K8S_VERSION) -lt $(ver "1.25") ]]; then KSM_IMAGE_VERSION="v2.6.0"; else KSM_IMAGE_VERSION="v2.7.0"; fi && \
|
||||||
|
# helm repo add newrelic https://helm-charts.newrelic.com && helm repo update && \
|
||||||
|
# kubectl create namespace newrelic ; helm upgrade --install newrelic-bundle newrelic/nri-bundle \
|
||||||
|
# --set global.licenseKey=$license_key \
|
||||||
|
# --set global.cluster=$cluster_name \
|
||||||
|
# --namespace=newrelic \
|
||||||
|
# --set newrelic-infrastructure.privileged=true \
|
||||||
|
# --set global.lowDataMode=true \
|
||||||
|
# --set kube-state-metrics.image.tag=${KSM_IMAGE_VERSION} \
|
||||||
|
# --set kube-state-metrics.enabled=true \
|
||||||
|
# --set kubeEvents.enabled=true \
|
||||||
|
# --set newrelic-prometheus-agent.enabled=true \
|
||||||
|
# --set newrelic-prometheus-agent.lowDataMode=true \
|
||||||
|
# --set newrelic-prometheus-agent.config.kubernetes.integrations_filter.enabled=false \
|
||||||
|
# --set logging.enabled=true \
|
||||||
|
# --set newrelic-logging.lowDataMode=true
|
||||||
|
echo "helm not supported yet"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
show_help
|
show_help
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-m|--helm)
|
-e|--environment)
|
||||||
helm_install=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-a|--app)
|
|
||||||
if [ "$2" ]; then
|
if [ "$2" ]; then
|
||||||
app_name="$2"
|
environment="$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
echo "Error: Missing argument for $1 option"
|
echo "Error: Missing argument for $1 option"
|
||||||
|
|
@ -88,6 +109,76 @@ while [ "$#" -gt 0 ]; do
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
-a|--account)
|
||||||
|
if [ "$2" ]; then
|
||||||
|
account_id="$2"
|
||||||
|
shift 2
|
||||||
|
else
|
||||||
|
if [ "$environment" == "k8s" ] || [ "$environment" == "linux"]; then
|
||||||
|
echo "Error: Missing argument for $1 option"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
$account_id = ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-k|--api-key)
|
||||||
|
if [ "$2" ]; then
|
||||||
|
api_key="$2"
|
||||||
|
shift 2
|
||||||
|
else
|
||||||
|
if [ "$environment" == "k8s" ] || [ "$environment" == "linux"]; then
|
||||||
|
echo "Error: Missing argument for $1 option"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
$api_key = ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-r|--region)
|
||||||
|
if [ "$2" ]; then
|
||||||
|
region="$2"
|
||||||
|
shift 2
|
||||||
|
else
|
||||||
|
if [ "$environment" == "k8s" ] || [ "$environment" == "linux"]; then
|
||||||
|
echo "Error: Missing argument for $1 option"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
$region = ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-n|--cluster-name)
|
||||||
|
if [ "$2" ]; then
|
||||||
|
cluster_name="$2"
|
||||||
|
shift 2
|
||||||
|
else
|
||||||
|
if [ "$environment" == "k8s" ] || [ "$environment" == "helm"]; then
|
||||||
|
echo "Error: Missing argument for $1 option"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
$cluster_name = ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-l|--license-key)
|
||||||
|
if [ "$2" ]; then
|
||||||
|
license_key="$2"
|
||||||
|
shift 2
|
||||||
|
else
|
||||||
|
if [ "$environment" == "docker" ] || [ "$environment" == "helm"]; then
|
||||||
|
echo "Error: Missing argument for $1 option"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
$license_key = ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Error: Unrecognized option $1"
|
echo "Error: Unrecognized option $1"
|
||||||
show_help
|
show_help
|
||||||
|
|
@ -96,31 +187,15 @@ while [ "$#" -gt 0 ]; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if --helm was set
|
if [ "$environment" = "k8s" ]; then
|
||||||
if [ "$helm_install" = true ]; then
|
if [ -z "$account_id" ] || [ -z "$api_key" ] || [ -z "$region" ] || [ -z "$cluster_name" ]; then
|
||||||
install_helm
|
echo "Error: Missing required options for k8s environment"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
setup_k8s
|
||||||
else
|
else
|
||||||
echo "Skipping helm"
|
echo "Error: $environment is not supported yet."
|
||||||
fi
|
show_allowed_environments
|
||||||
|
exit 1
|
||||||
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
|
|
||||||
"sock_shop")
|
|
||||||
echo "Installing sock shop"
|
|
||||||
install_sock_shop
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
show_allowed_apps
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
Loading…
Reference in New Issue