项目作者: superluminar-io

项目描述 :
super-eks is a CDK construct that provides a preconfigured EKS installation with batteries included.
高级语言: TypeScript
项目地址: git://github.com/superluminar-io/super-eks.git
创建时间: 2020-11-12T11:08:10Z
项目社区:https://github.com/superluminar-io/super-eks

开源协议:Apache License 2.0

下载


:no_entry_sign: This project is now archived and exists only for reference :no_entry_sign:

Try https://github.com/aws-quickstart/cdk-eks-blueprints instead!

:superhero_woman: super-eks

:warning: This branch is using cdk v2: If you are looking for the old cdk v1 version go here

super-eks is a CDK>) construct that provides a preconfigured EKS installation with batteries included.
Even when using best practices for your EKS cluster, picking the right setup can be overwhelming.
super-eks solves this problem by making a few choices for you as outlined below.

:sparkles: Features

:world_map: Roadmap

  • :hammer_and_wrench: Monitoring with Prometheus and CloudWatch #21
  • :hammer_and_wrench: Backup solution for cluster recovery #386
  • :hammer_and_wrench: Authentication/authorization for workloads with Amazon Cognito #383
  • :hammer_and_wrench: Autoscaling for pods #385
  • :hammer_and_wrench: Autoscaling for cluster #382
  • :hammer_and_wrench: CDK v2 support #387

:clapper: Quick Start

The quick start shows you how to setup a super-eks cluster.

Prerequisites

  • A working aws CLI installation with access to an account and administrator privileges
  • You’ll need a recent NodeJS installation
  • kubectl to interact with your fresh cluster
  • An editor of your choice
  • Roughly 30 minutes of your time and a :coffee:, :tea: or :beverage_box:

To get going you’ll need a CDK project. For details please refer to the detailed guide for CDK.

Create an empty directory on your system.

  1. mkdir super-eks-setup && cd super-eks-setup

Bootstrap your CDK project, we will use TypeScript, but you can switch to any other supported language.

  1. npx cdk init sample-app --language typescript
  2. npx cdk bootstrap # Has to be done once for your AWS account

Now install the super-eks library.

  1. npm i @superluminar-io/super-eks

You need to provide a Route53 @aws-cdk_aws-route53.HostedZone.html">Hosted zone and super-eks will take care of the rest.

  1. npm i @aws-cdk/aws-route53

Paste the snippet into lib/super-eks-setup-stack.ts.

  1. import * as cdk from "@aws-cdk/core";
  2. import { HostedZone } from "@aws-cdk/aws-route53";
  3. import { SuperEks } from "@superluminar-io/super-eks";
  4. export class SuperEksSetupStack extends cdk.Stack {
  5. constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
  6. super(scope, id, props);
  7. // Assumes you already have a Route53 zone in your account
  8. const hostedZone = HostedZone.fromLookup(this, "MyZone", {
  9. domainName: "example.com", // Your domain goes here
  10. });
  11. // Setup super-eks
  12. const superEks = new SuperEks(this, "hello-eks", {
  13. hostedZone: hostedZone,
  14. });
  15. // Add nginx installation for testing
  16. superEks.cluster.addHelmChart("nginx", {
  17. createNamespace: true,
  18. namespace: "nginx",
  19. repository: "https://charts.bitnami.com/bitnami",
  20. chart: "nginx",
  21. release: "nginx",
  22. version: "8.5.2",
  23. values: {
  24. ingress: {
  25. enabled: true,
  26. hostname: `nginx.${hostedZone.zoneName}`,
  27. annotations: {
  28. "kubernetes.io/ingress.class": "alb",
  29. "alb.ingress.kubernetes.io/scheme": "internet-facing",
  30. "alb.ingress.kubernetes.io/target-type": "ip",
  31. },
  32. },
  33. },
  34. });
  35. }
  36. }

Now deploy the stack.

  1. npx cdk deploy

