-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Samuel Torres <[email protected]>
- Loading branch information
1 parent
eaaedc7
commit a8810fc
Showing
4 changed files
with
18 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,18 @@ | ||
#!/bin/bash | ||
|
||
function docker_bridge_cidr() { | ||
docker network inspect -f json kind | jq -r '.[0].IPAM.Config[] | select(.Subnet | contains(":") | not) | .Subnet' | ||
function docker_bridge_base_cidr() { | ||
local DOCKER_CIDR=$(docker network inspect -f json kind | jq -r '.[0].IPAM.Config[] | select(.Subnet | contains(":") | not) | .Subnet') | ||
echo $DOCKER_CIDR | cut -d'.' -f1-2 | ||
} | ||
|
||
function metallb_cidr() { | ||
CLUSTER_ID="${1}" | ||
NET_NUM=$((1024 - $CLUSTER_ID)) | ||
BRIDGE_CIDR=$(docker_bridge_cidr "${CLUSTER_ID}") | ||
echo "cidrsubnet(\"$BRIDGE_CIDR\", 10, $NET_NUM)" | terraform console | sed 's/"//g' | ||
function metallb_address_cidr() { | ||
local CLUSTER_ID=$1 | ||
local DOCKER_BASE_CIDR=$(docker_bridge_base_cidr) | ||
echo "$DOCKER_BASE_CIDR.$((250+$CLUSTER_ID)).250/28" | ||
} | ||
|
||
function host_min() { | ||
CIDR="${1}" | ||
echo "cidrhost(\"$CIDR\", 1)" | terraform console | sed 's/"//g' | ||
} | ||
|
||
function host_max() { | ||
CIDR="${1}" | ||
echo "cidrhost(\"$CIDR\", -2)" | terraform console | sed 's/"//g' | ||
} | ||
|
||
function metallb_host_min() { | ||
CLUSTER_ID="${1}" | ||
METALLB_CIDR=$(metallb_cidr "${CLUSTER_ID}") | ||
host_min "$METALLB_CIDR" | ||
} | ||
|
||
function metallb_host_max() { | ||
CLUSTER_ID="${1}" | ||
METALLB_CIDR=$(metallb_cidr "${CLUSTER_ID}") | ||
host_max "$METALLB_CIDR" | ||
function x_pdb_address() { | ||
local CLUSTER_ID=$1 | ||
local DOCKER_BASE_CIDR=$(docker_bridge_base_cidr) | ||
echo "$DOCKER_BASE_CIDR.$((250+$CLUSTER_ID)).251" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters