calico change provider network IP address route via

Patch 

# https://*.com/questions/41958475/getting-the-object-array-index-in-jq
# https://www.codegrepper.com/code-examples/javascript/jq+array.length
kubectl get ds calico-node  -n kube-system -o json |jq .spec.template.spec.containers[0].env | length
kubectl get ds calico-node  -n kube-system -o json |jq .spec.template.spec.containers[0].env |map(.name == "IP_AUTODETECTION_METHOD") | index(true)
kubectl get ds calico-node  -n kube-system -o json |jq [ .spec.template.spec.containers[0].env | debug | .name == "IP_AUTODETECTION_METHOD" ] | index(true)
kubectl get ds calico-node  -n kube-system -o json |jq [ .spec.template.spec.containers[0].env | debug | map(.name == "IP_AUTODETECTION_METHOD") ] | index(true)

LEN=`kubectl get ds calico-node  -n kube-system -o json |   jq .spec.template.spec.containers[0].env | length`
IDX=$((LEN-1))
IDX=`kubectl get ds calico-node  -n kube-system -o json |jq .spec.template.spec.containers[0].env | \
  map(.name == "IP_AUTODETECTION_METHOD") | index(true)`

DS=calico-node

CMPATH=/spec/template/spec/containers/0/env/$IDX/value
VAL="cidr=192.168.10.66/24"

kubectl patch ds/$DS -n kube-system --type=json -p [
  {"op":"replace","path":""$CMPATH"","value": ""$VAL""},
]

 

Add

NM=IP_AUTODETECTION_METHOD
CMPATH=/spec/template/spec/containers/0/env/-
kubectl patch ds/$DS -n kube-system --type=json -p [
  {"op":"add","path":""$CMPATH"","value": {"name": ""$NM"", "value": ""$VAL""}},
]

 

calico change provider network IP address route via

上一篇:微信小程序


下一篇:nodejs中的几种跨域方案