Skip to content

Commit ea0b1b1

Browse files
committed
feat: move GitLab from EKS to EC2 docker-compose
- Disable GitLab ArgoCD addon (enabled-addons, hub-config, platform.yaml registry) - Remove Keycloak SSO client for GitLab - Remove gitlab-nlb/gitlab-distribution Taskfile.cloudfront.yaml tasks - Add gitlab:init-ec2 task: wait for CE readiness, create root token, user1, repos - Replace k8s Job wait in clone-repos with CF readiness poll - GITLAB_DOMAIN_INT uses EC2 private IP for in-cluster ArgoCD git access - Remove git_token from seed-secrets (seeded by CDK at deploy time) Refs #754
1 parent 2ed034d commit ea0b1b1

33 files changed

Lines changed: 1778 additions & 444 deletions

File tree

Taskfile.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ includes:
2525
vars:
2626
CONFIG_FILE: "{{.CONFIG_FILE}}"
2727
optional: true
28+
workshop:
29+
taskfile: ./cluster-providers/workshop/Taskfile.yaml
30+
dir: ./cluster-providers/workshop
31+
vars:
32+
CONFIG_FILE: "{{.CONFIG_FILE}}"
33+
ROOT_DIR: "{{.ROOT_DIR}}"
34+
optional: true
2835

2936
tasks:
3037
default:

applications/java/deployment/templates/kro/application.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ spec:
2121
enabled: true
2222
path: /java-app
2323
rewrite: true
24-
healthcheckPath: /java-app/
2524
functionalGate:
2625
enabled: true
2726
image: "httpd:alpine"

applications/java/kargo/deploy-kargo.sh

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,6 @@ if [[ -z "$AWS_ACCOUNT_ID" || -z "$AWS_REGION" || -z "$GITLAB_URL" || -z "$GIT_U
1818
exit 1
1919
fi
2020

21-
# Ensure the Kargo controller has ECR read access so the warehouse can discover images.
22-
# Creates the IAM role + pod identity association (idempotent).
23-
HUB_CLUSTER="${RESOURCE_PREFIX:-peeks}-hub"
24-
KARGO_ROLE="${HUB_CLUSTER}-kargo-controller-role"
25-
26-
echo "Setting up Kargo ECR access..."
27-
if ! aws iam get-role --role-name "$KARGO_ROLE" --region "$AWS_REGION" >/dev/null 2>&1; then
28-
aws iam create-role --role-name "$KARGO_ROLE" \
29-
--assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"pods.eks.amazonaws.com"},"Action":["sts:AssumeRole","sts:TagSession"]}]}' \
30-
--description "Kargo controller ECR read access" --no-cli-pager >/dev/null
31-
aws iam attach-role-policy --role-name "$KARGO_ROLE" \
32-
--policy-arn arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly --region "$AWS_REGION"
33-
echo " ✓ IAM role $KARGO_ROLE created"
34-
fi
35-
KARGO_ROLE_ARN=$(aws iam get-role --role-name "$KARGO_ROLE" --query 'Role.Arn' --output text --region "$AWS_REGION")
36-
37-
if ! aws eks list-pod-identity-associations --cluster-name "$HUB_CLUSTER" --region "$AWS_REGION" \
38-
--query "associations[?namespace=='kargo'&&serviceAccount=='kargo-controller']" --output text 2>/dev/null | grep -q .; then
39-
aws eks create-pod-identity-association \
40-
--cluster-name "$HUB_CLUSTER" --namespace kargo --service-account kargo-controller \
41-
--role-arn "$KARGO_ROLE_ARN" --region "$AWS_REGION" >/dev/null
42-
echo " ✓ pod identity association created"
43-
# Restart kargo controller to pick up the new credentials
44-
kubectl rollout restart deployment -n kargo 2>/dev/null || true
45-
kubectl rollout status deployment -n kargo --timeout=60s 2>/dev/null || true
46-
fi
47-
4821

4922
# Deploy the project (creates namespace)
5023
echo "Creating Kargo project..."

