Skip to content

Commit ae9726f

Browse files
author
Yuriy Bezsonov
committed
Add eks scripts to agent
1 parent b5a38f2 commit ae9726f

3 files changed

Lines changed: 38 additions & 32 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# eks-agent-build.sh - Script to connect to ECR, build and push image
3+
4+
set -e
5+
6+
echo "Starting build process for Spring AI Agent..."
7+
8+
# Get ECR URI - exit if not found
9+
echo "Getting ECR URI..."
10+
if ! ECR_URI=$(aws ecr describe-repositories --repository-names unicorn-spring-ai-agent | jq --raw-output '.repositories[0].repositoryUri' 2>/dev/null); then
11+
echo "Error: Could not get ECR URI. Repository 'unicorn-spring-ai-agent' may not exist. Exiting."
12+
exit 1
13+
else
14+
echo "ECR URI: $ECR_URI"
15+
fi
16+
17+
# Login to ECR
18+
echo "Logging in to Amazon ECR..."
19+
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_URI
20+
21+
# Navigate to project directory
22+
echo "Navigating to project directory..."
23+
cd ~/environment/unicorn-spring-ai-agent || {
24+
echo "Error: Project directory not found. Exiting."
25+
exit 1
26+
}
27+
28+
# Build and push container image
29+
echo "Building container image..."
30+
mvn spring-boot:build-image -DskipTests -Dspring-boot.build-image.imageName=$ECR_URI:latest
31+
32+
echo "Pushing container image to ECR..."
33+
docker push $ECR_URI:latest

infrastructure/scripts/spring-ai/eks-agent-deploy.sh

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,10 @@
11
#!/bin/bash
2-
# eks-agent-deploy.sh - Script to connect to ECR, build and push image, restart deployment, and show logs
2+
# eks-agent-deploy.sh - Script to restart deployment, and show logs
33

44
set -e
55

66
echo "Starting deployment process for Spring AI Agent..."
77

8-
# Get ECR URI - exit if not found
9-
echo "Getting ECR URI..."
10-
if ! ECR_URI=$(aws ecr describe-repositories --repository-names unicorn-spring-ai-agent | jq --raw-output '.repositories[0].repositoryUri' 2>/dev/null); then
11-
echo "Error: Could not get ECR URI. Repository 'unicorn-spring-ai-agent' may not exist. Exiting."
12-
exit 1
13-
else
14-
echo "ECR URI: $ECR_URI"
15-
fi
16-
17-
# Login to ECR
18-
echo "Logging in to Amazon ECR..."
19-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_URI
20-
21-
# Navigate to project directory
22-
echo "Navigating to project directory..."
23-
cd ~/environment/unicorn-spring-ai-agent || {
24-
echo "Error: Project directory not found. Exiting."
25-
exit 1
26-
}
27-
28-
# Build and push container image
29-
echo "Building container image..."
30-
mvn spring-boot:build-image -DskipTests -Dspring-boot.build-image.imageName=$ECR_URI:latest
31-
32-
echo "Pushing container image to ECR..."
33-
docker push $ECR_URI:latest
34-
358
# Restart deployment by applying a rolling update
369
echo "Restarting deployment..."
3710
kubectl rollout restart deployment unicorn-spring-ai-agent -n unicorn-spring-ai-agent

infrastructure/scripts/spring-ai/eks-agent-setup.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ EOF
171171
kubectl apply -f ~/environment/unicorn-spring-ai-agent/k8s/ingress.yaml
172172

173173
echo "Checking the application status ..."
174-
# kubectl wait deployment unicorn-spring-ai-agent -n unicorn-spring-ai-agent --for condition=Available=True --timeout=120s
175-
# kubectl get deployment unicorn-spring-ai-agent -n unicorn-spring-ai-agent
174+
kubectl wait deployment unicorn-spring-ai-agent -n unicorn-spring-ai-agent --for condition=Available=True --timeout=120s
175+
kubectl get deployment unicorn-spring-ai-agent -n unicorn-spring-ai-agent
176176
SVC_URL=http://$(kubectl get ingress unicorn-spring-ai-agent -n unicorn-spring-ai-agent -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
177-
# while [[ $(curl -s -o /dev/null -w "%{http_code}" $SVC_URL/) != "200" ]]; do echo "Service not yet available ..." && sleep 5; done
177+
while [[ $(curl -s -o /dev/null -w "%{http_code}" $SVC_URL/) != "200" ]]; do echo "Service not yet available ..." && sleep 5; done
178178
echo $SVC_URL
179-
# echo Service is Ready!
179+
echo Service is Ready!

0 commit comments

Comments
 (0)