差異處
這裏顯示兩個版本的差異處。
| 兩邊的前次修訂版 前次修改 下次修改 | 前次修改 | ||
| tech:k8s-netchk [2021/05/28 20:00] – jonathan | tech:k8s-netchk [2023/04/07 12:43] (目前版本) – [檢測跨 namespace 的 service] jonathan | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| ====== K8s 內的網路檢測 ====== | ====== K8s 內的網路檢測 ====== | ||
| + | < | ||
| + | - 在 K8s 內起一個有 curl 的 busybox POD <cli> | ||
| + | kubectl run --rm -it busybox --image yauritux/ | ||
| + | </ | ||
| + | - 直接下 ping / nslookup / curl 等等命令進行網路檢測++看結果|< | ||
| + | rkeuser@iso: | ||
| + | If you don't see a command prompt, try pressing enter. | ||
| + | /home # ping www.ichiayi.com | ||
| + | PING www.ichiayi.com (220.135.35.198): | ||
| + | 64 bytes from 220.135.35.198: | ||
| + | 64 bytes from 220.135.35.198: | ||
| + | ^C | ||
| + | --- www.ichiayi.com ping statistics --- | ||
| + | 2 packets transmitted, | ||
| + | round-trip min/avg/max = 4.992/ | ||
| + | /home # nslookup www.ichiayi.com | ||
| + | Server: | ||
| + | Address 1: 10.43.0.10 kube-dns.kube-system.svc.cluster.local | ||
| + | |||
| + | Name: www.ichiayi.com | ||
| + | Address 1: 220.135.35.198 220-135-35-198.HINET-IP.hinet.net | ||
| + | /home # curl http:// | ||
| + | < | ||
| + | /home # | ||
| + | </ | ||
| + | - 輸入 exit 離開++看結果|< | ||
| + | /home # exit | ||
| + | pod " | ||
| + | </ | ||
| + | </ | ||
| + | |||
| 因為在 Hyper-V 內建立一個 Ubuntu 20.04 VM 然後起一個 K8s Cluster 卻發現在 K8s 內的服務連不上 VM 內的服務, | 因為在 Hyper-V 內建立一個 Ubuntu 20.04 VM 然後起一個 K8s Cluster 卻發現在 K8s 內的服務連不上 VM 內的服務, | ||
| 行 52: | 行 83: | ||
| </ | </ | ||
| + | |||
| + | ===== 檢測跨 namespace 的 service ===== | ||
| + | * 預設完整服務網址是 {SERVICE_NAME}.{NAMESPACE_NAME}.svc.cluster.local | ||
| + | * Exp. 一個簡易網頁服務 | ||
| + | * SERVICE_NAME : test-20230110-37-master-serv-svc | ||
| + | * NAMESPACE_NAME : test-20230110-37 | ||
| + | * **test-20230110-37-master-serv-svc.test-20230110-37.svc.cluster.local** | ||
| + | * Exp. 在 namespace : test-20230110-37 內的 POD 內可直接使用 service name : test-20230110-37-master-serv-svc 當網址 ++看結果|< | ||
| + | / | ||
| + | |||
| + | < | ||
| + | |||
| + | <html lang=" | ||
| + | < | ||
| + | <meta charset=" | ||
| + | < | ||
| + | < | ||
| + | h3{text-align: | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | * Exp. 在 namespace : test-20230110-37 外的 POD 內需要使用完整的服務網址 : test-20230110-37-master-serv-svc.test-20230110-37.svc.cluster.local ++看結果|< | ||
| + | / | ||
| + | |||
| + | < | ||
| + | |||
| + | <html lang=" | ||
| + | < | ||
| + | <meta charset=" | ||
| + | < | ||
| + | < | ||
| + | h3{text-align: | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| ===== 參考網址 ===== | ===== 參考網址 ===== | ||
| * https:// | * https:// | ||
| {{tag> | {{tag> | ||