|NO.Z.00064|——————————|^^ 部署 ^^|——|KuberNetes&二進位制部署.V17|3臺Server|---------------------------------------|kubernetes驗證|busybox部署|Pod解析service|
阿新 • • 發佈:2022-03-29
[CloudNative:KuberNetes&二進位制部署.V17] [Applications.KuberNetes] [|DevOps|k8s|**3節點**|二進位制1.20|kubernetes叢集驗證|] [|部署busybox|pod同namespace下通訊|pod跨namespace通訊|]
一、叢集驗證資源準備
### --- 叢集驗證說明
~~~ 叢集驗證(叢集之前,先部署dashboard)
### --- pod驗證流程 ~~~ # Pod必須能解析Service ~~~ # Pod必須能解析跨namespace的Service ~~~ # 每個節點都必須要能訪問Kubernetes的kubernetes svc 443和kube-dns的service 53 ~~~ # Pod和Pod之間可以正常通訊 ~~~ a)同namespace能通訊 ~~~ b)跨namespace能通訊 ~~~ c)跨機器能通訊
二、安裝busybox
### --- 安裝busybox ~~~ # 建立一個busybox的pod [root@k8s-master01 ~]# cat<<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: busybox namespace: default spec: containers: - name: busybox image: busybox:1.28 command: - sleep - "3600" imagePullPolicy: IfNotPresent restartPolicy: Always EOF
### --- 檢視Pod執行狀態:若是沒有指定namespace,預設部署在default名稱空間下
[root@k8s-master01 ~]# kubectl get po
NAME READY STATUS RESTARTS AGE
busybox 1/1 Running 0 112s
三、叢集驗證### --- 每個Pod執行之後都會有一個kubernetes service [root@k8s-master01 ~]# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 159m
### --- Pod必須能解析Service
~~~ 注:解析這個Service在同一個namespaces是否可以解析成功
[root@k8s-master01 ~]# kubectl exec busybox -n default -- nslookup kubernetes
Server: 10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local
Name: kubernetes
Address 1: 10.96.0.1 kubernetes.default.svc.cluster.local
### --- Pod必須能解析跨namespace的Service
~~~ 注:跨namespaces是否可以解析成功
[root@k8s-master01 ~]# kubectl exec busybox -n default -- nslookup kube-dns.kube-system
Server: 10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local
Name: kube-dns.kube-system
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local
### --- 每個節點都必須要能訪問Kubernetes的kubernetes svc 443和kube-dns的service 53
~~~ 檢視kubernetes-service的IP地址
[root@k8s-master01 ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 167m
[root@k8s-master01 ~]# yum install -y telnet
[root@k8s-master01 ~]# telnet 10.96.0.1 443
Trying 10.96.0.1...
Connected to 10.96.0.1.
Escape character is '^]'. // 輸出該內容說明埠是通的;若是沒有自動關閉的情況下,是沒有問題的,若是自動關閉狀態,可能是故障狀態。
### --- 檢視kube-dns的埠是否是通的
[root@k8s-master01 ~]# kubectl get svc -n kube-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 43m
metrics-server ClusterIP 10.97.177.184 <none> 443/TCP
[root@k8s-master01 ~]# telnet 10.96.0.10 53
Trying 10.96.0.10...
Connected to 10.96.0.10.
Escape character is '^]'. // 正常狀態
### --- 也可以使用curl命令檢視
~~~ 注:所有節點安裝telnet
~~~ 注:每個節點都必須要能訪問Kubernetes的kubernetes svc 443和kube-dns的service 53
[root@k8s-master01 ~]# curl 10.96.0.10:53
curl: (52) Empty reply from server // 正常狀態
===============================END===============================
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart ——W.S.Landor
來自為知筆記(Wiz)