Skip to content

Commit a443689

Browse files
committed
wip additions
1 parent 79c860d commit a443689

File tree

2 files changed

+69
-9
lines changed

2 files changed

+69
-9
lines changed

.github/workflows/java-eks-otlp-ocb-test.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,6 @@ jobs:
9090
max_retry: 3
9191
sleep_time: 60
9292

93-
- name: Download enablement script
94-
uses: ./.github/workflows/actions/execute_and_retry
95-
with:
96-
pre-command: "mkdir enablement-script && cd enablement-script"
97-
command: "wget https://raw.githubusercontent.com/jj22ee/application-signals-demo/refs/heads/ocb/scripts/eks/appsignals/enable-app-signals-ocb.sh"
98-
cleanup: "rm -f enable-app-signals-ocb.sh"
99-
post-command: "chmod +x enable-app-signals-ocb.sh"
100-
10193
- name: Configure AWS Credentials
10294
uses: aws-actions/configure-aws-credentials@v4
10395
with:
@@ -192,7 +184,7 @@ jobs:
192184
- name: Install OTel Operator using enablement script
193185
uses: ./.github/workflows/actions/execute_and_retry
194186
with:
195-
command: "${{ env.TEST_RESOURCES_FOLDER }}/enablement-script/enable-app-signals-ocb.sh \
187+
command: "${{ env.TEST_RESOURCES_FOLDER }}/terraform/java/eks-otlp-ocb/util/enable-app-signals-ocb.sh \
196188
${{ env.CLUSTER_NAME }} \
197189
${{ env.E2E_TEST_AWS_REGION }} \
198190
${{ env.SAMPLE_APP_NAMESPACE }}"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
3+
cd "$(dirname "$0")"
4+
5+
CLUSTER_NAME=$1
6+
REGION=$2
7+
NAMESPACE=${3:-default}
8+
echo "Enabling Application Signals for EKS Cluster ${CLUSTER_NAME} in ${REGION} for namespace ${NAMESPACE}"
9+
10+
# Check if the current context points to the new cluster in the correct region
11+
kub_config=$(kubectl config current-context)
12+
if [[ $kub_config != *"$CLUSTER_NAME"* ]] || [[ $kub_config != *"$REGION"* ]]; then
13+
echo "Your current cluster context is not set to $CLUSTER_NAME $REGION. Please switch to the correct context first before running this script"
14+
exit 1
15+
fi
16+
17+
check_if_step_failed_and_exit() {
18+
if [ $? -ne 0 ]; then
19+
echo $1
20+
exit 1
21+
fi
22+
}
23+
24+
check_if_loop_failed_and_exit() {
25+
if [ $1 -ne 0 ]; then
26+
echo $2
27+
exit 1
28+
fi
29+
}
30+
31+
# Check if the namespace exists
32+
kubectl get namespace $NAMESPACE > /dev/null 2>&1
33+
34+
# $? is a special variable that stores the exit status of the last command
35+
if [ $? -ne 0 ]; then
36+
# If namespace does not exist, create it
37+
echo "Namespace '$NAMESPACE' does not exist. Creating it..."
38+
kubectl create namespace $NAMESPACE
39+
else
40+
# If namespace exists, print a message
41+
echo "Namespace '$NAMESPACE' already exists."
42+
fi
43+
44+
# Create service linked role in the account
45+
aws iam create-service-linked-role --aws-service-name application-signals.cloudwatch.amazonaws.com
46+
47+
# Enable OIDC to allow IAM role authN/Z with service account
48+
eksctl utils associate-iam-oidc-provider --cluster ${CLUSTER_NAME} --region ${REGION} --approve
49+
check_if_step_failed_and_exit "There was an error enabling the OIDC, exiting"
50+
51+
# Create Service Account with the proper IAM permissions
52+
echo "Creating ServiceAccount"
53+
eksctl create iamserviceaccount \
54+
--name appsignals-collector \
55+
--namespace ${NAMESPACE} \
56+
--cluster ${CLUSTER_NAME} \
57+
--region ${REGION} \
58+
--attach-policy-arn arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess \
59+
--attach-policy-arn arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy \
60+
--attach-policy-arn arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy \
61+
--approve \
62+
--override-existing-serviceaccounts
63+
check_if_step_failed_and_exit "There was an error creating the ServiceAccount, exiting"
64+
65+
66+
# Install OpenTelemetry Operator
67+
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.12.0/cert-manager.yaml
68+
kubectl apply -f https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml

0 commit comments

Comments
 (0)