Skip to content

Add windows instructions #2

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@
4. Please make sure **Kubernetes CLI** (`kubernetes-cli`/`kubectl`) is installed.
See [here](https://kubernetes.io/docs/tasks/tools/) for details.

## Windows Preparation
1. Install chocolatey
```bash
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
```
2. Install Git for Windows
```bash
choco install git
```
3. Install Maven [if not installed]
```bash
choco install maven
```
4. Install JDK [if not installed]
```bash
choco install jdk8
```

> [!WARNING]
> For the **Windows** environment, please make sure you are running the commands in **Git Bash**. Otherwise, the scripts below will not work as expected.
>
> Open **Git Bash** and go to the directory where the scripts are located.

## Setup with OpenTelemetry From the Beginning
This setup shows how you can install OpenTelemetry resources into Kubernetes first and deploy application later then.
So deployed applications will be auto instrumented.
Expand Down
2 changes: 2 additions & 0 deletions otel/instrumentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ spec:
value: otlp
- name: OTEL_EXPORTER_OTLP_PROTOCOL
value: grpc
- name: OTEL_METRICS_EXPORTER
value: none
55 changes: 44 additions & 11 deletions otel/setup-otel.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,62 @@
#!/bin/bash

function check_command() {
if [ $? -ne 0 ]; then
echo: "Last command failed"
exit 1
fi
if [ $? -ne 0 ]; then
echo: "Last command failed"
exit 1
fi
}

function apply_manifest() {
echo "Applying manifest $1 ..."
kubectl apply -f $1
echo "Applying manifest $1 ..."
kubectl apply -f $1
}

function check_service_status() {
SERVICE_PREFIX=$1
EXPECTED_COUNT=$2
SERVICES=$(kubectl get pods --all-namespaces -o json | jq -r --arg prefix "$SERVICE_PREFIX" '.items[] | select(.metadata.name | startswith($prefix)) | select(.status.phase == "Running") | "\(.metadata.namespace) \(.metadata.name) \(.status.phase)"')
SERVICE_COUNT=$(echo "$SERVICES" | wc -l)
if [ $SERVICE_COUNT -ne $EXPECTED_COUNT ]; then
SERVICES=""
fi
echo "$SERVICES"
}


echo "Installing certificate manager ..."
echo "================================================================================"
while ! kubectl get namespace cert-manager &> /dev/null;
do
apply_manifest https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml
sleep 5
sleep 10
done
check_command
SERVICES=$(check_service_status "cert-manager" 3)
while [ -z "$SERVICES" ];
do
echo "Waiting for cert-manager services to be ready ..."
SERVICES=$(check_service_status "cert-manager" 3)
sleep 15
done
echo "================================================================================"
echo "Installed certificate manager"

echo "Installing OpenTelemetry operator ..."
echo "================================================================================"
while ! kubectl get namespace opentelemetry-operator-system &> /dev/null;
do
apply_manifest https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml
sleep 5
apply_manifest https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml
sleep 10
done
check_command
SERVICES=$(check_command "opentelemetry-operator-controller" 1)
while [ -z "$SERVICES" ];
do
echo "Waiting for OpenTelemetry operator services to be ready ..."
SERVICES=$(check_service_status "opentelemetry-operator-controller" 1)
sleep 15
done
echo "================================================================================"
echo "Installed OpenTelemetry operator"
kubectl config set-context --current --namespace=opentelemetry-operator-system
Expand All @@ -41,9 +67,16 @@ echo "==========================================================================
while ! kubectl get opentelemetrycollector otel -o jsonpath='{.metadata.name}' &> /dev/null;
do
apply_manifest otel/collector.yaml
sleep 5
sleep 15
done
check_command
SERVICES=$(check_service_status "otel-collector" 1)
while [ -z "$SERVICES" ];
do
echo "Waiting for OpenTelemetry collector services to be ready ..."
SERVICES=$(check_service_status "otel-collector" 1)
sleep 15
done
echo "================================================================================"
echo "Created OpenTelemetry collector"

Expand All @@ -52,7 +85,7 @@ echo "==========================================================================
while ! kubectl get instrumentation otel-instrumentation -o jsonpath='{.metadata.name}' &> /dev/null;
do
apply_manifest otel/instrumentation.yaml
sleep 5
sleep 15
done
check_command
echo "================================================================================"
Expand Down