4import * as _ from 'lodash-es' 6export const fix1IngressPublishAddr = async ({ip}: {ip: string}) => { 8 const kinds = ['Deployment', 'DaemonSet'] as const 10 {name: 'ingress-nginx-controller', namespace: 'ingress-nginx'}, 11 {name: 'rke2-ingress-nginx-controller', namespace: 'kube-system'}, 14 for (const {name, namespace} of candidates) { 15 for (const kind of kinds) { 19 apiVersion: 'apps/v1', 21 metadata: {name, namespace}, 24 if (!resource) continue 26 const container = resource.spec.template.spec.containers[0] 27 const newArg = `--publish-status-address=${ip}` 28 const argI = _.findIndex(container.args, (argS: string) => _.startsWith(argS, '--publish-status-address')) 30 if (argI !== -1 && container.args[argI] === newArg) { 31 console.log(`fix1IngressPublishAddr: ${name} already set to ${ip}`) 36 container.args.push(newArg) 37 console.log(`fix1IngressPublishAddr: adding ${newArg} to ${name}`) 39 const oldArg = container.args[argI] 40 container.args[argI] = newArg 41 console.log(`fix1IngressPublishAddr: ${name} ${oldArg} -> ${newArg}`) 44 await res1Action({action: 'apply', resource: resource as KubeResource, cluster_name}) 49 console.log('fix1IngressPublishAddr: ingress controller not found')