applications/java/progressive-app.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: team-java
66
spec:
77
image: argoproj/rollouts-demo:blue
8-
image_name: progressive-app
8+
image_name: rollout-demo
99
replicas: 2
1010
port: 8080
1111
targetPort: 8080
@@ -25,11 +25,11 @@ spec:
2525
apiVersion: v1
2626
kind: Service
2727
metadata:
28-
name: progressive-app
28+
name: rollout-demo
2929
namespace: team-java
3030
spec:
3131
selector:
32-
app: progressive-app
32+
app: rollout-demo
3333
ports:
3434
- port: 8080
3535
targetPort: 8080
@@ -38,11 +38,11 @@ spec:
3838
apiVersion: v1
3939
kind: Service
4040
metadata:
41-
name: progressive-app-preview
41+
name: rollout-demo-preview
4242
namespace: team-java
4343
spec:
4444
selector:
45-
app: progressive-app
45+
app: rollout-demo
4646
ports:
4747
- port: 8080
4848
targetPort: 8080

applications/next-js/deployment/dev/application.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ spec:
2222
enabled: true
2323
path: /unicorn
2424
rewrite: false
25-
healthcheckPath: /unicorn
2625
---
2726
apiVersion: v1
2827
kind: Service

applications/rust/deployment/templates/kro/application.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ spec:
2929
enabled: true
3030
path: /rust-app
3131
rewrite: true
32-
healthcheckPath: /rust-app/
3332
## Uncomment the sections below to enable metrics-driven progressive delivery (Module 30)
3433
# functionalGate:
3534
# enabled: true

cluster-providers/kind-crossplane/Taskfile.cloudfront.yaml

