From 20ceae03f721cbf11304030277a04f4eb70d722b Mon Sep 17 00:00:00 2001 From: Onur Filiz Date: Fri, 23 Mar 2018 17:09:16 -0700 Subject: [PATCH] Add sample config file and instructions --- providers/aws/README.md | 32 +++++++++++++++++++++++++ providers/aws/fargate.toml | 39 +++++++++++++++++++++++++++++++ providers/aws/fargate/region.go | 41 +++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 providers/aws/README.md create mode 100644 providers/aws/fargate.toml create mode 100644 providers/aws/fargate/region.go diff --git a/providers/aws/README.md b/providers/aws/README.md new file mode 100644 index 000000000..59b5c2cbe --- /dev/null +++ b/providers/aws/README.md @@ -0,0 +1,32 @@ +# AWS Fargate + +[AWS Fargate](https://aws.amazon.com/fargate/) is a technology for deploying and managing containers +without having to manage any of the underlying infrastructure. With AWS Fargate, you no longer have +to provision, configure, and scale clusters of virtual machines to run containers. This removes the +need to choose server types, decide when to scale your clusters, or optimize cluster packing. + +Fargate makes it easy to scale your applications. You no longer have to worry about provisioning +enough compute resources. You can launch tens or tens of thousands of containers in seconds. Fargate +lets you focus on designing and building your applications instead of managing the infrastructure +that runs them. + +With Fargate, billing is at a per second granularity and you only pay for what you use. You pay for +the amount of vCPU and memory resources your containerized application requests. vCPU and memory +resources are calculated from the time your container images are pulled until they terminate, +rounded up to the nearest second. + +## Fargate virtual-kubelet provider + +Fargate virtual-kubelet provider configures a Fargate cluster in AWS. Fargate resources show as a +node in your Kubernetes cluster. Pods scheduled on the Fargate node are deployed as Fargate +instances as if Fargate is a standard Kubernetes node. + +## Configuration + +A [sample configuration file](fargate.toml) is available. + +## Usage + +`` +virtual-kubelet --provider aws --provider-config fargate.toml +`` diff --git a/providers/aws/fargate.toml b/providers/aws/fargate.toml new file mode 100644 index 000000000..5d2fe205c --- /dev/null +++ b/providers/aws/fargate.toml @@ -0,0 +1,39 @@ +# +# Example configuration file for virtual-kubelet AWS Fargate provider. +# +# Usage: +# virtual-kubelet --provider aws --provider-config fargate.toml +# + +# AWS region where Fargate resources are provisioned. Mandatory. +Region = "us-east-1" + +# Fargate cluster name. Optional. Defaults to "default". +# If a cluster with this name does not exist in the region, virtual-kubelet will create it. +# Although the same Fargate cluster can be shared by multiple virtual-kubelets, +# we recommend to create a dedicated Fargate cluster for each virtual-kubelet. +ClusterName = "fargate1" + +# List of subnets that pods are connected to. Mandatory. +Subnets = ["subnet-12345678"] + +# List of security groups for pods. Optional. +# If omitted, pods inherit their VPC's default security group. +SecurityGroups = ["sg-12345678", "sg-87654321"] + +# Whether pod ENIs are assigned a public IPv4 address. Optional. Defaults to false. +AssignPublicIPv4Address = false + +# Fargate platform version. Optional. Defaults to "LATEST". +# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html +PlatformVersion = "LATEST" + +# Operating system for pods. Optional. Defaults to "Linux". +OperatingSystem = "Linux" + +# Fargate capacity advertised by virtual-kubelet. Optional. Defaults to the values below. +# Capacity is specified using Kubernetes resource format. +# https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ +CPU = "20" +Memory = "40Gi" +Pods = "20" diff --git a/providers/aws/fargate/region.go b/providers/aws/fargate/region.go new file mode 100644 index 000000000..4f14ce800 --- /dev/null +++ b/providers/aws/fargate/region.go @@ -0,0 +1,41 @@ +package fargate + +import ( + "strings" +) + +// Regions is the set of AWS regions where a service is available. +// https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/ +type Regions []string + +var ( + // FargateRegions are AWS regions where Fargate is available. + FargateRegions = Regions{ + "us-east-1", + } +) + +// Include returns whether the region set includes the given region. +func (r Regions) Include(region string) bool { + region = strings.ToLower(region) + region = strings.Trim(region, " ") + + for _, name := range r { + if name == region { + return true + } + } + + return false +} + +// Names returns an array of region names. +func (r Regions) Names() []string { + names := make([]string, 0, len(r)) + + for _, name := range r { + names = append(names, name) + } + + return names +}