养浩然之气,做博学之人
kubectl get nodes #NAME STATUS ROLES AGE VERSION #kube-node1 Ready <none> 3h v1.10.4 #kube-node2 Ready <none> 3h v1.10.4 #kube-node3 Ready <none> 3h v1.10.4
##都为 Ready 时正常。
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
kubectl create -f nginx-ds.yml #service "nginx-ds" created #daemonset.extensions "nginx-ds" created
kubectl get pods -o wide|grep nginx-ds #nginx-ds-p9p5x 1/1 Running 6 15h 192.30.32.2 docker110 #nginx-ds-rsrvl 1/1 Running 5 15h 192.30.97.2 docker112 #nginx-ds-rvbdl 1/1 Running 12 15h 192.30.18.2 docker111
若有没有起来的可执行:
#kubectl describe pods nginx-ds-rsrvl #kubectl describe pods nginx-ds-rvbdl
可见,nginx-ds 的 Pod IP 分别是192.30.32.2、192.30.97.2、192.30.18.2,在所有 Node 上分别 ping 这三个 IP,看是否连通:
source /opt/k8s/bin/environment.sh for node_ip in ${NODE_IPS[@]} do echo ">>> ${node_ip}" ssh ${node_ip} "ping -c 1 192.30.18.2" ssh ${node_ip} "ping -c 1 192.30.97.2" ssh ${node_ip} "ping -c 1 192.30.32.2" done
kubectl get svc |grep nginx-ds #nginx-ds NodePort 10.0.178.178 <none> 80:8536/TCP 9h
#可见:
#Service Cluster IP: 10.0.178.178
#服务端口:80
#NodePort 端口:8536
source /opt/k8s/bin/environment.shfor node_ip in ${NODE_IPS[@]} do echo ">>> ${node_ip}" ssh ${node_ip} "curl ${node_ip}:8900" done
#预期输出 nginx 欢迎页面内容。
#% Total % Received % Xferd Average Speed Time Time Time Current
# Dload Upload Total Spent Left Speed
# 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0<!DOCTYPE html>
#<html>
#<head>
#<title>Welcome to nginx!</title>
#<style>
# body {
# width: 35em;
# margin: 0 auto;
# font-family: Tahoma, Verdana, Arial, sans-serif;
# }
#</style>
#</head>
#<body>
#<h1>Welcome to nginx!</h1>
#<p>If you see this page, the nginx web server is successfully installed and
#working. Further configuration is required.</p>
#
#<p>For online documentation and support please refer to
#<a href="http://nginx.org/">nginx.org</a>.<br/>
#Commercial support is available at
#<a href="http://nginx.com/">nginx.com</a>.</p>
#
#<p><em>Thank you for using nginx.</em></p>
#</body>
#</html>
参考:
https://www.kubernetes.org.cn/3063.html
https://www.kubernetes.org.cn/3096.html
https://github.com/opsnull/follow-me-install-kubernetes-cluster
http://www.imooc.com/article/23355
https://www.docker.com/
编辑:孙小北
本文地址: https://www.xiaowangyun.com/wyblog/detail/?id=238
版权归属: www.xiaowangyun.com 转载时请以链接形式注明出处
0 条评论