Skip to content

Commit

Permalink
Create external IP only when flag is set (#4749)
Browse files Browse the repository at this point in the history
  • Loading branch information
Prince Rachit Sinha authored Jul 9, 2021
1 parent 14c36e6 commit 193a825
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions .werft/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,21 +276,23 @@ export async function deployToDev(deploymentConfig: DeploymentConfig, workspaceF
});

var k3sWsProxyIP = "";
try {
// The output of gcloud compute addresses describe contains a list of values in <key>:__<value> form. We get rid of the `address: ` to find the ip
const existingIP = exec(`gcloud compute addresses describe ${namespace} --region europe-west1 | grep 'address:' | cut -c 10-`, { silent: true }).trim();
werft.log('certificate', `The gcloud compute address describe returned: ${existingIP}`)
if (existingIP.indexOf("ERROR:") == -1 && existingIP != "") {
k3sWsProxyIP = existingIP;
werft.log('certificate', `found existing ip named ${namespace} and value: ${k3sWsProxyIP}`)
} else {
exec(`gcloud compute addresses create ${namespace} --region europe-west1`)
const newIP = exec(`gcloud compute addresses describe ${namespace} --region europe-west1 | grep 'address:' | cut -c 10-`).trim();
k3sWsProxyIP = newIP
werft.log('certificate', `created new ip named ${namespace} and value: ${k3sWsProxyIP}`)
if (k3sWsCluster) {
try {
// The output of gcloud compute addresses describe contains a list of values in <key>:__<value> form. We get rid of the `address: ` to find the ip
const existingIP = exec(`gcloud compute addresses describe ${namespace} --region europe-west1 | grep 'address:' | cut -c 10-`, { silent: true }).trim();
werft.log('certificate', `The gcloud compute address describe returned: ${existingIP}`)
if (existingIP.indexOf("ERROR:") == -1 && existingIP != "") {
k3sWsProxyIP = existingIP;
werft.log('certificate', `found existing ip named ${namespace} and value: ${k3sWsProxyIP}`)
} else {
exec(`gcloud compute addresses create ${namespace} --region europe-west1`)
const newIP = exec(`gcloud compute addresses describe ${namespace} --region europe-west1 | grep 'address:' | cut -c 10-`).trim();
k3sWsProxyIP = newIP
werft.log('certificate', `created new ip named ${namespace} and value: ${k3sWsProxyIP}`)
}
} catch (err) {
werft.fail('certificate', err.toString())
}
} catch (err) {
werft.fail('certificate', err.toString())
}

try {
Expand Down

0 comments on commit 193a825

Please sign in to comment.