-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR solves issue #36 and Naiserator is now able to publish Protobuf messages to Kafka once when a deployment is initialised and also when a deployment has succeed. I've also added tests, a makefile function and helpful docs in the README. If one wants to test it out for themselves. What this feature implements is a kafka package that handles the kafka client , config, producer and event channel. A deployment package which is just the package generated from the event.proto file. And a generators package which generates these events for us. We've put most of the functionality into the synchronize loop, where it sends one event on initialization and monitors the app before sending a subsequent event on successful deployment. I and @ambientsound have been working on this issue over slack and in person, so there's no discussion here on Github. But the solution is also pretty much done as far as I can tell. So it's basically ready to be merged. Feedback is still very welcome! CHANGELOG: * [Feature] Added basic kafka and protobuf integrations This is by no means complete, but it's a start. I've implemented a skeleton for the kafka configuration. Added Makefiles and helpful developer docs in the README. I've also started on the kafka package which shows the design i'm thinking of going with, which is a producerLoop, listening on a channel, and in some way receiving the protobuf Event struct on that channel. The way it recieves the struct I've still not decided on. * [Feature] added deployment struct, event contexts, and app rollout etc. This is just a basic first draft of how I think it should look, nothing final. And I'm not super happy with the design, but can't find anything better currently. * [Chore] Removed event.proto and added gitignore * [Refactor] Moved application Rollout check to naiserator package, etc. Now the logic that checks if an app is deployed is moved to the naiserator package, which is a much better fit. Now it's a continuous check if the deployment has all of it's pods ready and when that condition is met, a bool is sent over channel to signify that the application is ready. This is then again used by a function in the kafka package which waits for 5 minutes for a bool to be sent over that channel before it times out. If the bool is sent an event is then sent over to kafka. Other than that I did som small changes to logging. But there's more work to be done here. * [Chore] Logging and error handling changes * [Feature] Added basic kafka and protobuf integrations This is by no means complete, but it's a start. I've implemented a skeleton for the kafka configuration. Added Makefiles and helpful developer docs in the README. I've also started on the kafka package which shows the design i'm thinking of going with, which is a producerLoop, listening on a channel, and in some way receiving the protobuf Event struct on that channel. The way it recieves the struct I've still not decided on. * [Feature] added deployment struct, event contexts, and app rollout etc. This is just a basic first draft of how I think it should look, nothing final. And I'm not super happy with the design, but can't find anything better currently. * [Chore] Removed event.proto and added gitignore * [Refactor] Moved application Rollout check to naiserator package, etc. Now the logic that checks if an app is deployed is moved to the naiserator package, which is a much better fit. Now it's a continuous check if the deployment has all of it's pods ready and when that condition is met, a bool is sent over channel to signify that the application is ready. This is then again used by a function in the kafka package which waits for 5 minutes for a bool to be sent over that channel before it times out. If the bool is sent an event is then sent over to kafka. Other than that I did som small changes to logging. But there's more work to be done here. * move code to deployment event generation module * refactor kafka event logic * [Feature] Added function to get the hash of the container iamge We need the hash of the container image for the kafka depoyment events, so I've implemented a simple function that gets all the pods that has an app label matching the app name. Then it get's the container statuses of those pods and extracts the ContainerID, in which the last 64 chars are always the sha256 hash. * [Feature] Deployment CorrelationID saved in kubernetes and equal on both deployment events * [Bug fix] added return to MonitorRollout, so the goroutine is closed and a successful kafka message is only sent one time * [Refactor] Moved UUID generation into the syncronize loop Now the uuid generation can fail and the sending of events would stop. I also changed the NewDeploymentEvent function to use the app annotation `nais.io/deployment-correlation-id` as it's correlationID. This way it's set at the start and subsequent events all have that correlationID automatically, as it's stored in the app. * propagate correlation ID everywhere * add docker container reference parser * [Chore] Removed unused ContainerImageHash function * use gettag * write first test for deployment event * get clusterName from app and order event fields * expose NAIS cluster name in Application resource * [Tests] 100% Test coverage for generator * [Chore] Added check if kafka is enabled * [Chore] Cleanup config options and functions * Revert "[Chore] Cleanup config options and functions" This reverts commit 4cb9d2a. * [Chore] Removed SignatureKey Option * Rename default topic from deploymentStatus to deploymentEvents * clarify readme * kafka logging includes application logger context * prevent nil crash when setting correlation id * include correlation id and application name in log messages
- Loading branch information
Kasper Furnes Bernhoff
authored
Jul 17, 2019
1 parent
7fdb043
commit 8220f38
Showing
18 changed files
with
1,049 additions
and
25 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ cmd/naiserator/naiserator | |
vendor/ | ||
cover.out | ||
./naiserator | ||
*.proto |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: "3" | ||
services: | ||
kafka: | ||
image: "spotify/kafka" | ||
ports: | ||
- "9092:9092" | ||
environment: | ||
ADVERTISED_HOST: localhost | ||
ADVERTISED_PORT: 9092 |
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
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
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
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
Oops, something went wrong.