基于 kubeadm 搭建高可用的kubernetes 1.18.2 (k8s)集群 三 集群可用性测试
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: apps/v1
kind: DaemonSet
metadata:
name: nginx-ds
labels:
addonmanager.kubernetes.io/mode: Reconcile
spec:
selector:
matchLabels:
app: nginx-ds
template:
metadata:
labels:
app: nginx-ds
spec:
containers:
- name: my-nginx
image: nginx:1.17
ports:
- containerPort: 80
EOF
# 创建ds
$ kubectl create -f nginx-ds.yml2. 检查各种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.17
ports:
- containerPort: 80
EOF
# 创建pod
$ kubectl create -f pod-nginx.yaml
# 进入pod,查看dns
$ kubectl exec nginx -i -t -- /bin/bash
# 查看dns配置
:/# cat /etc/resolv.conf
# 查看名字是否可以正确解析
:/# ping nginx-ds 相关推荐
lucialee 2020-03-03
80443361 2020-02-28
jszy 2020-02-24
mohanzb 2019-12-05
趣IT 2020-07-29
cyworz 2020-06-14
辛佳雨 2020-06-12
木子叶家园 2020-06-12
天空一样的蔚蓝 2020-06-04
middleware0 2020-05-17
憧憬 2020-05-16
憧憬 2020-05-10
loviezhang 2020-05-10
zyjj 2020-05-07
xiaoxiangyu 2020-04-30
loviezhang 2020-04-26
枫叶上的雨露 2020-04-25