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

chore: Inject k8s pod name and uid #10633

Merged
merged 1 commit into from
Dec 11, 2024
Merged
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: 16 additions & 0 deletions spartan/aztec-network/templates/boot-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ spec:
value: "{{ .Values.aztec.epochDuration }}"
- name: AZTEC_EPOCH_PROOF_CLAIM_WINDOW_IN_L2_SLOTS
value: "{{ .Values.aztec.epochProofClaimWindow }}"
- name: K8S_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- end }}
containers:
- name: boot-node
Expand Down Expand Up @@ -142,6 +150,14 @@ spec:
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: K8S_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: AZTEC_PORT
value: "{{ .Values.bootNode.service.nodePort }}"
- name: LOG_LEVEL
Expand Down
8 changes: 8 additions & 0 deletions spartan/aztec-network/templates/deploy-l1-verifier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ spec:
done || { echo "All L1 verifier deploy attempts failed." >&2; exit 1; }
echo "L1 verifier deployed"
env:
- name: K8S_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: NODE_NO_WARNINGS
value: "1"
- name: LOG_LEVEL
Expand Down
8 changes: 8 additions & 0 deletions spartan/aztec-network/templates/prover-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ spec:
source /shared/config/service-addresses && \
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --prover-agent
env:
- name: K8S_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: AZTEC_PORT
value: "{{ .Values.proverAgent.service.nodePort }}"
- name: LOG_LEVEL
Expand Down
8 changes: 8 additions & 0 deletions spartan/aztec-network/templates/prover-broker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ spec:
source /shared/config/service-addresses && \
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --prover-broker
env:
- name: K8S_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: AZTEC_PORT
value: "{{ .Values.proverBroker.service.nodePort }}"
- name: LOG_LEVEL
Expand Down
8 changes: 8 additions & 0 deletions spartan/aztec-network/templates/prover-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ spec:
- name: config
mountPath: /shared/config
env:
- name: K8S_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
Expand Down
8 changes: 8 additions & 0 deletions spartan/aztec-network/templates/pxe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ spec:
echo "AZTEC_NODE_URL=${AZTEC_NODE_URL}"
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --pxe
env:
- name: K8S_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: AZTEC_PORT
value: "{{ .Values.pxe.service.nodePort }}"
- name: LOG_JSON
Expand Down
8 changes: 8 additions & 0 deletions spartan/aztec-network/templates/setup-l2-contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ spec:
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js setup-protocol-contracts --skipProofWait --l1-chain-id {{ .Values.ethereum.chainId }}
echo "L2 contracts initialized"
env:
- name: K8S_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: TELEMETRY
value: "{{ .Values.telemetry.enabled }}"
- name: LOG_LEVEL
Expand Down
8 changes: 8 additions & 0 deletions spartan/aztec-network/templates/transaction-bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ spec:
echo "AZTEC_NODE_URL=${AZTEC_NODE_URL}"
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --pxe --bot
env:
- name: K8S_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: AZTEC_PORT
value: "{{ .Values.bot.service.nodePort }}"
- name: LOG_JSON
Expand Down
8 changes: 8 additions & 0 deletions spartan/aztec-network/templates/validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ spec:
- name: validator-data
mountPath: {{ .Values.validator.dataDir }}
env:
- name: K8S_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
Expand Down
4 changes: 3 additions & 1 deletion yarn-project/foundation/src/config/env_var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,6 @@ export type EnvVar =
| 'FAUCET_MNEMONIC_ACCOUNT_INDEX'
| 'FAUCET_ETH_AMOUNT'
| 'FAUCET_INTERVAL_MS'
| 'FAUCET_L1_ASSETS';
| 'FAUCET_L1_ASSETS'
| 'K8S_POD_NAME'
| 'K8S_POD_UID';
3 changes: 3 additions & 0 deletions yarn-project/telemetry-client/src/aztec_resource_detector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type DetectorSync, type IResource, Resource } from '@opentelemetry/resources';
import { ATTR_K8S_POD_NAME, ATTR_K8S_POD_UID } from '@opentelemetry/semantic-conventions/incubating';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice.


import { NETWORK_NAME } from './attributes.js';
import { getConfigEnvVars } from './config.js';
Expand All @@ -12,6 +13,8 @@ class AztecDetector implements DetectorSync {

return new Resource({
[NETWORK_NAME]: config.networkName,
[ATTR_K8S_POD_UID]: config.k8sPodUid,
[ATTR_K8S_POD_NAME]: config.k8sPodName,
});
}
}
Expand Down
10 changes: 10 additions & 0 deletions yarn-project/telemetry-client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface TelemetryClientConfig {
networkName: string;
otelCollectIntervalMs: number;
otelExportTimeoutMs: number;
k8sPodUid?: string;
k8sPodName?: string;
}

export const telemetryClientConfigMappings: ConfigMappingsType<TelemetryClientConfig> = {
Expand Down Expand Up @@ -48,6 +50,14 @@ export const telemetryClientConfigMappings: ConfigMappingsType<TelemetryClientCo
defaultValue: 30000, // Default extracted from otel client
parseEnv: (val: string) => parseInt(val),
},
k8sPodUid: {
env: 'K8S_POD_UID',
description: 'The UID of the Kubernetes pod (injected automatically by k8s)',
},
k8sPodName: {
env: 'K8S_POD_NAME',
description: 'The name of the Kubernetes pod (injected automatically by k8s)',
},
};

export function getConfigEnvVars(): TelemetryClientConfig {
Expand Down
1 change: 1 addition & 0 deletions yarn-project/telemetry-client/src/otel_logger_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ export async function registerOtelLoggerProvider(resource?: IResource, otelLogsU
);

otelLogs.setGlobalLoggerProvider(loggerProvider);

return loggerProvider;
}
12 changes: 1 addition & 11 deletions yarn-project/telemetry-client/src/otel_resource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { awsEc2Detector, awsEcsDetector } from '@opentelemetry/resource-detector-aws';
import {
type IResource,
detectResourcesSync,
Expand All @@ -11,17 +10,8 @@ import {
import { aztecDetector } from './aztec_resource_detector.js';

export async function getOtelResource(): Promise<IResource> {
// TODO(palla/log): Do we really need *all* this info?
const resource = detectResourcesSync({
detectors: [
osDetectorSync,
envDetectorSync,
processDetectorSync,
serviceInstanceIdDetectorSync,
awsEc2Detector,
awsEcsDetector,
aztecDetector,
],
detectors: [osDetectorSync, envDetectorSync, processDetectorSync, serviceInstanceIdDetectorSync, aztecDetector],
});

if (resource.asyncAttributesPending) {
Expand Down
Loading