Skip to content

Commit

Permalink
docs: [SKU modularizastion] Add AWS installation documentation (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
smritidahal653 authored Nov 26, 2024
1 parent 00056b5 commit 711c858
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 3 deletions.
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ AI_MODELS_REGISTRY ?= modelregistry.azurecr.io
AI_MODELS_REGISTRY_SECRET ?= modelregistry
SUPPORTED_MODELS_YAML_PATH ?= ~/runner/_work/kaito/kaito/presets/workspace/models/supported_models.yaml

## AWS parameters
CLUSTER_CONFIG_FILE ?= ./docs/aws/clusterconfig.yaml.template
RENDERED_CLUSTER_CONFIG_FILE ?= ./docs/aws/clusterconfig.yaml
AWS_KARPENTER_VERSION ?=1.0.8

# Scripts
GO_INSTALL := ./hack/go-install.sh

Expand Down Expand Up @@ -173,6 +178,29 @@ create-aks-cluster-for-karpenter: ## Create test AKS cluster (with msi, cilium,
--enable-managed-identity --enable-oidc-issuer --enable-workload-identity -o none
az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --overwrite-existing

## --------------------------------------
## AWS resources
## --------------------------------------
.PHONY: mktemp
mktemp:
$(eval TEMPOUT := $(shell mktemp))

.PHONY: deploy-aws-cloudformation
deploy-aws-cloudformation: mktemp ## Deploy AWS CloudFormation stack
curl -fsSL https://raw.githubusercontent.com/aws/karpenter-provider-aws/v"${AWS_KARPENTER_VERSION}"/website/content/en/preview/getting-started/getting-started-with-karpenter/cloudformation.yaml > "${TEMPOUT}"

aws cloudformation deploy \
--stack-name "Karpenter-${AWS_CLUSTER_NAME}" \
--template-file "${TEMPOUT}" \
--capabilities CAPABILITY_NAMED_IAM \
--parameter-overrides "ClusterName=${AWS_CLUSTER_NAME}"

.PHONY: create-eks-cluster
create-eks-cluster: ## Create test EKS cluster
@envsubst < $(CLUSTER_CONFIG_FILE) > $(RENDERED_CLUSTER_CONFIG_FILE)

eksctl create cluster -f $(RENDERED_CLUSTER_CONFIG_FILE)

## --------------------------------------
## Image Docker Build
## --------------------------------------
Expand Down Expand Up @@ -280,6 +308,16 @@ az-patch-install-helm: ## Update Azure client env vars and settings in helm valu

helm install kaito-workspace ./charts/kaito/workspace --namespace $(KAITO_NAMESPACE) --create-namespace

.PHONY: aws-patch-install-helm ##install kaito on AWS cluster
aws-patch-install-helm:
yq -i '(.image.repository) = "$(REGISTRY)/workspace"' ./charts/kaito/workspace/values.yaml
yq -i '(.image.tag) = "$(IMG_TAG)"' ./charts/kaito/workspace/values.yaml
yq -i '(.featureGates.Karpenter) = "true"' ./charts/kaito/workspace/values.yaml
yq -i '(.clusterName) = "$(AWS_CLUSTER_NAME)"' ./charts/kaito/workspace/values.yaml
yq -i '(.cloudProviderName) = "aws"' ./charts/kaito/workspace/values.yaml

helm install kaito-workspace ./charts/kaito/workspace --namespace $(KAITO_NAMESPACE) --create-namespace

generate-identities: ## Create identities for the provisioner component.
./hack/deploy/generate-identities.sh \
$(AZURE_CLUSTER_NAME) $(AZURE_RESOURCE_GROUP) $(TEST_SUITE) $(AZURE_SUBSCRIPTION_ID)
Expand Down Expand Up @@ -320,6 +358,23 @@ azure-karpenter-helm: ## Update Azure client env vars and settings in helm valu

kubectl wait --for=condition=available deploy "karpenter" -n karpenter --timeout=300s

## --------------------------------------
## AWS Karpenter Installation
## --------------------------------------
.PHONY: aws-karpenter-helm
aws-karpenter-helm:
helm upgrade --install karpenter oci://public.ecr.aws/karpenter/karpenter \
--version "${AWS_KARPENTER_VERSION}" \
--namespace "${KARPENTER_NAMESPACE}" --create-namespace \
--set "settings.clusterName=${AWS_CLUSTER_NAME}" \
--set "settings.interruptionQueue=${AWS_CLUSTER_NAME}" \
--set controller.resources.requests.cpu=1 \
--set controller.resources.requests.memory=1Gi \
--set controller.resources.limits.cpu=1 \
--set controller.resources.limits.memory=1Gi \

kubectl wait --for=condition=available deploy "karpenter" -n ${KARPENTER_NAMESPACE} --timeout=300s

##@ Build
.PHONY: build-workspace
build-workspace: manifests generate fmt vet ## Build manager binary.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ The workspace status can be tracked by running the following command. When the W

```sh
$ kubectl get workspace workspace-falcon-7b
NAME INSTANCE RESOURCEREADY INFERENCEREADY WORKSPACEREADY AGE
workspace-falcon-7b Standard_NC12s_v3 True True True 10m
NAME INSTANCE RESOURCEREADY INFERENCEREADY JOBSTARTED WORKSPACESUCCEEDED AGE
workspace-falcon-7b Standard_NC12s_v3 True True True True 10m
```

Next, one can find the inference service's cluster ip and use a temporal `curl` pod to test the service endpoint in the cluster.
Expand Down
101 changes: 101 additions & 0 deletions docs/aws/aws_installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Installation using AWS EKS cluster

Before you begin, ensure you have the following tools installed:
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) to provision AWS resources
- [Eksctl](https://eksctl.io/installation/) (>= v0.191.0) to create and manage clusters on EKS
- [Helm](https://helm.sh) to install this operator
- [kubectl](https://kubernetes.io/docs/tasks/tools/) to view Kubernetes resources

## Create EKS Cluster
If you do not already have an EKS cluster, run the following to create one:

```bash
cd ../.. #go back to main directory to use MAKE commands

export AWS_CLUSTER_NAME=kaito-aws
export AWS_REGION=us-west-2
export AWS_PARTITION=aws
export AWS_K8S_VERSION=1.30
export KARPENTER_NAMESPACE=kube-system
export AWS_ACCOUNT_ID="$(aws sts get-caller-identity --query Account --output text)"

make deploy-aws-cloudformation
make create-eks-cluster
```

If you already have an EKS cluster, connect to it using
```bash
aws eks update-kubeconfig --name $CLUSTER_NAME --region $AWS_REGION
```

## Install Karpenter Controller
```bash
make aws-karpenter-helm
```

## Install Workspace Controller
```bash
make aws-patch-install-helm
```

## Verify installation
You can run the following commands to verify the installation of the controllers were successful.

Check status of the Helm chart installations.

```bash
helm list -n default
```

Check status of `workspace`.

```bash
kubectl describe deploy kaito-workspace -n kaito-workspace
```

Check status of `karpenter`.

```bash
kubectl describe deploy karpenter -n $KARPENTER_NAMESPACE
```

## Create a Workspace and start an inference service
Once the Kaito and Karpenter controllers are installed, you can follow these commands to start a falcon-7b inference service.

```bash
$ export kaito_workspace_aws="../../examples/inference/kaito_workspace_falcon_7b_aws.yaml"
$ cat $kaito_workspace_aws
apiVersion: kaito.sh/v1alpha1
kind: Workspace
metadata:
name: aws-workspace
resource:
instanceType: "g5.4xlarge"
labelSelector:
matchLabels:
apps: falcon-7b
inference:
preset:
name: "falcon-7b"

$ kubectl apply -f $kaito_workspace_aws
```

The workspace status can be tracked by running the following command. When the WORKSPACEREADY column becomes `True`, the model has been deployed successfully.

```sh
$ kubectl get workspace workspace-falcon-7b
NAME INSTANCE RESOURCEREADY INFERENCEREADY JOBSTARTED WORKSPACESUCCEEDED AGE
aws-workspace g5.4xlarge True True True True 10m
```

Next, one can find the inference service's cluster ip and use a temporal `curl` pod to test the service endpoint in the cluster.

```sh
$ kubectl get svc aws-workspace
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
aws-workspace ClusterIP <CLUSTERIP> <none> 80/TCP,29500/TCP 10m

export CLUSTERIP=$(kubectl get svc aws-workspace -o jsonpath="{.spec.clusterIPs[0]}")
$ kubectl run -it --rm --restart=Never curl --image=curlimages/curl -- curl -X POST http://$CLUSTERIP/chat -H "accept: application/json" -H "Content-Type: application/json" -d "{\"prompt\":\"YOUR QUESTION HERE\"}"
```
38 changes: 38 additions & 0 deletions docs/aws/clusterconfig.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: ${AWS_CLUSTER_NAME}
region: ${AWS_REGION}
version: "${AWS_K8S_VERSION}"
tags:
karpenter.sh/discovery: ${AWS_CLUSTER_NAME}

iam:
withOIDC: true
podIdentityAssociations:
- namespace: "${KARPENTER_NAMESPACE}"
serviceAccountName: karpenter
roleName: ${AWS_CLUSTER_NAME}-karpenter
permissionPolicyARNs:
- arn:${AWS_PARTITION}:iam::${AWS_ACCOUNT_ID}:policy/KarpenterControllerPolicy-${AWS_CLUSTER_NAME}

iamIdentityMappings:
- arn: "arn:${AWS_PARTITION}:iam::${AWS_ACCOUNT_ID}:role/KarpenterNodeRole-${AWS_CLUSTER_NAME}"
username: system:node:{{EC2PrivateDNSName}}
groups:
- system:bootstrappers
- system:nodes
## If you intend to run Windows workloads, the kube-proxy group should be specified.
# For more information, see https://github.com/aws/karpenter/issues/5099.
# - eks:kube-proxy-windows

managedNodeGroups:
- instanceType: m5.large
amiFamily: AmazonLinux2
name: ${AWS_CLUSTER_NAME}-ng
desiredCapacity: 2
minSize: 1
maxSize: 10

addons:
- name: eks-pod-identity-agent
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Installation

The following guidance assumes **Azure Kubernetes Service(AKS)** is used to host the Kubernetes cluster.
The following guidance assumes **Azure Kubernetes Service(AKS)** is used to host the Kubernetes cluster. If you want to use Elastic Kubernetes Service (EKS) instead, please follow the installation guide [here](./aws/aws_installation.md)

Before you begin, ensure you have the following tools installed:

Expand Down
13 changes: 13 additions & 0 deletions examples/inference/kaito_workspace_falcon_7b_aws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kaito.sh/v1alpha1
kind: Workspace
metadata:
name: aws-workspace
resource:
instanceType: "g5.4xlarge"
labelSelector:
matchLabels:
apps: falcon-7b
inference:
preset:
name: "falcon-7b"

0 comments on commit 711c858

Please sign in to comment.