Friday, January 28, 2022

Dynamic Set for Helm Chart

 


cluster_chart_values_override = {
"upgradeOptions.apply" = "Disabled"
"imagePullPolicy" = "Always"
"sharding.enabled" = false
}

dynamic "set" {

for_each = var.cluster_chart_values_override
content {
name = set.key
value = set.value
}
}

Monday, January 3, 2022

Script to grep ip and port number from netstat

Below script is to parse output from netstat -tulnp or ipvsadm -Ln. 

#!/bin/bash

input=$1

vipNportRe="TCP ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:[0-9]{2,3}).*$"

ipNportRe=".*-> ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:[0-9]{2,3}).*$"

netstatIpNportRe="^tcp .* 0 ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:[0-9]{2,3}).*$"

while read line

do

  if [[ $line =~ $ipNportRe ]]; then

    echo "${BASH_REMATCH[1]}"

  elif [[ $line =~ $netstatIpNportRe ]]; then

    echo "${BASH_REMATCH[1]}"

  fi

done < $input


# Get the lines in a.txt but not in b.txt

grep -F -x -v -f b.txt a.txt