本机IP获取

/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"

k8s 获取容器所造node节点的ip

container_net=`ifconfig eth0 |grep "inet" |grep -v "inet6"| awk '{print $2}'|cut -d '.' -f 3`

node_ip=`etcdctl --endpoints=https://10.0.13.78:2379,https://10.0.13.80:2379,https://10.0.13.81:2379 --cert-file=/home/yanfa/cert/etcd.pem --key-file=/home/yanfa/cert/etcd-key.pem --ca-file=/home/yanfa/cert/etcd-root-ca.pem get /kube-centos/network/subnets/10.252.${container_net}.0-24 |sed 's/.*"PublicIP":"\([^"]\+\)".*/\1/' `

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