-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: keel deploy command #1678
Open
jonbretman
wants to merge
1
commit into
main
Choose a base branch
from
keel-deploy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b8ef698
to
552ab6a
Compare
b7b4b15
to
4c02033
Compare
7878e31
to
73749aa
Compare
davenewza
reviewed
Dec 18, 2024
@@ -18,7 +18,7 @@ | |||
"prettier": "3.1.1" | |||
}, | |||
"dependencies": { | |||
"@teamkeel/functions-runtime": "0.394.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh!
73749aa
to
7752775
Compare
d4a671f
to
7e8cf9e
Compare
7e8cf9e
to
c5026b9
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Keel Deploy
This adds
keel deploy
to the CLI for deploying a Keel app to any AWS account (self-hosting).Key things to review
deploy.Build
The
Build
function in thedeploy
package creates the required assets needed for deploying and puts them into the.build
directory. There is no real use-case for users to do a manual but it is exposed under the command
keel deploy build`, mostly for debugging purposes so if something is going wrong you can have a look at the build files without needing to deploy.deploy.Run
The
Run
function in thedeploy
package either creates/updates all the necessary resources in AWS or it deletes all resources. These two actions correspond to the Pulumiup
anddeploy
commands. For our CLI they are exposed askeel deploy up
andkeel deploy remove
.IaC
The IaC code is all in
deploy/program.go
. I think it's fairly straight forward and I've tried to comment the bits that might be less obvious.Lambda handlers
This code is in
deploy/lambdas/runtime
anddeploy/lambdas/functions
. Most of what you see here was taken (and slightly modified) from the backend repo. The big difference here is rather than having separate packages for each Lambda (api, subscribers, jobs) we just have one and it uses a different handler function depending on an env var. Given they all do the same thing on boot and it's only the handler function that changes I think this is a nice approach.Integration tests
I have updated the
testing
package to use bothdeploy.Build
and the handlers from thedeploy/lambdas/...
package. This means by running the integration tests (or usingkeel test
) we are testing much of the code that is actually used in the deployed environments, rather than having test-specific code.One interesting aspect of how this works is mocking AWS API calls. This is done with a little mock server in
testing/aws.go
, which knows how to handle the few API calls the runtime handler makes on boot (for example to get secrets) as well as things like SQS and S3 usage. This works by configuring the runtime Lambda code to use a custom endpoint when constructing AWS clients.Manual testing
First you need to build the runtime Lambda binary, which you can do by running this command in the repo:
Then you can do a deploy by running the CLI:
The Keel app must have a
keelconfig.<env>.yaml
file with adeploy
section in it. A minimal valid config looks like this:Other than you just need to be authenticated into the AWS account you want to deploy to. A first deploy with RDS will take around 5 minutes and updates around 2 minutes.
To destroy all resources in AWS you run the same command but replace
up
withremove
.Key features
keel deploy logs
command. This is fairly basic at the moment but even so it's probably nicer than digging around in Cloudwatch logs.keel deploy secrets set
etc... Note this is a different command to the one for setting local secrets -keel secrets
.keel deploy
will use Amazon RDS for the database but you can use any publicly available Postgres database by setting thedeploy.database.provider
value in config to "external" and setting aDATABASE_URL
secret.deploy.telemetry.collector
value in config to an OpenTelemetry collector config file. If you set this then the collector layer will be included.Docs
A docs PR is on it's way...