Running a model on a K8s cluster

You can now edit the vars.sh file we created earlier and set the appropriate values using your favorite command-line text editor. You will also need to create the bucket where k8s stores cluster information.

Once you have done this, you can bring up your Kubernetes cluster:

source vars.sh
./cluster-up.sh

KOPS is now interacting with Kubernetes via kubectl to spin up the AWS resources that will run your cluster and then configure K8s itself on these same resources. You will need to verify that your cluster has been brought up successfully before proceeding:

kops validate cluster
Validating cluster hodlgo.k8s.local

INSTANCE GROUPS
NAME ROLE MACHINETYPE MIN MAX SUBNETS
master-ap-southeast-2a Master c4.large 1 1 ap-southeast-2
nodes Node t2.medium 2 2 ap-southeast-2

NODE STATUS
NAME ROLE READY
ip-172-20-35-114.ec2.internal node True
ip-172-20-49-22.ec2.internal master True
ip-172-20-64-133.ec2.internal node True

Once all K8s masters return Ready, you can proceed with deploying your model across the cluster's nodes!

The script to do this is simple, and calls kubectl to apply the template in the same manner as our cluster_up.sh script.

Let's look at our deploy-model.sh file:

#!/bin/bash

# envsubst doesn't exist for OSX. needs to be brew-installed
# via gettext. Should probably warn the user about that.
command -v envsubst >/dev/null 2>&1 || {
echo >&2 "envsubst is required and not found. Aborting"
if [[ "$OSTYPE" == "darwin"* ]]; then
echo >&2 "------------------------------------------------"
echo >&2 "If you're on OSX, you can install with brew via:"
echo >&2 " brew install gettext"
echo >&2 " brew link --force gettext"
fi
exit 1;
}

cat ${SCRIPT_DIR}/model.yaml | envsubst | kubectl apply -f -


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.244.250