Kubernetes v1.9.7安装部署-Node集群验证

1、验证集群功能(Create之前先提前在所有节点pull一下image)

定义yaml 文件:(将下面内容保存为:nginx-ds.yaml)

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

创建 Pod 和服务:

$ kubectl create -f nginx-ds.yml
service "nginx-ds" created
daemonset "nginx-ds" created

执行下面的命令查看Pod 和SVC:

$ kubectl get pods -o wide
NAME       READY   STATUS  RESTARTS  AGE    IP      NODE
nginx-ds-f29zt  1/1    Running  0     23m    172.17.0.2  192.168.1.170

img

$ kubectl get svc
NAME     TYPE    CLUSTER-IP    EXTERNAL-IP   PORT(S)       AGE
nginx-ds   NodePort  10.254.112.137  <none>    80:30216/TCP  5d

可以看到:

  • 服务IP:10.254.112.137
  • 服务端口:80
  • NodePort端口:30216

在所有 Node 上执行:

curl 10.254.112.137curl10.254.112.137 curl 172.16.200.15:30216

执行上面的命令预期都会输出nginx 欢迎页面内容,表示我们的Node 节点正常运行了。

img

img

推荐文章

发表评论

邮箱地址不会被公开。 必填项已用*标注