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.10html

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

[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 2mnginx

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

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 2mapi

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

[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 2mide

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

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 2mthis

[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.245url

#####暴露端口

[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" "-"
相關文章
相關標籤/搜索