Skip to content

Latest commit

 

History

History
82 lines (63 loc) · 3.44 KB

File metadata and controls

82 lines (63 loc) · 3.44 KB

10.8 Deploying to EKS

In the section we'll create Elastic Kubernetes Service (EKS) cluster on Amazon using cli, publishing the image to ECR and configure kubectl.

To create cluster and manage on EKS we'll use a cli tool eksctl which can be downloaded from here. And next we'll follow these steps:

  • In the kube-config folder create eks config file eks-config.yaml:

    • apiVersion: eksctl.io/v1alpha5
      kind: ClusterConfig
      
      metadata:
        name: mlzoomcamp-eks
        region: ap-south-1
      
      nodeGroups: # for our case, we need only one node group (CPU)
        - name: ng-m5-xlarge
          instanceType: m5.xlarge
          desiredCapacity: 1
    • Create eks cluster: eksctl create cluster -f eks-config.yaml
  • Publish local docker images to ECR:

    • Create aws ecr repository for eks cluster: aws ecr create-repository --repository-name mlzoomcamp-images
    • Bash commands to run in the teminal to push docker images to ecr repository:
      • # Registry URI
        ACCOUNT_ID=22782589
        REGION=ap-south-123
        REGISTRY_NAME=mlzoomcamp-images
        PREFIX=${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/${REGISTRY_NAME}
        
        # Tag local docker images to remote tag
        GATEWAY_LOCAL=clothing-model-gateway:002 # gateway service
        GATEWAY_REMOTE=${PREFIX}:clothing-model-gateway-002 # notice the ':' is replaced with '-' before 002
        docker tag ${GATEWAY_LOCAL} ${GATEWAY_REMOTE}
        
        MODEL_LOCAL=clothing-model:xception-v4-001 # tf-serving model
        MODEL_REMOTE=${PREFIX}:clothing-model-xception-v4-001 # same thing ':' is replaced with '-' before xception
        docker tag ${MODEL_LOCAL} ${MODEL_REMOTE}
        
        
        # Push tagged docker images
        docker push ${MODEL_REMOTE}
        docker push ${GATEWAY_REMOTE}
      • Login to ecr and push images: $(aws ecr get-login --no-include-email), first push the model and then gateway remote image.
      • Get the uri of these images echo ${MODEL_REMOTE} and echo ${GATEWAY_REMOTE} and add them to model-deployment.yaml and gate-deployment.yaml respectively.
    • Apply all the yaml config files to remote node coming from eks (kubectl get nodes):
      • kubectl apply -f model-deployment.yaml
      • kubectl apply -f model-service.yaml
      • kubectl apply -f gateway-deployment.yaml
      • kubectl apply -f gateway-service.yaml
        • Testing the deployment pods and services should give us predictions.
    • Executing kubectl get service should give us the external port address which need to add in the test.py as access url for predictions (e.g., url = 'http://a3399e***-5180***.ap-south-123.elb.amazonaws.com/predict').
  • To delete the remote cluster: eksctl delete cluster --name mlzoomcamp-eks

Notes

Add notes from the video (PRs are welcome)

⚠️ The notes are written by the community.
If you see an error here, please create a PR with a fix.

Navigation