Issue
How can I grep the nodeport which is the "31000" under the PORT(S) , it can and will change, from the following kubernetes command output:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
vault-ui NodePort 10.96.62.155 <none> 8200:31000/TCP 23m
and how can I grep the ip address(in this case 192.168.99.213) but not the port(8443) or the https:// in following output, this output also changes depending on the ip:
Kubernetes master is running at https://192.168.99.213:8443
KubeDNS is running at https://192.168.99.213:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Solution
kubecmd | awk -F[:] 'NR>1 { split($2,arr,"/");print arr[1]}'
For the first scenario, you can use awk as above. Use : as a field separator and then further split the second delimited piece on / into array arr printing the first element this array the
kubecmd | sed -En 's/(^.*Kubernetes master.*https:\/\/)(.*)(:.*$)/\2/p'
For the second scenario, use sed as above. Split the text into three sections and print the second section
Answered By - Raman Sailopal Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.