Lines changed: 12 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,17 @@ tasks:
2828
echo "Platform CloudFront origin OK"
2929
fi
3030
fi
31-
# GitLab NLB
32-
NLB_DNS=$(aws elbv2 describe-load-balancers --names "{{.HUB_CLUSTER_NAME}}-gitlab" --region {{.AWS_REGION}} --query 'LoadBalancers[0].DNSName' --output text 2>/dev/null)
33-
DIST_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='{{.HUB_CLUSTER_NAME}}-gitlab'].Id" --output text 2>/dev/null)
34-
if [ -n "$DIST_ID" ] && [ "$DIST_ID" != "None" ] && [ -n "$NLB_DNS" ] && [ "$NLB_DNS" != "None" ]; then
35-
CURRENT_ORIGIN=$(aws cloudfront get-distribution-config --id "$DIST_ID" --query 'DistributionConfig.Origins.Items[0].DomainName' --output text)
36-
if [ "$CURRENT_ORIGIN" != "$NLB_DNS" ]; then
37-
echo "Updating GitLab CloudFront origin: $CURRENT_ORIGIN → $NLB_DNS"
38-
ETAG=$(aws cloudfront get-distribution-config --id "$DIST_ID" --query 'ETag' --output text)
39-
aws cloudfront get-distribution-config --id "$DIST_ID" --query 'DistributionConfig' --output json | \
40-
jq --arg dns "$NLB_DNS" '.Origins.Items[0].DomainName = $dns' > /tmp/cf-gitlab-config.json
41-
aws cloudfront update-distribution --id "$DIST_ID" --if-match "$ETAG" --distribution-config file:///tmp/cf-gitlab-config.json > /dev/null
42-
echo "GitLab CloudFront updated"
43-
else
44-
echo "GitLab CloudFront origin OK"
45-
fi
46-
fi
31+
# GitLab CloudFront is managed by CDK (NLB + distribution in team-stack.ts).
32+
# private/gitlab-cloudfront-domain is written by bootstrap.sh at EC2 boot.
4733
4834
setup-exposure:
49-
desc: Pre-create ALB and CloudFront distributions (cloudfront mode only)
35+
desc: Pre-create ALB and CloudFront distributions (cloudfront mode only, skipped if cloudfrontDomain already set in config)
5036
status:
5137
- '[ "{{.EXPOSURE_MODE}}" != "cloudfront" ]'
38+
- '[ -n "{{.CLOUDFRONT_DOMAIN}}" ]'
5239
cmds:
5340
- task: create-alb
5441
- task: hub-distribution
55-
- task: gitlab-nlb
56-
- task: gitlab-distribution
5742
create-alb:
5843
desc: Pre-create the platform ALB for CloudFront (cloudfront mode only)
5944
status:
@@ -62,9 +47,12 @@ tasks:
6247
- printf '{{.C_STEP}}▸ Creating platform ALB...{{.C_RESET}}\n'
6348
- |
6449
set -e
65-
VPC_ID=$(aws eks describe-cluster --name {{.HUB_CLUSTER_NAME}} --region {{.AWS_REGION}} --query 'cluster.resourcesVpcConfig.vpcId' --output text)
66-
PUBLIC_SUBNETS=$(aws eks describe-cluster --name {{.HUB_CLUSTER_NAME}} --region {{.AWS_REGION}} --query 'cluster.resourcesVpcConfig.subnetIds' --output text | tr '\t' '\n')
67-
PUBLIC_SUBNETS=$(aws ec2 describe-subnets --subnet-ids $PUBLIC_SUBNETS --region {{.AWS_REGION}} --query 'Subnets[?MapPublicIpOnLaunch==`true`].SubnetId' --output text | tr '\t' ' ')
50+
# Use VPC from config.local.yaml cloudfront.vpcId if set, else derive from EKS cluster
51+
VPC_ID="${{.CLOUDFRONT_VPC_ID}}"
52+
if [ -z "$VPC_ID" ]; then
53+
VPC_ID=$(aws eks describe-cluster --name {{.HUB_CLUSTER_NAME}} --region {{.AWS_REGION}} --query 'cluster.resourcesVpcConfig.vpcId' --output text)
54+
fi
55+
PUBLIC_SUBNETS=$(aws ec2 describe-subnets --filters "Name=vpc-id,Values=$VPC_ID" "Name=mapPublicIpOnLaunch,Values=true" --region {{.AWS_REGION}} --query 'Subnets[*].SubnetId' --output text | tr '\t' ' ')
6856
CLUSTER_SG=$(aws eks describe-cluster --name {{.HUB_CLUSTER_NAME}} --region {{.AWS_REGION}} --query 'cluster.resourcesVpcConfig.clusterSecurityGroupId' --output text)
6957
SG_NAME="{{.HUB_CLUSTER_NAME}}-platform-alb-sg"
7058
SG_ID=$(aws ec2 describe-security-groups --filters "Name=group-name,Values=$SG_NAME" "Name=vpc-id,Values=$VPC_ID" --region {{.AWS_REGION}} --query 'SecurityGroups[0].GroupId' --output text 2>/dev/null)
@@ -109,55 +97,7 @@ tasks:
10997
CF_DOMAIN=$(aws cloudfront create-distribution --distribution-config "$CF_CONFIG" --query "Distribution.DomainName" --output text)
11098
mkdir -p {{.ROOT_DIR}}/private
11199
echo -n "$CF_DOMAIN" > {{.ROOT_DIR}}/private/cloudfront-domain
112-
echo "CloudFront: $CF_DOMAIN"
100+
echo "CloudFront: $CF_DOMAIN (copy this to config.local.yaml cloudfront.cloudfrontDomain)"
113101
- printf '{{.C_OK}}✓ Platform CloudFront ready.{{.C_RESET}}\n'
114-
115-
gitlab-nlb:
116-
desc: Pre-create GitLab NLB for CloudFront (cloudfront mode only)
117-
status:
118-
- aws elbv2 describe-load-balancers --names {{.HUB_CLUSTER_NAME}}-gitlab --region {{.AWS_REGION}} 2>/dev/null
119-
cmds:
120-
- printf '{{.C_STEP}}▸ Creating GitLab NLB...{{.C_RESET}}\n'
121-
- |
122-
set -e
123-
VPC_ID=$(aws eks describe-cluster --name {{.HUB_CLUSTER_NAME}} --region {{.AWS_REGION}} --query 'cluster.resourcesVpcConfig.vpcId' --output text)
124-
PUBLIC_SUBNETS=$(aws eks describe-cluster --name {{.HUB_CLUSTER_NAME}} --region {{.AWS_REGION}} --query 'cluster.resourcesVpcConfig.subnetIds' --output text | tr '\t' '\n')
125-
PUBLIC_SUBNETS=$(aws ec2 describe-subnets --subnet-ids $PUBLIC_SUBNETS --region {{.AWS_REGION}} --query 'Subnets[?MapPublicIpOnLaunch==`true`].SubnetId' --output text | tr '\t' ' ')
126-
# Create WITH a security group: an NLB created with zero SGs can never have
127-
# SGs added later, which blocks the AWS LBC from attaching its managed
128-
# frontend SG when it adopts this NLB. Seed with the cluster SG; the LBC
129-
# replaces the set via SetSecurityGroups during reconcile.
130-
CLUSTER_SG=$(aws eks describe-cluster --name {{.HUB_CLUSTER_NAME}} --region {{.AWS_REGION}} --query 'cluster.resourcesVpcConfig.clusterSecurityGroupId' --output text)
131-
NLB_ARN=$(aws elbv2 create-load-balancer \
132-
--name "{{.HUB_CLUSTER_NAME}}-gitlab" \
133-
--subnets $PUBLIC_SUBNETS \
134-
--security-groups "$CLUSTER_SG" \
135-
--scheme internet-facing \
136-
--type network \
137-
--tags Key=elbv2.k8s.aws/cluster,Value={{.HUB_CLUSTER_NAME}} Key=service.k8s.aws/stack,Value=gitlab/gitlab Key=service.k8s.aws/resource,Value=LoadBalancer \
138-
--region {{.AWS_REGION}} \
139-
--query 'LoadBalancers[0].LoadBalancerArn' --output text)
140-
NLB_DNS=$(aws elbv2 describe-load-balancers --load-balancer-arns "$NLB_ARN" --region {{.AWS_REGION}} --query 'LoadBalancers[0].DNSName' --output text)
141-
echo "GitLab NLB: $NLB_DNS"
142-
- printf '{{.C_OK}}✓ GitLab NLB ready.{{.C_RESET}}\n'
143-
144-
gitlab-distribution:
145-
desc: Create CloudFront distribution for GitLab NLB (idempotent)
146-
status:
147-
- aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='{{.HUB_CLUSTER_NAME}}-gitlab'].Id" --output text | grep -q .
148-
cmds:
149-
- printf '{{.C_STEP}}▸ Creating GitLab CloudFront distribution...{{.C_RESET}}\n'
150-
- |
151-
set -e
152-
NLB_DNS=$(aws elbv2 describe-load-balancers --names "{{.HUB_CLUSTER_NAME}}-gitlab" --region {{.AWS_REGION}} --query 'LoadBalancers[0].DNSName' --output text)
153-
CF_CONFIG=$(cat <<'CFEOF'
154-
{"CallerReference":"{{.HUB_CLUSTER_NAME}}-gitlab-TIMESTAMP","Comment":"{{.HUB_CLUSTER_NAME}}-gitlab","Enabled":true,"Origins":{"Quantity":1,"Items":[{"Id":"gitlab-nlb","DomainName":"NLB_DNS_PLACEHOLDER","CustomOriginConfig":{"HTTPPort":80,"HTTPSPort":443,"OriginProtocolPolicy":"http-only","OriginSslProtocols":{"Quantity":1,"Items":["TLSv1.2"]}}}]},"DefaultCacheBehavior":{"TargetOriginId":"gitlab-nlb","ViewerProtocolPolicy":"redirect-to-https","AllowedMethods":{"Quantity":7,"Items":["GET","HEAD","OPTIONS","PUT","POST","PATCH","DELETE"],"CachedMethods":{"Quantity":2,"Items":["GET","HEAD"]}},"CachePolicyId":"4135ea2d-6df8-44a3-9df3-4b5a84be39ad","OriginRequestPolicyId":"216adef6-5c7f-47e4-b989-5492eafa07d3","Compress":true},"ViewerCertificate":{"CloudFrontDefaultCertificate":true},"PriceClass":"PriceClass_100"}
155-
CFEOF
156-
)
157-
CF_CONFIG=$(echo "$CF_CONFIG" | sed "s|NLB_DNS_PLACEHOLDER|$NLB_DNS|g; s|TIMESTAMP|$(date +%s)|g")
158-
CF_DOMAIN=$(aws cloudfront create-distribution --distribution-config "$CF_CONFIG" --query "Distribution.DomainName" --output text)
159-
mkdir -p {{.ROOT_DIR}}/private
160-
echo -n "$CF_DOMAIN" > {{.ROOT_DIR}}/private/gitlab-cloudfront-domain
161-
echo "GitLab CloudFront: $CF_DOMAIN"
162-
- printf '{{.C_OK}}✓ GitLab CloudFront ready.{{.C_RESET}}\n'
102+
# gitlab-nlb and gitlab-distribution removed — GitLab CloudFront is now managed by CDK (team-stack.ts).
163103

cluster-providers/kind-crossplane/Taskfile.workshop.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)