Add a /api/deploy endpoint for the k8s hosted site#641
Merged
Conversation
Add a webhook responder using a sidecar container to securely validate and pull from the repo, in response to GH push webevents. We can do this directly without needing to poll for lock files.
darcywong00
reviewed
Nov 3, 2022
mcdurdin
approved these changes
Nov 3, 2022
Member
mcdurdin
left a comment
There was a problem hiding this comment.
I think LGTM although there's a lot of k8s special sauce magic that I don't really grok!
Make it clear this a dummy key for testing purposes, so should be here, and it should not be used in production.
Contributor
Author
|
Not sure where this kind of detail should go, as it seems a bit long for a yaml comment, but to trigger the deploy hook with a minimal simulated GitHub event, you can use the following on a docker-desktop k8s cluster deployed pod: $> curl -v --request POST \
-H "Content-Type: application/json" \
-H "X-Hub-Signature-256: sha256=49af8531106a369bfee369f91dadec597e8ea3992ec2802bbe655be0ece17f15" \
--data '{"action":"push","ref":"refs/heads/staging"}' \
help.keyman.com.localhost:30900/api/deploy |
Member
|
README.md
…On Thu, 3 Nov 2022, 3:41 pm Tim Eves, ***@***.***> wrote:
Not sure where this kind of detail should go, as it seems a bit long for a
yaml comment, but to trigger the deploy hook with a minimal simulated
GitHub event, you can use the following on a docker-desktop k8s cluster
deployed pod:
$> curl -v --request POST \
-H "Content-Type: application/json" \
-H "X-Hub-Signature-256: sha256=49af8531106a369bfee369f91dadec597e8ea3992ec2802bbe655be0ece17f15" \
--data '{"action":"push","ref":"refs/heads/staging"}' \
help.keyman.com.localhost:30900/api/deploy
—
Reply to this email directly, view it on GitHub
<#641 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABCKHPM36QFEDRUJOJ25W5DWGM7ALANCNFSM6AAAAAARVXHF5I>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
Explain how to bring up the Kubernetes pod and resources to simulate deployment, and test a near production environment.
This file contains hidden or 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
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.
This implements a deploy webhook by having a dedicated small responder directly perform a git pull. It turns out to be less trouble than watching for files in sidecar container, and more efficient than polling in a bash script signal files. This only maps the /api/deploy path to respond to GH push webhook events, leaving the rest of the '/api' space for the site's php. It is integrated to pull the secret from k8s a Secret volume (not defined here) and configuration (branch name to deploy, deploy script, and responder config) from k8s ConfigMap (included).