如何使用kubeadm安裝kubernetes(K8S)——3.集羣可用性測試

=>返回首頁<=

三、集羣可用性測試

1. 創建nginx ds

 # 寫入配置
$ cat > nginx-ds.yml <<EOF
apiVersion: v1
kind: Service
metadata:
  name: nginx-ds
  labels:
    app: nginx-ds
spec:
  type: NodePort
  selector:
    app: nginx-ds
  ports:
  - name: http
    port: 80
    targetPort: 80
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: nginx-ds
  labels:
    addonmanager.kubernetes.io/mode: Reconcile
spec:
  template:
    metadata:
      labels:
        app: nginx-ds
    spec:
      containers:
      - name: my-nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
EOF

# 創建ds
$ kubectl create -f nginx-ds.yml


2. 檢查各種ip連通性

# 檢查各 Node 上的 Pod IP 連通性
$ kubectl get pods  -o wide

# 在每個節點上ping pod ip
$ ping <pod-ip>

# 檢查service可達性
$ kubectl get svc

# 在每個節點上訪問服務
$ curl <service-ip>:<port>

# 在每個節點檢查node-port可用性
$ curl <node-ip>:<port>

3. 檢查dns可用性

# 創建一個nginx pod
$ cat > pod-nginx.yaml <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.7.9
    ports:
    - containerPort: 80
EOF

# 創建pod
$ kubectl create -f pod-nginx.yaml

# 進入pod,查看dns
$ kubectl exec  nginx -i -t -- /bin/bash

# 查看dns配置
root@nginx:/# cat /etc/resolv.conf

# 查看名字是否可以正確解析
root@nginx:/# ping nginx-ds
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章