日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長(zhǎng)提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢(xún)客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

目錄
  • 部署 deploy
  • 部署 service
  • 查看 service 和 pod 的關(guān)系
  • 查看 service
  • 查看端口
  • 導(dǎo)出 yaml
  • 篩選 service 關(guān)聯(lián) pod
  • 擴(kuò)容測(cè)試
  • Service 三種常用類(lèi)型

Service 引入主要是解決 Pod 的動(dòng)態(tài)變化,提供統(tǒng)一訪問(wèn)入口:

  1. 防止 Pod 失聯(lián),準(zhǔn)備找到提供同一個(gè)服務(wù)的 Pod (服務(wù)發(fā)現(xiàn)) 
  2. 定義一組 Pod 的訪問(wèn)策略 (負(fù)載均衡)

部署 deploy

kubectl apply -f deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: chiyi-nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: chiyi-nginx
  template:
    metadata:
      labels:
        app: chiyi-nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

部署 service

kubectl apply -f service.yaml
apiVersion: v1
kind: Service
metadata:
  name: chiyi-nginx
spec:
  selector:
    app: chiyi-nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30002
  type: NodePort

查看 service 和 pod 的關(guān)系

kubectl  get ep
curl 10.244.1.58:80

說(shuō)明:

Service 通過(guò)標(biāo)簽關(guān)聯(lián)一組 Pod

Service 為一組 Pod 提供負(fù)載均衡能力

[root@k8s-master service]# kubectl get ep
NAME          ENDPOINTS                                      AGE
chiyi-nginx   10.244.1.58:80,10.244.1.59:80,10.244.2.46:80   5m19s
kubernetes    172.17.28.225:6443                             23h
[root@k8s-master service]# curl 10.244.1.58:80
<!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 >nginx.org</a>.<br/>
Commercial support is available at
<a >nginx.com</a>.</p>
 
<p><em>Thank you for using nginx.</em></p>
</body>
</html>

查看 service

kubectl  get service
curl 10.101.104.218
[root@k8s-master service]# kubectl get service
NAME          TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
chiyi-nginx   NodePort    10.101.104.218   <none>        80:30002/TCP   6m3s
kubernetes    ClusterIP   10.96.0.1        <none>        443/TCP        23h
[root@k8s-master service]# curl 10.101.104.218
<!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 >nginx.org</a>.<br/>
Commercial support is available at
<a >nginx.com</a>.</p>
 
<p><em>Thank you for using nginx.</em></p>
</body>
</html>

查看端口

ss -antp |grep 30002
[root@k8s-master service]# ss -antp |grep 30002
LISTEN     0      128          *:30002                    *:*                   users:(("kube-proxy",pid=3544,fd=13))

導(dǎo)出 yaml

kubectl  get service chiyi-nginx -o yaml

篩選 service 關(guān)聯(lián) pod

kubectl get pods -l app=chiyi-nginx
[root@k8s-master service]# kubectl get pods -l app=chiyi-nginx
NAME                           READY   STATUS    RESTARTS   AGE
chiyi-nginx-5bbf8bff4b-6bwfz   1/1     Running   0          3m58s
chiyi-nginx-5bbf8bff4b-bpvvc   1/1     Running   0          3m58s
chiyi-nginx-5bbf8bff4b-pwwt4   1/1     Running   0          3m58s

擴(kuò)容測(cè)試

kubectl scale deployment chiyi-nginx --replicas=1
kubectl  get service,pods,ep

Service 三種常用類(lèi)型

  • ClusterIP 集群內(nèi)部使用,任一節(jié)點(diǎn)服務(wù)器和 pod 內(nèi)部都可以訪問(wèn)
  • NodePort 對(duì)外暴露應(yīng)用(端口默認(rèn)范圍:30000-32767),任一節(jié)點(diǎn)服務(wù)器公網(wǎng)IP+端口號(hào),可在瀏覽器訪問(wèn)。
  • LoadBalancer 對(duì)外暴露應(yīng)用,適合公有云

分享到:
標(biāo)簽:對(duì)外 控制器 暴露 服務(wù) 服務(wù)器
用戶(hù)無(wú)頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過(guò)答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫(kù),初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績(jī)?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績(jī)?cè)u(píng)定