Skip to main content

EKS library for the Halloumi modules of the AWS CDK

Project description

Github

Halloumi EKS for the CDK

EKS library for the Halloumi modules of the AWS CDK

Installation

pip install hcdk_eks

Usage

Halloumi EKS can be used as a basis to deploy EKS clusters with managed Nodegroups on AWS using the CDK.

Passing your own VPC

Example

Within a sample stack, the following example code should be present for minimum functionality.

self.eks_cluster_public_subnet_name = 'eks_public'
self.eks_cluster_private_subnet_name = 'eks_private'
self.eks_cluster_name = 'EksCluster'
self.eks_stack_name = 'eks-cluster-stack'

# prerequisites for EKS
self.vpc = ec2.Vpc(
    self, 'Vpc',
    cidr='10.0.0.0/16',
    max_azs=99,  # use all available AZs,
    subnet_configuration=[
        {
            'cidrMask': 26,
            'name': self.eks_cluster_public_subnet_name,
            'subnetType': ec2.SubnetType.PUBLIC
        },
        {
            'cidrMask': 24,
            'name': self.eks_cluster_private_subnet_name,
            'subnetType': ec2.SubnetType.PRIVATE
        }
    ]
)

# Add necessary tags to subnets for the EKS Cluster
private_eks_subnets = self.vpc.select_subnets(
    subnet_name=self.eks_cluster_private_subnet_name
).subnets
for subnet in private_eks_subnets:
    core.Tag.add(
        subnet,
        key=f'kubernetes.io/cluster/{self.eks_cluster_name}',
        value='shared'
    )
    core.Tag.add(
        subnet,
        key=f'kubernetes.io/role/internal-elb',
        value='1'
    )

# Add necessary tags to subnets for the EKS Cluster
public_eks_subnets = self.vpc.select_subnets(
    subnet_name=self.eks_cluster_public_subnet_name
).subnets
for subnet in public_eks_subnets:
    core.Tag.add(
        subnet,
        key=f'kubernetes.io/cluster/{self.eks_cluster_name}',
        value='shared'
    )
    core.Tag.add(
        subnet,
        key=f'kubernetes.io/role/elb',
        value='1'
    )

EKS Cluster

Example

from hcdk_eks import HalloumiEksCluster

app = core.App()

sample_stack = SampleAppStack(app, "sample-app")

__config_eks_cluster = {
    'stack_name': sample_stack.eks_stack_name,
    'eks_cluster_public_subnet_name': sample_stack.eks_cluster_public_subnet_name,
    'eks_cluster_private_subnet_name': sample_stack.eks_cluster_private_subnet_name,
    'eks_cluster_name': sample_stack.eks_cluster_name,
    'kubernetes_version': '1.14',
    'nodegroups': {
        'nodegroup1': {
            'instance_types': [
                't3.large'
            ]
        },
        'nodegroup2': {
            'instance_types': [
                't3.xlarge'
            ]
        }
    }
}

eks_stack = cfn.NestedStack(
    sample_stack, 'eks-stack'
)

HalloumiEksCluster(
    scope=eks_stack,
    vpc=sample_stack.vpc,
    config=__config_eks_cluster
)

app.synth()

Using the VPC from the module

Example

from hcdk_eks import HalloumiEksCluster

app = core.App()
sample_stack = SampleAppStack(app, "sample-app")

__config_eks_cluster = {
    'nodegroups': {
        'nodegroup1': {
            'instance_types': [
                't3.large'
            ]
        },
        'nodegroup2': {
            'instance_types': [
                't3.xlarge'
            ]
        }
    }
}

# EKS Cluster Stack
eks_cluster_stack = cfn.NestedStack(
    sample_stack, 'eks-cluster-stack'
)

eks_cluster = HalloumiEksCluster(
    scope=eks_cluster_stack,
    config=__config_eks_cluster
)

synth = app.synth()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hcdk_eks-0.0.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

hcdk_eks-0.0.3-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file hcdk_eks-0.0.3.tar.gz.

File metadata

  • Download URL: hcdk_eks-0.0.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for hcdk_eks-0.0.3.tar.gz
Algorithm Hash digest
SHA256 8441d8b1e3cb3d5cb84e2d16722ec6360b294b41d5905ca9c368c5c4593af449
MD5 8639c691ea72fc86d6b402772cf18f5b
BLAKE2b-256 e10e233e762c6a2a73dbf8392136dd6e207d32855376d7e541e2ec392da3bb4a

See more details on using hashes here.

File details

Details for the file hcdk_eks-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: hcdk_eks-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for hcdk_eks-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4ef430a0c0d81bf7267057495bfa9953cea80d84b2369fc61f083babb8cc9606
MD5 15491e26b2a9dd70025b1b7720f26d26
BLAKE2b-256 4c9dd209292c76f719b2e3c1b802cfcbf0c56bd76922110c4a237a0606db2ede

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page