If everything works, you should see some output.

  1. IntegrationTestsStack
  2. Outputs:
  3. IntegrationTestsStack.EksClusterConfigCommandAEB22784 = aws eks update-kubeconfig --name EksCluster3394B24C-86f946f02a67416c80413e123d58b628 --region eu-central-1 --role-arn arn:aws:iam::123456789012:role/IntegrationTestsStack-EksClusterMastersRoleA746276-GNW143CGOXG7
  4. IntegrationTestsStack.EksClusterGetTokenCommand53BD6035 = aws eks get-token --cluster-name EksCluster3394B24C-86f946f02a67416c80413e123d58b628 --region eu-central-1 --role-arn arn:aws:iam::123456789012:role/IntegrationTestsStack-EksClusterMastersRoleA746276-GNW143CGOXG7
  5. Stack ARN:
  6. arn:aws:cloudformation:eu-central-1:123456789012:stack/IntegrationTestsStack/06273460-660e-11eb-b4d9-06da4ef2f41a
  7. Done in 1757.52s.
  8. Done in 1757.79s.

Paste the aws eks update-kubeconfig command into your shell. This will update your kubeconfig.

  1. aws eks update-kubeconfig --name EksCluster3394B24C-86f946f02a67416c80413e123d58b628 --region eu-central-1 --role-arn arn:aws:iam::123456789012:role/IntegrationTestsStack-EksClusterMastersRoleA746276-GNW143CGOXG7
  2. Added new context arn:aws:eks:eu-central-1:123456789012:cluster/EksCluster3394B24C-86f946f02a67416c80413e123d58b628 to /home/super-eks/.kube/config

Now let’s see if it works.

  1. NAMESPACE NAME READY STATUS RESTARTS AGE
  2. dns external-dns-7d4d69545d-r5w68 1/1 Running 0 14m
  3. logging aws-for-fluent-bit-qwhwb 1/1 Running 0 14m
  4. logging aws-for-fluent-bit-s7wnj 1/1 Running 0 14m
  5. ingress aws-load-balancer-controller-5b9cbc5497-smfrt 1/1 Running 0 14m
  6. kube-system aws-node-lscgc 1/1 Running 0 18m
  7. kube-system aws-node-zfcdl 1/1 Running 0 18m
  8. kube-system coredns-59b69b4849-9gstn 1/1 Running 0 25m
  9. kube-system coredns-59b69b4849-bssnr 1/1 Running 0 25m
  10. kube-system kube-proxy-9sgtt 1/1 Running 0 18m
  11. kube-system kube-proxy-r4gzg 1/1 Running 0 18m
  12. nginx nginx-67cb444d48-lqzkg 1/1 Running 0 14m

Voila! :tada: You now have a super EKS cluster with batteries included!

:lock_with_ink_pen: Configuring external secrets

External secrets in EKS is automatically deployed and configured. We configure it in such a way that if you tag your secrets with SuperEKS: secrets, external secrets will have access. You can follow
the documentation to setup secrets but need to tag your secrets in secrets manager, e.g., when creating:

  1. aws secretsmanager create-secret --name hello-service/password --secret-string "1234" --tags Key=SuperEKS,Value=secrets

The service account that will be used by external secrets uses a condition in the IAM policy so that access will be automatically granted.
To keep the setup secure and sound you have to set namespace annotations for secrets as described in the
original documentation.

:open_book: API documentation

See the API documentation for details.

:gear: Development

:question: FAQ

Frequently asked questions are answered here.

What do you mean by “batteries included”?

Batteries included is a term that comes from the philosophy behind the Python programming language.
It means, that super-eks ships with all necessary parts. You don’t need additional things, like in this case Helm charts, manifests etc. apart from the workload you want to run on Kubernetes.

Why did you choose to include component X?

We try to include components, that are seen as community standards. On the other hand we choose components,
that work best in combination with AWS.

Where are the advanced settings? I want to do things differently

super-eks makes some decisions for you. If you want an expert setup maybe super-eks isn’t for you.
If you believe core functionality is missing please open a GitHub issue.

Our approach is to offer opinionated solutions, but we aim to offer the possibility to opt out, as well.

I don’t want to use CDK? Do you offer alternatives?

No, not for now.

:balance_scale: License

super-eks is distributed under the Apache License, Version 2.0.

See LICENSE for more information.