Aut*_*ner 2 kubernetes kubectl
我正在尝试使用kubectl describe命令从特定的Pod中获取Nodeport。从这个问题中我知道-o选项不适用于描述,因此我正在尝试以下方式,但是我没有得到所需的值,有人可以纠正我。
kubectl -n core describe svc/pg-debug
Name: pg-debug
Namespace: core
Labels: <none>
Annotations: <none>
Selector: app=postgresql-default
Type: NodePort
IP: 172.17.17.19
Port: <unset> 5432/TCP
TargetPort: 5432/TCP
NodePort: <unset> 24918/TCP
Endpoints: 172.16.90.10:5432
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
Run Code Online (Sandbox Code Playgroud)
以下是我试图获得价值的命令 "24918"
kubectl -n core describe svc/pg-debug | grep NodePort |awk -F: '/nodePort/{gsub(/ /,"",$2)}'
Run Code Online (Sandbox Code Playgroud)
您可以使用以下命令从服务获取nodePort
kubectl get svc pg-debug -n core -o jsonpath='{.spec.ports[].nodePort}'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
538 次 |
| 最近记录: |