@starship-ci/generator
Version:
Kubernetes manifest generator for Starship deployments
53 lines (52 loc) • 1.73 kB
JavaScript
import * as helpers from '../../../helpers';
/**
* Generates the Service for Ethereum chain
* Based on the Helm template: chains/eth/service.yaml
*/
export class EthereumServiceGenerator {
config;
chain;
constructor(chain, config) {
this.config = config;
this.chain = chain;
}
generate() {
const name = `${this.chain.name}-${this.chain.id}`;
// Port mappings from Helm template
const portMap = {
http: 8545,
ws: 8546,
rpc: 8551
};
return [
{
apiVersion: 'v1',
kind: 'Service',
metadata: {
name: name,
labels: {
...helpers.getCommonLabels(this.config),
'app.kubernetes.io/component': 'chain',
'app.kubernetes.io/name': name,
'app.kubernetes.io/part-of': helpers.getChainId(this.chain),
'app.kubernetes.io/role': 'service',
'starship.io/chain-name': this.chain.name,
'starship.io/chain-id': helpers.getChainId(this.chain)
}
},
spec: {
clusterIP: 'None',
ports: Object.entries(portMap).map(([portName, port]) => ({
name: portName,
port,
protocol: 'TCP',
targetPort: String(port)
})),
selector: {
'app.kubernetes.io/name': name
}
}
}
];
}
}