Skip to content
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

adds otel env vars #579

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion platforms/kubernetes/common/knative/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,25 @@ import {
ServiceScaling,
} from "../../loaders/siteState/get.ts";

export interface EnvVar {
export interface EnvFieldRef {
fieldPath: string;
}
export interface EnvRef {
fieldRef: EnvFieldRef;
}

export interface InlineEnvVar {
name: string;
value: string;
}

export interface ReferenceEnvVar {
name: string;
valueFrom: EnvRef;
}

export type EnvVar = InlineEnvVar | ReferenceEnvVar;

export interface KnativeSerivceOpts {
hypervisor?: boolean;
controlPlaneDomain: string;
Expand Down
48 changes: 48 additions & 0 deletions platforms/kubernetes/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,54 @@ export default function App(
...PRODUCTION_SERVICE_RESOURCES.requests,
},
},
envVars: [
...baseSiteState?.envVars ?? [],
{
name: "POD_NAME",
valueFrom: {
fieldRef: {
fieldPath: "metadata.name",
},
},
},
{
name: "POD_UID",
valueFrom: {
fieldRef: {
fieldPath: "metadata.uid",
},
},
},
{
name: "POD_NAMESPACE",
valueFrom: {
fieldRef: {
fieldPath: "metadata.namespace",
},
},
},
{
name: "NODE_NAME",
valueFrom: {
fieldRef: {
fieldPath: "spec.nodeName",
},
},
},
{
name: "DEPLOYMENT_NAME",
valueFrom: {
fieldRef: {
fieldPath: "metadata.labels['deploymentId']",
},
},
},
{
name: "OTEL_RESOURCE_ATTRIBUTES",
value:
"k8s.pod.name=$(POD_NAME),k8s.pod.uid=$(POD_UID),k8s.namespace.name=$(POD_NAMESPACE),k8s.node.name=$(NODE_NAME),k8s.deployment.name=$(DEPLOYMENT_NAME)",
},
],
};

return {
Expand Down
Loading