From 48e8b200ae6068358167e3b0dd0e73408b1ff869 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 1 Apr 2021 22:37:14 +0000 Subject: [PATCH] Docs: update and polish "Kubernetes on AWS" example Signed-off-by: Solomon Hykes --- examples/README.md | 55 +++++++++++++++---- .../cfn_template_eks_controlplane.cue | 0 .../cfn_template_eks_nodegroup.cue | 0 .../infrastructure.cue | 0 examples/{aws-eks => kubernetes-aws}/main.cue | 8 +-- 5 files changed, 48 insertions(+), 15 deletions(-) rename examples/{aws-eks => kubernetes-aws}/cfn_template_eks_controlplane.cue (100%) rename examples/{aws-eks => kubernetes-aws}/cfn_template_eks_nodegroup.cue (100%) rename examples/{aws-eks => kubernetes-aws}/infrastructure.cue (100%) rename examples/{aws-eks => kubernetes-aws}/main.cue (75%) diff --git a/examples/README.md b/examples/README.md index b4ecce4c..01fb5c00 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,9 +3,11 @@ All example commands should be executed in the `examples/` directory in an up-to-date checkout of the [dagger repository](https://github.com/dagger/dagger). -## react: Deploy a simple React application +## Deploy a simple React application -This example shows how to deploy an example React Application. +This example shows how to deploy an example React Application. [Read the deployment plan](https://github.com/dagger/dagger/tree/main/examples/react) + +Audience: Javascript developers looking to deploy their application. Components: @@ -43,18 +45,51 @@ dagger up ``` -## aws-eks: Kubernetes on AWS (EKS) +## Provision a Kubernetes cluster on AWS -This example provisions a Kubernetes (EKS) cluster on AWS using Cloudformation, -it also outputs the new generated kubeconfig for the `kubectl` client. +This example shows how to provision a new Kubernetes cluster on AWS, and configure your `kubectl` client to use it. [Read the deployment plan](https://github.com/dagger/dagger/tree/main/examples/kubernetes-aws) -How to run: +Audience: infrastructure teams looking to provisioning kubernetes clusters as part of automated CICD pipelines. + +Components: + +- [Amazon EKS](https://aws.amazon.com/eks) for Kubernetes hosting +- [Amazon CloudFormation](https://aws.amazon.com/cloudformation) for infrastructure provisioning +- [Kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) as kubernetes client + +1. Change the current directory to the example deployment plan ```sh -dagger compute ./aws-eks \ - --input-string awsConfig.accessKey="MY_AWS_ACCESS_KEY" \ - --input-string awsConfig.secretKey="MY_AWS_SECRET_KEY" \ - | jq -j '.kubeconfig.kubeconfig' > kubeconfig +cd ./kubernetes-aws +``` + +2. Create a new deployment from the plan + +```sh +dagger new +``` + +3. Configure the deployment with your AWS credentials + +```sh +dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY +``` + +```sh +dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY +``` + + +4. Deploy! + +```sh +dagger up +``` + +5. Export the generated kubectl config + +```sh +dagger query kubeconfig.kubeconfig | jq . > kubeconfig ``` ## aws-monitoring: HTTP Monitoring on AWS diff --git a/examples/aws-eks/cfn_template_eks_controlplane.cue b/examples/kubernetes-aws/cfn_template_eks_controlplane.cue similarity index 100% rename from examples/aws-eks/cfn_template_eks_controlplane.cue rename to examples/kubernetes-aws/cfn_template_eks_controlplane.cue diff --git a/examples/aws-eks/cfn_template_eks_nodegroup.cue b/examples/kubernetes-aws/cfn_template_eks_nodegroup.cue similarity index 100% rename from examples/aws-eks/cfn_template_eks_nodegroup.cue rename to examples/kubernetes-aws/cfn_template_eks_nodegroup.cue diff --git a/examples/aws-eks/infrastructure.cue b/examples/kubernetes-aws/infrastructure.cue similarity index 100% rename from examples/aws-eks/infrastructure.cue rename to examples/kubernetes-aws/infrastructure.cue diff --git a/examples/aws-eks/main.cue b/examples/kubernetes-aws/main.cue similarity index 75% rename from examples/aws-eks/main.cue rename to examples/kubernetes-aws/main.cue index e605701f..59607229 100644 --- a/examples/aws-eks/main.cue +++ b/examples/kubernetes-aws/main.cue @@ -5,9 +5,7 @@ import ( "dagger.io/aws/eks" ) -// Fill using: -// --input-string awsConfig.accessKey=XXX -// --input-string awsConfig.secretKey=XXX +// AWS account: credentials and region awsConfig: aws.#Config & { region: *"us-east-2" | string } @@ -20,11 +18,11 @@ awsConfig: aws.#Config & { infra: #Infrastructure & { "awsConfig": awsConfig namePrefix: "dagger-example-" - // Cluster size is 1 for the example purpose - workerNodeCapacity: 1 + workerNodeCapacity: int | *1 workerNodeInstanceType: "t3.small" } +// Client configuration for kubectl kubeconfig: eks.#KubeConfig & { config: awsConfig clusterName: infra.clusterName