Skip to content

Commit

Permalink
AWS: cleanup & fix dev
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrildiagne committed Oct 25, 2019
1 parent 0a36d12 commit f0161c8
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 149 deletions.
2 changes: 1 addition & 1 deletion cmd/setup-aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func init() {

func setupAWS() error {
const provider = "aws"
const providerVersion = "0.1.0"
const providerVersion = "2.0.0"

// Set provider config.
viper.Set("provider", provider)
Expand Down
2 changes: 0 additions & 2 deletions providers/aws/.config.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
set -e

echo
echo -e "\e[1m \e[34mKuda AWS provider \e[36mv$(cat /kuda_cmd/VERSION) \e[0m"
echo
Expand Down
16 changes: 8 additions & 8 deletions providers/aws/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
FROM alpine:3.10

# Set dependencies versions.
ARG EKSCTL_VERSION=0.7.0
ARG KUBECTL_VERSION=1.16.2
ARG SKAFFOLD_VERSION=0.40.0
ARG ISTIO_VERSION=1.3.3
ARG HELM_VERSION=2.15.0

# Install base apps & docker.
RUN apk add --update-cache --no-cache \
bash \
Expand All @@ -23,27 +16,34 @@ RUN apk add --update-cache --no-cache \
RUN pip install awscli

# Install eksctl
ARG EKSCTL_VERSION=0.7.0
ARG EKSCTL_HOST="https://github.com/weaveworks/eksctl/releases/download"
RUN curl --silent \
--location "${EKSCTL_HOST}/${EKSCTL_VERSION}/eksctl_$(uname -s)_amd64.tar.gz" \
| tar xz -C /tmp
RUN mv /tmp/eksctl /usr/local/bin

# Install kubectl
ARG KUBECTL_VERSION=1.16.2
ARG KUBECTL_HOST="https://storage.googleapis.com/kubernetes-release/release"
RUN curl -LO "${KUBECTL_HOST}/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" && \
chmod +x ./kubectl && \
mv ./kubectl /usr/local/bin/kubectl

# Install Helm
ARG HELM_VERSION=2.15.1
RUN curl -L https://git.io/get_helm.sh | DESIRED_VERSION="v${HELM_VERSION}" bash

# Download Istio CRDs
ARG ISTIO_VERSION=1.3.3
RUN curl -L https://git.io/getLatestIstio | ISTIO_VERSION="${ISTIO_VERSION}" sh -

# Install Skaffold.
ARG SKAFFOLD_HOST="https://storage.googleapis.com/skaffold/releases"
ARG SKAFFOLD_VERSION=0.40.0
# ARG SKAFFOLD_HOST="https://storage.googleapis.com/skaffold/releases"
# RUN curl -Lo skaffold "${SKAFFOLD_HOST}/v${SKAFFOLD_VERSION}/skaffold-linux-amd64" && \
# Temporarily use a custom skaffold build that fixes a kaniko issue #731 :
# https://github.com/GoogleContainerTools/skaffold/issues/731
RUN curl -Lo skaffold "https://storage.googleapis.com/artifacts.gpu-sh.appspot.com/releases/latest/skaffold-linux-amd64" && \
chmod +x skaffold && \
mv skaffold /usr/local/bin
Expand Down
50 changes: 31 additions & 19 deletions providers/aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,43 @@ It uses [ECR](https://aws.amazon.com/ecr) to privately store the app images.

# Status

| Command | Status |
| - | - |
| setup ||
| delete ||
| get | Not Started |
| app dev | WIP |
| app deploy | WIP |
| app delete ||
| Command |  Status |
| ------------ | ------- |
| `setup` ||
| `delete` ||
| `app dev` ||
| `app deploy` ||
| `app delete` ||

Functionalities:

| Functionality |  Status |
| ------------------- | ----------- |
| Dev file sync ||
| GPU node autoscaler | WIP |
| Https | Not started |
| Dns | Not started |
| Monitoring | Not started |

Notes:

- There is an issue with the nodes autoscaler

# Prerequisites

- You must have subscribed to [EKS-optimize AMI with GPU support](https://aws.amazon.com/marketplace/pp/B07GRHFXGM)
- You must have an increased limit of at least 1 instance of type p2.xlarge. You can make requests [here](http://aws.amazon.com/contact-us/ec2-request)
- You must have an [aws configuration](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) on your local machine in `~/.aws/` with credentials that have authorization for:
- cloudformation
- ec2
- ec2 autoscaling
- eks
- iam
- api
- ecr
- elb
- cloudformation
- ec2
- ec2 autoscaling
- eks
- iam
- api
- ecr
- elb

# Configuration
<!-- # Configuration
You can override the following settings by adding them as flags of the `kuda setup` command (ex: `kuda setup aws ... --aws_...=mycluster`).
Expand All @@ -37,5 +50,4 @@ You can override the following settings by adding them as flags of the `kuda set
| | | |
# Limitations

# Limitations -->
77 changes: 25 additions & 52 deletions providers/aws/app_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,41 @@ set -e

source $KUDA_CMD_DIR/.config.sh

# Config.
cluster_name=$KUDA_AWS_CLUSTER_NAME
aws_region=$KUDA_AWS_CLUSTER_REGION
aws_account_id="$(aws sts get-caller-identity | jq -r .Account)"
ecr_domain="$aws_account_id.dkr.ecr.$KUDA_AWS_CLUSTER_REGION.amazonaws.com"

ecr_domain="$aws_account_id.dkr.ecr.$aws_region.amazonaws.com"
app_name=$1
app_registry="$ecr_domain/$app_name"
app_image="$app_registry:$app_version"
namespace="default"

app_cache_name=$app_name-cache

echo $app_image

# Create Container Registry if it doesn't exists.
if [ -z "$(aws ecr describe-repositories --region $KUDA_AWS_CLUSTER_REGION | grep $app_name)" ]; then
# Create container registries if they doesn't exists.
repos="$(aws ecr describe-repositories --region $aws_region)"
if [ -z "$(echo $repos | grep $app_name)" ]; then
aws ecr create-repository \
--repository-name $app_name \
--region $KUDA_AWS_CLUSTER_REGION
--region $aws_region
else
echo "Container Registry $app_registry already exists"
fi

# Create the cache registry if it doesn't exists.
if [ -z "$(aws ecr describe-repositories --region $KUDA_AWS_CLUSTER_REGION | grep $app_cache_name)" ]; then
# Cache registry.
if [ -z "$(echo $repos | grep $app_cache_name)" ]; then
aws ecr create-repository \
--repository-name $app_cache_name \
--region $KUDA_AWS_CLUSTER_REGION
--region $aws_region
else
echo "Container Registry $app_registry-cache already exists"
fi

# Retrieve cluster token.
aws eks update-kubeconfig \
--name $KUDA_AWS_CLUSTER_NAME \
--region $KUDA_AWS_CLUSTER_REGION
--name $cluster_name \
--region $aws_region

# Login Container Registry.
# aws ecr get-login --region $KUDA_AWS_CLUSTER_REGION --no-include-email | bash

#TODO: Build & Push image using Kaniko.

# Write Knative service config.
# cat <<EOF | kubectl apply -f -
# apiVersion: serving.knative.dev/v1alpha1
# kind: Service
# metadata:
# name: $app_name
# namespace: default
# spec:
# template:
# spec:
# nodeSelector:
# nvidia.com/gpu: "true"
# tolerations:
# - key: "nvidia.com/gpu"
# operator: "Exists"
# effect: "NoSchedule"
# containers:
# - image: $app_image
# resources:
# limits:
# nvidia.com/gpu: 1
# EOF
aws ecr get-login --region $aws_region --no-include-email | bash

# Write Knative service config.
echo "
Expand All @@ -78,20 +51,22 @@ spec:
template:
spec:
# nodeSelector:
# nvidia.com/gpu: true
# nvidia.com/gpu: 'true'
# tolerations:
# - key: nvidia.com/gpu
# operator: Exists
# effect: NoSchedule
# - key: 'nvidia.com/gpu'
# operator: 'Exists'
# effect: 'NoSchedule'
containers:
- image: $app_registry
resources:
limits:
nvidia.com/gpu: 1
# resources:
# limits:
# nvidia.com/gpu: 1
env:
- name: KUDA_DEV
value: 'true'
" >.kuda-app.k8.yaml

# cat <<EOF | skaffold dev -n $namespace -f -
cat <<EOF | skaffold run -v debug -n $namespace -f -
cat <<EOF | skaffold dev -n $namespace -f -
apiVersion: skaffold/v1beta17
kind: Config
build:
Expand All @@ -102,8 +77,6 @@ build:
- src: '**/*'
dest: .
kaniko:
buildArgs:
verbosity: debug
buildContext:
localDir: {}
cache:
Expand Down
Loading

0 comments on commit f0161c8

Please sign in to comment.