Skip to content

Commit

Permalink
CI-999: Modify console template on creation to add tlog (gocardless#243)
Browse files Browse the repository at this point in the history
CI-1010: Modify console operator to add sidecar

* Create a volume to write the tlog data to
* Add the volume mount to the main container
* Modify the main container commands to wrap everything in tlog
* Add a sidecar that runs our wrapper and pubsubtle (log data pusher)
* Add rolebinding for service account to read pod status
* Handle case of missing service account name
* Add topic ID and project ID as flags and pass through to sidecar
  • Loading branch information
VSpike authored Dec 10, 2021
1 parent 641ed66 commit 13e679d
Show file tree
Hide file tree
Showing 5 changed files with 292 additions and 41 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.5.0
3.6.0
37 changes: 29 additions & 8 deletions cmd/workloads-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ import (
var (
scheme = runtime.NewScheme()

app = kingpin.New("workloads-manager", "Manages workloads.crd.gocardless.com resources").Version(cmd.VersionStanza())
contextName = app.Flag("context-name", "Distinct name for the context this controller runs within. Usually the user-facing name of the kubernetes context for the cluster").Envar("CONTEXT_NAME").String()
pubsubProjectId = app.Flag("pubsub-project-id", "ID for the project containing the Pub/Sub topic for console event publishing").Envar("PUBSUB_PROJECT_ID").String()
pubsubTopicId = app.Flag("pubsub-topic-id", "ID of the topic to publish lifecycle event messages").Envar("PUBSUB_TOPIC_ID").String()
app = kingpin.New("workloads-manager", "Manages workloads.crd.gocardless.com resources").Version(cmd.VersionStanza())
contextName = app.Flag("context-name", "Distinct name for the context this controller runs within. Usually the user-facing name of the kubernetes context for the cluster").Envar("CONTEXT_NAME").String()
pubsubProjectId = app.Flag("pubsub-project-id", "ID for the project containing the Pub/Sub topic for console event publishing").Envar("PUBSUB_PROJECT_ID").String()
pubsubTopicId = app.Flag("pubsub-topic-id", "ID of the topic to publish lifecycle event messages").Envar("PUBSUB_TOPIC_ID").String()
enableSessionRecording = app.Flag("session-recording", "Enable session recording features").Envar("ENABLE_SESSION_RECORDING").Default("false").Bool()
sessionSidecarImage = app.Flag("session-sidecar-image", "Container image to use for the session recording sidecar container").Envar("SESSION_SIDECAR_IMAGE").Default("").String()
sessionPubsubProjectId = app.Flag("session-pubsub-project-id", "ID for the project containing the Pub/Sub topic for session recording").Envar("SESSION_PUBSUB_PROJECT_ID").Default("").String()
sessionPubsubTopicId = app.Flag("session-pubsub-topic-id", "ID of the topic to publish session recording data to").Envar("SESSION_PUBSUB_TOPIC_ID").Default("").String()

commonOpts = cmd.NewCommonOptions(app).WithMetrics(app)
)
Expand All @@ -44,6 +48,19 @@ func main() {
ctx, cancel := signals.SetupSignalHandler()
defer cancel()

// Check flag validity for session recording
if *enableSessionRecording {
if len(*sessionSidecarImage) == 0 {
app.Fatalf("Session recording sidecar image parameter must be set")
}
if len(*sessionPubsubProjectId) == 0 {
app.Fatalf("Session recording Google project ID must be set")
}
if len(*sessionPubsubTopicId) == 0 {
app.Fatalf("Session recording Google pubsub ID must be set")
}
}

// Create publisher sink for console lifecycle events
var publisher events.Publisher
var err error
Expand Down Expand Up @@ -71,10 +88,14 @@ func main() {

// controller
if err = (&consolecontroller.ConsoleReconciler{
Client: mgr.GetClient(),
LifecycleRecorder: lifecycleRecorder,
Log: ctrl.Log.WithName("controllers").WithName("console"),
Scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
LifecycleRecorder: lifecycleRecorder,
Log: ctrl.Log.WithName("controllers").WithName("console"),
Scheme: mgr.GetScheme(),
EnableSessionRecording: *enableSessionRecording,
SessionSidecarImage: *sessionSidecarImage,
SessionPubsubProjectId: *sessionPubsubProjectId,
SessionPubsubTopicId: *sessionPubsubTopicId,
}).SetupWithManager(ctx, mgr); err != nil {
app.Fatalf("failed to create controller: %v", err)
}
Expand Down
Loading

0 comments on commit 13e679d

Please sign in to comment.