This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/examples
Solomon Hykes 161e67de9a Develop Dagger with Dagger: new and improved
Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
2021-04-29 17:51:03 -07:00
..
docker stdlib: improved Docker package 2021-04-06 15:41:36 -07:00
hello-world New example: hello world 2021-04-01 20:34:47 -07:00
jamstack examples/jamstack: use a inputs.yaml instead of cue code 2021-04-27 12:11:33 -07:00
kubernetes-app tests(stdlib/k8s/helm): test basic helm chart 2021-04-15 14:24:42 +02:00
kubernetes-aws examples: kubernetes-aws: fix cuefmt 2021-04-01 16:49:58 -07:00
mini Fix linter 2021-04-01 17:49:15 -07:00
monitoring Docs: update and polish kubernetes-app and monitoring examples 2021-04-01 20:34:31 -07:00
react tests: fix react example test 2021-04-08 18:48:23 -07:00
simple-s3 Make S3 always do a Put 2021-04-29 21:34:12 +02:00
README.md examples/jamstack: use a inputs.yaml instead of cue code 2021-04-27 12:11:33 -07:00

Dagger Examples

All example commands should be executed in the examples/ directory in an up-to-date checkout of the dagger repository.

Deploy a static page to S3

This example shows how to generate a simple HTML page and serve it from an S3 bucket.

Components:

  1. Change the current directory to the example deployment plan and create a new deployment
cd ./simple-s3
dagger new
  1. Configure your AWS credentials
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
  1. Deploy!
dagger up
  1. Change a variable to alter the content

In this example config, the HTML content is created from a variable name that has a default value, here is a simple way to change it without changing the code:

dagger input text name "someone else!"
dagger up

Deploy a simple React application

This example shows how to deploy an example React Application. Read the deployment plan

Audience: Javascript developers looking to deploy their application.

Components:

  1. Change the current directory to the example deployment plan
cd ./react
  1. Create a new deployment from the plan
dagger new
  1. Configure the deployment with your Netlify access token. You can create new tokens from the Netlify dashboard.
dagger input text www.account.token MY_TOKEN

NOTE: there is a dedicated command for encrypted secret inputs, but it is not yet implemented. Coming soon!

  1. Deploy!
dagger up

Deploy a complete JAMstack app

This example shows how to deploy a complete app with a backend, a database and a frontend.

This app assumes the following infrastructure is available:

  • AWS ECS Cluster
  • AWS ALB with a TLS certificate
  • AWS RDS Instance (MySQL or PostgreSQL)
  • AWS ECR repository
  1. Create a new deployment from the plan
cd ./examples/jamstack
dagger new
  1. Edit the inputs

Edit the file inputs.yaml and review all values to match to your infrastructure.

Add the inputs to the deployment:

dagger input yaml "" -f ./inputs.yaml
  1. Deploy!
dagger up

The example inputs.yaml from the ./examples/jamstack directory takes the source code from a remote git repository, but you can remove this from the file and instead points to a local source code:

dagger input dir backend.source ./my/local/backend/code

And the same mechanism applies for every single key in this file.

  1. Get the App URL
dagger query url

Provision a Kubernetes cluster on AWS

This example shows how to provision a new Kubernetes cluster on AWS, and configure your kubectl client to use it. Read the deployment plan

Audience: infrastructure teams looking to provisioning kubernetes clusters as part of automated CICD pipelines.

Components:

  1. Change the current directory to the example deployment plan
cd ./kubernetes-aws
  1. Create a new deployment from the plan
dagger new
  1. Configure the deployment with your AWS credentials
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
  1. Deploy!
dagger up
  1. Export the generated kubectl config
dagger query kubeconfig.kubeconfig | jq . > kubeconfig

Add HTTP monitoring to your application

This example shows how to implement a robust HTTP(s) monitoring service on top of AWS. Read the deployment plan.

Audience: application team looking to improve the reliability of their application.

Components:

  1. Change the current directory to the example deployment plan
cd ./monitoring
  1. Create a new deployment from the plan
dagger new
  1. Configure the deployment with your AWS credentials
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
  1. Configure the monitoring parameters
dagger input text website https://MYWEBSITE.TLD
dagger input text email my_email@my_domain.tld
  1. Deploy!
dagger up

Deploy an application to your Kubernetes cluster

This example shows two different ways to deploy an application to an existing Kubernetes cluster: with and without a Helm chart. Read the deployment plan](https://github.com/dagger/dagger/tree/main/examples/kubernetes-app)

NOTE: this example requires an EKS cluster to allow authentication with your AWS credentials; but can easily be adapter to deploy to any Kubernetes cluster.

Components:

  • Amazon EKS for Kubernetes hosting
  • Kubectl as kubernetes client
  • Helm to manage kubernetes configuration (optional)

How to run:

  1. Change the current directory to the example deployment plan
cd ./kubernetes-app
  1. Create a new deployment from the plan
dagger new
  1. Configure the deployment with your AWS credentials
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
  1. Configure the EKS cluster to deploy to

Note: if you have run the kubernetes-aws example, you may skip this step.

dagger input text cluster.clusterName MY_CLUSTER_NAME
  1. Load the Helm chart
dagger input dir helmChart.chart=./kubernetes-app/testdata/mychart
  1. Deploy!
dagger up