|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Anyscale on an existing EKS cluster — post-terraform deployment commands. |
| 3 | +# |
| 4 | +# Substitute <eks_cluster_name>, <anyscale_cloud_name>, and |
| 5 | +# <node_IAM_role_arn> below before running. Steps 5-8 also depend on |
| 6 | +# $CLOUD_DEPLOYMENT_ID (captured from step 1) and $GATEWAY_HOSTNAME |
| 7 | +# (captured from step 5). |
| 8 | +set -euo pipefail |
| 9 | + |
| 10 | +# ------------------------------------------------------------------ |
| 11 | +# 1. Register the Anyscale cloud (returns a cldrsrc_... id) |
| 12 | +# ------------------------------------------------------------------ |
| 13 | +echo "==> Step 1/8: Registering the Anyscale cloud..." |
| 14 | +# Replace <anyscale_cloud_name> and <node_IAM_role_arn> below: |
| 15 | +register_output=$(${registration_command} 2>&1) |
| 16 | +echo "$register_output" |
| 17 | +export CLOUD_DEPLOYMENT_ID=$(echo "$register_output" | grep -oE 'cldrsrc_[a-zA-Z0-9]+' | head -1 || true) |
| 18 | +: "$${CLOUD_DEPLOYMENT_ID:?failed to capture cldrsrc_ id from registration output}" |
| 19 | +echo " Captured CLOUD_DEPLOYMENT_ID=$CLOUD_DEPLOYMENT_ID" |
| 20 | + |
| 21 | +# ------------------------------------------------------------------ |
| 22 | +# 2. Authenticate to the EKS cluster |
| 23 | +# ------------------------------------------------------------------ |
| 24 | +echo "==> Step 2/8: Updating kubeconfig for cluster <eks_cluster_name>..." |
| 25 | +aws eks update-kubeconfig --region ${aws_region} --name <eks_cluster_name> |
| 26 | + |
| 27 | +# ------------------------------------------------------------------ |
| 28 | +# 3. Cluster Autoscaler |
| 29 | +# ------------------------------------------------------------------ |
| 30 | +echo "==> Step 3/8: Installing Cluster Autoscaler..." |
| 31 | +helm repo add autoscaler https://kubernetes.github.io/autoscaler 2>/dev/null || true |
| 32 | +helm repo update |
| 33 | +helm upgrade cluster-autoscaler autoscaler/cluster-autoscaler \ |
| 34 | + --version 9.46.0 \ |
| 35 | + --namespace kube-system \ |
| 36 | + --set awsRegion=${aws_region} \ |
| 37 | + --set autoDiscovery.clusterName=<eks_cluster_name> \ |
| 38 | + --install |
| 39 | + |
| 40 | +# ------------------------------------------------------------------ |
| 41 | +# 4. AWS Load Balancer Controller (region + vpcId explicit so it |
| 42 | +# does not need IMDSv2 access to introspect them) |
| 43 | +# ------------------------------------------------------------------ |
| 44 | +echo "==> Step 4/8: Installing AWS Load Balancer Controller..." |
| 45 | +helm repo add eks https://aws.github.io/eks-charts 2>/dev/null || true |
| 46 | +helm repo update |
| 47 | +helm upgrade aws-load-balancer-controller eks/aws-load-balancer-controller \ |
| 48 | + --version 1.13.2 \ |
| 49 | + --namespace kube-system \ |
| 50 | + --set clusterName=<eks_cluster_name> \ |
| 51 | + --set region=${aws_region} \ |
| 52 | + --set vpcId=${existing_vpc_id} \ |
| 53 | + --install |
| 54 | +%{ if enable_s3_pvc ~} |
| 55 | + |
| 56 | +# ------------------------------------------------------------------ |
| 57 | +# 4a. (enable_s3_pvc = true) Install the Mountpoint-S3 CSI managed |
| 58 | +# addon and bind it to the IAM role Terraform created. |
| 59 | +# ------------------------------------------------------------------ |
| 60 | +echo "==> Step 4a/8: Installing Mountpoint-S3 CSI managed addon + Pod Identity Association..." |
| 61 | +aws eks create-addon \ |
| 62 | + --cluster-name <eks_cluster_name> \ |
| 63 | + --addon-name aws-mountpoint-s3-csi-driver \ |
| 64 | + --resolve-conflicts OVERWRITE |
| 65 | +aws eks create-pod-identity-association \ |
| 66 | + --cluster-name <eks_cluster_name> \ |
| 67 | + --namespace kube-system \ |
| 68 | + --service-account s3-csi-driver-sa \ |
| 69 | + --role-arn ${s3_csi_driver_role_arn} |
| 70 | +%{ endif ~} |
| 71 | + |
| 72 | +# ------------------------------------------------------------------ |
| 73 | +# 5. Envoy Gateway + Anyscale gateway manifests |
| 74 | +# (substitutes the cldrsrc slug into the gateway YAML on the fly |
| 75 | +# so the TLS Secret refs are correct from the first apply) |
| 76 | +# |
| 77 | +# CRDs are applied separately because `helm upgrade --install` |
| 78 | +# skips `chart/crds/` on subsequent runs by design — so reruns |
| 79 | +# with a newer chart version would otherwise leave Gateway API |
| 80 | +# and Envoy Gateway CRDs stale. |
| 81 | +# ------------------------------------------------------------------ |
| 82 | +echo "==> Step 5/8: Installing Envoy Gateway v1.7.0 and applying Anyscale gateway manifests..." |
| 83 | +EG_CRD_DIR=$(mktemp -d) |
| 84 | +trap 'rm -rf "$${EG_CRD_DIR}"' EXIT |
| 85 | +helm pull oci://docker.io/envoyproxy/gateway-helm --version v1.7.0 \ |
| 86 | + --untar --untardir "$${EG_CRD_DIR}" |
| 87 | +kubectl apply --server-side --force-conflicts -R -f "$${EG_CRD_DIR}/gateway-helm/crds/" |
| 88 | +helm upgrade eg oci://docker.io/envoyproxy/gateway-helm \ |
| 89 | + --version v1.7.0 \ |
| 90 | + --namespace envoy-gateway-system \ |
| 91 | + --create-namespace \ |
| 92 | + --skip-crds \ |
| 93 | + --install |
| 94 | +kubectl wait --for=condition=available deployment/envoy-gateway \ |
| 95 | + -n envoy-gateway-system --timeout=120s |
| 96 | + |
| 97 | +SECRET_SLUG="$${CLOUD_DEPLOYMENT_ID//_/-}" # cldrsrc_xxx → cldrsrc-xxx |
| 98 | +echo " Substituting SECRET_SLUG=$SECRET_SLUG into sample-values_gateway.yaml..." |
| 99 | +sed "s/<cldrsrc-with-dashes>/$${SECRET_SLUG}/g" sample-values_gateway.yaml | kubectl apply -f - |
| 100 | + |
| 101 | +echo " Waiting for Gateway to be Programmed (up to 5 min)..." |
| 102 | +kubectl wait -n anyscale-operator --for=condition=Programmed gateway/gateway --timeout=300s |
| 103 | +export GATEWAY_HOSTNAME=$(kubectl get gateway gateway -n anyscale-operator \ |
| 104 | + -o jsonpath='{.status.addresses[0].value}') |
| 105 | +echo " Captured GATEWAY_HOSTNAME=$GATEWAY_HOSTNAME" |
| 106 | +%{ if enable_s3_pvc ~} |
| 107 | + |
| 108 | +# ------------------------------------------------------------------ |
| 109 | +# 6. Apply the Mountpoint-S3 PV/PVC (enable_s3_pvc = true) |
| 110 | +# ------------------------------------------------------------------ |
| 111 | +echo "==> Step 6/8: Applying S3 PersistentVolume + PersistentVolumeClaim..." |
| 112 | +kubectl apply -f ./generated/pv-pvc.yaml |
| 113 | +echo " Waiting for PVC anyscale-shared-fuse to bind (up to 2 min)..." |
| 114 | +kubectl wait -n anyscale-operator --for=jsonpath='{.status.phase}'=Bound \ |
| 115 | + pvc/anyscale-shared-fuse --timeout=120s |
| 116 | +%{ endif ~} |
| 117 | + |
| 118 | +# ------------------------------------------------------------------ |
| 119 | +# 7. Anyscale Operator |
| 120 | +# ------------------------------------------------------------------ |
| 121 | +echo "==> Step 7/8: Installing the Anyscale Operator helm chart..." |
| 122 | +helm repo add anyscale https://anyscale.github.io/helm-charts 2>/dev/null || true |
| 123 | +helm repo update |
| 124 | +helm upgrade anyscale-operator anyscale/anyscale-operator \ |
| 125 | + --set-string global.cloudDeploymentId="$CLOUD_DEPLOYMENT_ID" \ |
| 126 | + --set-string global.cloudProvider=aws \ |
| 127 | + --set-string global.aws.region=${aws_region} \ |
| 128 | + --set-string workloads.serviceAccount.name=anyscale-operator \ |
| 129 | + --set networking.gateway.enabled=true \ |
| 130 | + --set-string networking.gateway.name=gateway \ |
| 131 | + --set-string networking.gateway.namespace=anyscale-operator \ |
| 132 | + --set-string networking.gateway.apiVersion=gateway.networking.k8s.io/v1 \ |
| 133 | + --set-string networking.gateway.hostname="$GATEWAY_HOSTNAME" \ |
| 134 | + --namespace anyscale-operator \ |
| 135 | + --install \ |
| 136 | + --wait --timeout 10m |
| 137 | + |
| 138 | +echo " Waiting for the operator to create the head-node TLS Secret (up to 5 min)..." |
| 139 | +kubectl wait --for=create secret/anyscale-$${SECRET_SLUG}-certificate \ |
| 140 | + -n anyscale-operator --timeout=300s |
| 141 | + |
| 142 | +# ------------------------------------------------------------------ |
| 143 | +# 8. Verify |
| 144 | +# ------------------------------------------------------------------ |
| 145 | +echo "==> Step 8/8: Verifying the deployment..." |
| 146 | +echo " Cert Secret:" |
| 147 | +kubectl get secret "anyscale-$${SECRET_SLUG}-certificate" -n anyscale-operator |
| 148 | +echo " Gateway listener status:" |
| 149 | +kubectl get gateway gateway -n anyscale-operator \ |
| 150 | + -o jsonpath='{range .status.listeners[*]}{.name}: ResolvedRefs={.conditions[?(@.type=="ResolvedRefs")].status}{"\n"}{end}' |
| 151 | +echo " HTTPRoutes (operator-managed, none until workloads launch):" |
| 152 | +kubectl get httproutes -n anyscale-operator |
| 153 | +echo "==> Done. Anyscale cloud $CLOUD_DEPLOYMENT_ID is ready." |
0 commit comments