欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

關(guān)于k8s?使用?Service?控制器對(duì)外暴露服務(wù)的問題

 更新時(shí)間:2022年03月28日 09:06:41   作者:篤北天涯  
這篇文章主要介紹了k8s使用Service控制器對(duì)外暴露服務(wù),包括部署deploy,部署?service及查看?service?和?pod?的關(guān)系,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下

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

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

說明:

Service 通過標(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ò)容測試

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

Service 三種常用類型

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

到此這篇關(guān)于k8s 使用 Service 控制器對(duì)外暴露服務(wù)的文章就介紹到這了,更多相關(guān)k8s對(duì)外暴露服務(wù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • k8s?常見面試題集錦

    k8s?常見面試題集錦

    這篇文章主要為大家介紹了k8s?常見面試題集錦,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-09-09
  • 淺析kubernetes的控制器和標(biāo)簽

    淺析kubernetes的控制器和標(biāo)簽

    這篇文章主要介紹了kubernetes的控制器和標(biāo)簽的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)使用k8s,感興趣的朋友可以了解下
    2021-04-04
  • 詳解推薦使用systemd?timer替代cronjob

    詳解推薦使用systemd?timer替代cronjob

    這篇文章主要為大家介紹了推薦使用systemd?timer替代0cronjob原理分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-04-04
  • IoT?邊緣集群Kubernetes?Events告警通知進(jìn)一步配置詳解

    IoT?邊緣集群Kubernetes?Events告警通知進(jìn)一步配置詳解

    這篇文章主要為大家介紹了IoT?邊緣集群Kubernetes?Events告警通知進(jìn)一步配置詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02
  • Kubernetes組件和架構(gòu)簡介

    Kubernetes組件和架構(gòu)簡介

    Kubernetes是google開源的容器編排工具,本質(zhì)是一組服務(wù)器集群,在集群的各個(gè)節(jié)點(diǎn)上運(yùn)行程序來進(jìn)行容器進(jìn)行管理,最終實(shí)現(xiàn)資源管理智能化、自動(dòng)化,這篇文章主要介紹了Kubernetes組件和架構(gòu)簡介,需要的朋友可以參考下
    2023-09-09
  • kubernetes日志備份解決ELK中日志丟失問題

    kubernetes日志備份解決ELK中日志丟失問題

    這篇文章主要為大家介紹了kubernetes日志備份方案的細(xì)節(jié)探究分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-10-10
  • 常見Kubernetes kubectl命令使用詳解

    常見Kubernetes kubectl命令使用詳解

    這篇文章主要為大家介紹了常見Kubernetes kubectl命令使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-08-08
  • ES業(yè)務(wù)數(shù)據(jù)遷移遇到的精度問題BUG

    ES業(yè)務(wù)數(shù)據(jù)遷移遇到的精度問題BUG

    這篇文章主要為大家介紹了ES業(yè)務(wù)數(shù)據(jù)遷移遇到的BUG精度問題,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-06-06
  • Kubernetes故障排除有效維護(hù)集群的最佳實(shí)踐工具

    Kubernetes故障排除有效維護(hù)集群的最佳實(shí)踐工具

    這篇文章主要為大家介紹了Kubernetes故障排除有效維護(hù)集群的最佳實(shí)踐工具詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-10-10
  • k8s部署Pyroscope并分析golang性能瓶頸(最新推薦)

    k8s部署Pyroscope并分析golang性能瓶頸(最新推薦)

    這篇文章主要介紹了k8s部署Pyroscope并分析golang性能瓶頸,Pyroscope支持多種編程語言并提供了豐富的性能數(shù)據(jù),可以幫助我們跟蹤應(yīng)用程序的執(zhí)行情況,并根據(jù)收集到的數(shù)據(jù)來識(shí)別性能瓶頸,需要的朋友可以參考下
    2023-04-04

最新評(píng)論