跳到正文

Managed Infrastructure ​

AWS has a catalog of managed infrastructure services that support and complement Kubernetes clusters and their workloads.

At a minimum, networking must be configured for deployment of an EKS cluster.

AWS exposes a Virtual Private Cloud API which can be used to create resources into a virtual network. With the VPC you can define the region's Availability Zones to use, alongwith Route Tables, Subnets, Internet Gateways, NAT Gateways and Security Groups.

The full code for this stack is on GitHub.

Overview ​

We'll configure and deploy:

  • Networking: To provide a virtual network for the cluster.
  • Storage: To provide data stores for the cluster.

Networking ​

In Crosswalk for AWS we showcase how to define networking:

Create a New VPC for Kubernetes ​

Create a new VPC to use with the cluster with custom settings and best-practice defaults.

typescript
import * as awsx from "@pulumi/awsx";

// Create a new VPC with custom settings.
const vpcName = "eksVpc";
const vpc = new awsx.ec2.Vpc(vpcName, {
    cidrBlock: "172.16.0.0/16",
    numberOfAvailabilityZones: "all",
    tags: { "Name": vpcName },
});

// Export the VPC resource IDs.
export const vpcId = vpc.id;
export const publicSubnetIds = vpc.publicSubnetIds;
export const privateSubnetIds = vpc.privateSubnetIds;

Use the Default VPC with Kubernetes ​

Use the account's default VPC.

typescript
import * as awsx from "@pulumi/awsx";

// Use the default VPC.
const defaultVpc = awsx.ec2.Vpc.getDefault();

// Export the VPC resource IDs.
export const defaultVpcId = defaultVpc.id;
export const defaultPublicSubnetIds = defaultVpc.publicSubnetIds;
export const defaultPrivateSubnetIds = defaultVpc.privateSubnetIds;

Use an Existing VPC with Kubernetes ​

To use an existing VPC, provide the IDs of the VPC and its resources.

typescript
import * as awsx from "@pulumi/awsx";

// Use an existing VPC, subnets, and gateways.
const existingVpc = awsx.ec2.Vpc.fromExistingIds("existingVpc", {
    vpcId: "vpc-00000000000000000",
    publicSubnetIds: ["subnet-00000000000000000", "subnet-11111111111111111"],
    privateSubnetIds: ["subnet-22222222222222222", "subnet-33333333333333333"],
    internetGatewayId: "igw-00000000000000000",
    natGatewayIds: ["nat-00000000000000000", "nat-11111111111111111"],
})

// Export the VPC resource IDs.
export const existingVpcId = existingVpc.id;
export const existingPublicSubnetIds = existingVpc.publicSubnetIds;
export const existingPrivateSubnetIds = existingVpc.privateSubnetIds;

Requirements & Recommendations ​

See the official docs EKS Network Requirements and AWS VPC Recommendations for more details.

Storage ​

Cloud storage persists data in many forms, from data warehouses to analytics, and is presented as object, file, block storage, and migration capabilities.

Generally, the storage services in this stack tend to be foundational for teams, and is typically shared across clusters and orgs.

In the managed clusters, the worker node groups by default will use block devices, and Kubernetes itself could manage PersistentVolumes.

Often times, this layer may be conflated with storage services managed in stacks closer to the apps, such as the Kubernetes Cluster Services or App Services. Those higher layers tend to primarily focus on the direct needs of a given Kubernetes cluster and its apps, rather than the needs of your complete architecture.

Amazon Simple Storage Service (S3) ​

See Crosswalk AWS S3 and the AWS S3 docs for more details.

Elastic Container Registry (ECR) ​

See Crosswalk AWS ECR and the AWS ECR docs for more details.

Amazon Elastic File System (EFS) ​

See Persisting Kubernetes Workloads with Amazon EFS and the AWS EFS docs for more details.

文档内容翻译自 Pulumi 官方文档。