🌳
pt0/deployF/ethF/claimCheckContainerF.mts
1import fs from 'fs'
4import { tsAbsPath } from '../../ptDirF.mts'
6const claimCheckEpPath = 'pt0/deployF/ethF/binF/epClaimCheck.mjs'
7export const claimCheckCmName = 'ethclaimcheck'
9export const mkClaimCheckConfigMap = async () => {
10 const {bundleAbsPath} = await genBundleTar({entrypointAbsPath: tsAbsPath(claimCheckEpPath), bundleName: claimCheckCmName})
11 return {
12 apiVersion: 'v1',
13 kind: 'ConfigMap',
14 metadata: {name: claimCheckCmName},
15 data: {'bundle.mjs': fs.readFileSync(bundleAbsPath, 'utf8')},
16 }
19export const mkClaimCheckContainer = ({ethValidatorNum, cluster_name, domainName, cfApiKeySecretName}: {
20 ethValidatorNum: number | string, cluster_name: string, domainName: string, cfApiKeySecretName: string,
21}) => ({
22 name: 'claim-check',
24 command: ['node', '/claimcheck/bundle.mjs'],
25 env: [
26 {name: 'ETH_VALIDATOR_NUM', value: String(ethValidatorNum)},
27 {name: 'CLUSTER_NAME', value: cluster_name},
28 {name: 'DOMAIN_NAME', value: domainName},
29 ],
30 envFrom: [{secretRef: {name: cfApiKeySecretName}}],
31 volumeMounts: [{name: claimCheckCmName, mountPath: '/claimcheck'}],
32})
34// injects the claim-check initContainer + ConfigMap volume into a validator Deployment; returns the ConfigMap (or undefined if disabled).
35export const withClaimCheck = async ({deployment, enabled, ethValidatorNum, cluster_name, domainName, cfApiKeySecretName}: {
36 deployment: any, enabled: boolean, ethValidatorNum?: number, cluster_name: string, domainName?: string, cfApiKeySecretName?: string,
37}) => {
38 if (!enabled || ethValidatorNum == null || !domainName || !cfApiKeySecretName) return undefined
39 const configMap = await mkClaimCheckConfigMap()
40 deployment.spec.template.spec.initContainers.push(mkClaimCheckContainer({ethValidatorNum, cluster_name, domainName, cfApiKeySecretName}))
41 deployment.spec.template.spec.volumes.push({name: claimCheckCmName, configMap: {name: claimCheckCmName}})
42 return configMap