Skip to content

Commit 5c76879

Browse files
authored
feat(agent): autoconfig passes publish context and fillStrategy (#1220)
* add /api/v4.2/discovery to agent proxy config * pass down agent publication context values
1 parent d40cdcb commit 5c76879

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

internal/controllers/configmaps.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ func (r *Reconciler) reconcileAgentProxyConfig(ctx context.Context, cr *model.Cr
301301
CryostatPort: constants.CryostatHTTPContainerPort,
302302
AllowedPathPrefixes: []string{
303303
"/api/v4/discovery",
304+
"/api/v4.2/discovery",
304305
"/api/v4/credentials",
305306
"/api/beta/recordings",
306307
"/api/beta/diagnostics/heapdump/upload",

internal/test/resources.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5224,6 +5224,14 @@ http {
52245224
proxy_pass http://127.0.0.1:8181$request_uri;
52255225
}
52265226
5227+
location /api/v4.2/discovery/ {
5228+
proxy_pass http://127.0.0.1:8181$request_uri;
5229+
}
5230+
5231+
location = /api/v4.2/discovery {
5232+
proxy_pass http://127.0.0.1:8181$request_uri;
5233+
}
5234+
52275235
location /api/v4/credentials/ {
52285236
proxy_pass http://127.0.0.1:8181$request_uri;
52295237
}
@@ -5317,6 +5325,14 @@ http {
53175325
proxy_pass http://127.0.0.1:8181$request_uri;
53185326
}
53195327
5328+
location /api/v4.2/discovery/ {
5329+
proxy_pass http://127.0.0.1:8181$request_uri;
5330+
}
5331+
5332+
location = /api/v4.2/discovery {
5333+
proxy_pass http://127.0.0.1:8181$request_uri;
5334+
}
5335+
53205336
location /api/v4/credentials/ {
53215337
proxy_pass http://127.0.0.1:8181$request_uri;
53225338
}

internal/webhooks/agent/pod_defaulter.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,22 @@ func (r *podMutator) Default(ctx context.Context, obj runtime.Object) error {
239239
Name: "CRYOSTAT_AGENT_WEBSERVER_PORT",
240240
Value: strconv.Itoa(int(*port)),
241241
},
242+
corev1.EnvVar{
243+
Name: "CRYOSTAT_AGENT_PUBLISH_FILL_STRATEGY",
244+
Value: "KUBERNETES",
245+
},
246+
corev1.EnvVar{
247+
Name: "CRYOSTAT_AGENT_PUBLISH_CONTEXT_NAMESPACE",
248+
Value: pod.Namespace,
249+
},
250+
corev1.EnvVar{
251+
Name: "CRYOSTAT_AGENT_PUBLISH_CONTEXT_NODETYPE",
252+
Value: "Pod",
253+
},
254+
corev1.EnvVar{
255+
Name: "CRYOSTAT_AGENT_PUBLISH_CONTEXT_NAME",
256+
Value: fmt.Sprintf("$(%s)", podNameEnvVar),
257+
},
242258
)
243259

244260
if len(harvesterTemplate) > 0 {

internal/webhooks/agent/test/resources.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,22 @@ func (r *AgentWebhookTestResources) newMutatedContainer(original *corev1.Contain
578578
Name: "CRYOSTAT_AGENT_WEBSERVER_PORT",
579579
Value: strconv.Itoa(int(options.callbackPort)),
580580
},
581+
{
582+
Name: "CRYOSTAT_AGENT_PUBLISH_FILL_STRATEGY",
583+
Value: "KUBERNETES",
584+
},
585+
{
586+
Name: "CRYOSTAT_AGENT_PUBLISH_CONTEXT_NAMESPACE",
587+
Value: options.namespace,
588+
},
589+
{
590+
Name: "CRYOSTAT_AGENT_PUBLISH_CONTEXT_NODETYPE",
591+
Value: "Pod",
592+
},
593+
{
594+
Name: "CRYOSTAT_AGENT_PUBLISH_CONTEXT_NAME",
595+
Value: "$(CRYOSTAT_AGENT_POD_NAME)",
596+
},
581597
{
582598
Name: options.javaOptionsName,
583599
Value: options.javaOptionsValue + fmt.Sprintf("-javaagent:"+constants.AgentJarPath+"=io.cryostat.agent.shaded.org.slf4j.simpleLogger.defaultLogLevel=%s", options.logLevel),

0 commit comments

Comments
 (0)