k8s-集群状态及部署一个实例

[root@k8s-master ~]# kubectl get cs
NAME STATUS MESSAGE ERROR
controller-manager Healthy ok
scheduler Healthy ok
etcd-0 Healthy {"health": "true"}
etcd-2 Healthy {"health": "true"}
etcd-1 Healthy {"health": "true"}
[root@k8s-master ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
192.168.56.244 Ready <none> 27m v1.11.10
192.168.56.245 Ready <none> 20m v1.11.10

[root@k8s-master ~]# kubectl run nginx --image=nginx --replicas=3
deployment "nginx" created

[root@k8s-master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-64f497f8fd-jnhgm 1/1 Running 0 1m
nginx-64f497f8fd-n5pst 1/1 Running 0 1m
nginx-64f497f8fd-rzldm 1/1 Running 0 1m
[root@k8s-master ~]# kubectl get all
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deploy/nginx 3 3 3 3 2m

NAME DESIRED CURRENT READY AGE
rs/nginx-64f497f8fd 3 3 3 2m

NAME READY STATUS RESTARTS AGE
po/nginx-64f497f8fd-jnhgm 1/1 Running 0 2m
po/nginx-64f497f8fd-n5pst 1/1 Running 0 2m
po/nginx-64f497f8fd-rzldm 1/1 Running 0 2m

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/kubernetes ClusterIP 10.10.10.1 <none> 443/TCP 2h

[root@k8s-master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-64f497f8fd-jnhgm 1/1 Running 0 1m
nginx-64f497f8fd-n5pst 1/1 Running 0 1m
nginx-64f497f8fd-rzldm 1/1 Running 0 1m
[root@k8s-master ~]# kubectl get all
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deploy/nginx 3 3 3 3 2m

NAME DESIRED CURRENT READY AGE
rs/nginx-64f497f8fd 3 3 3 2m

NAME READY STATUS RESTARTS AGE
po/nginx-64f497f8fd-jnhgm 1/1 Running 0 2m
po/nginx-64f497f8fd-n5pst 1/1 Running 0 2m
po/nginx-64f497f8fd-rzldm 1/1 Running 0 2m

[root@k8s-master ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE
nginx-64f497f8fd-jnhgm 1/1 Running 0 3m 172.17.9.2 192.168.56.244
nginx-64f497f8fd-n5pst 1/1 Running 0 3m 172.17.7.2 192.168.56.245
nginx-64f497f8fd-rzldm 1/1 Running 0 3m 172.17.7.3 192.168.56.245

#####暴露端口

[root@k8s-master ~]# kubectl expose deployment nginx --port=88 --target-port=80 --type=NodePort
service "nginx" exposed

[root@k8s-master ~]# kubectl get svc   ####生成了一个nginx 集群ip:10.10.10.144

这个IP的范围在哪定义的呢?

[root@k8s-master ~]# cat /opt/kubernetes/cfg/kube-apiserver

--service-cluster-ip-range=10.10.10.0/24 \           #####就是这一句

 

###我们可以在node上访问集群ip,master 无法访问!!!!(因为master没有部署flannel)

[root@k8s-node01 src]# curl 10.10.10.144:88
<!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>

#####也可以访问外网的端口,那个端口是随机生成的

####查看日志

[root@k8s-master ~]# kubectl get pod -o wide
NAME                     READY     STATUS    RESTARTS   AGE       IP           NODE
nginx-64f497f8fd-jnhgm   1/1       Running   0          29m       172.17.9.2   192.168.56.244
nginx-64f497f8fd-n5pst   1/1       Running   0          29m       172.17.7.2   192.168.56.245
nginx-64f497f8fd-rzldm   1/1       Running   0          29m       172.17.7.3   192.168.56.245
[root@k8s-master ~]# kubectl logs nginx-64f497f8fd-jnhgm
192.168.56.244 - - [29/May/2019:10:33:45 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.29.0" "-"
172.17.9.1 - - [29/May/2019:10:38:09 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36" "-"
2019/05/29 10:38:09 [error] 5#5: *3 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.9.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.56.244:35824", referrer: "http://192.168.56.244:35824/"
172.17.9.1 - - [29/May/2019:10:38:09 +0000] "GET /favicon.ico HTTP/1.1" 404 556 "http://192.168.56.244:35824/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36" "-"

 

转载于:https://www.cnblogs.com/shanhua-fu/p/10945569.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值