EDITD / kubetools

:nut_and_bolt: Kubetools is a tool and processes for developing and deploying microservices to Kubernetes.
MIT License
13 stars 2 forks source link

AWS EKS support #147

Closed tmwoodruff closed 1 year ago

tmwoodruff commented 1 year ago

Purpose of PR

Updates to support deployment to AWS EKS.

I've run into two issues deploying to EKS:

  1. ECR requires authentication and SSL, but the check for existing docker images in deploy/image.py makes an http request with no auth. To fix this, I've added the ability to configure an external script that can be called to check for existing images (see example below). Since there's no standard way to check registries, this provides flexibility to support whatever is needed.
  2. The version compatibility check in kubernetes/api.py:check_if_cronjob_batch_v1_compatible() fails with version strings returned by EKS (e.g., v1.25.7-eks-a59e1f0). I've added a regex to strip off anything after - in the version string,

Parts of the app this will impact

Kubernetes deployment

Additional information

Example image check script that uses aws-cli:

#!/bin/bash

AWS_REGION=us-west-2

REGISTRY="$1"
APP="$2"
COMMIT_INFO="$3"

[[ "$REGISTRY" != *.dkr.ecr.*.amazonaws.com ]] && exit 2

registry_id=${REGISTRY%%.*}

echo "Checking for image: <${registry_id}> <${APP}> <${COMMIT_INFO}>"

res=`aws ecr describe-images --registry-id ${registry_id} --region ${AWS_REGION} --repository-name ${APP} --image-ids imageTag=${COMMIT_INFO} 2>&1`

[[ "$res" = *imageDetails* ]] && { echo "Found"; exit 0; }

[[ "$res" = *ImageNotFoundException* ]] && { echo "Not Found"; exit 1; }

echo "ERROR:"
echo "$res"

exit 255
tmwoodruff commented 1 year ago

Looks great. Thanks, @gchazot .

gchazot commented 1 year ago

Thanks @tmwoodruff @Jberrz