当前位置: 首页 > news >正文

大网站如何优化株洲seo优化报价

大网站如何优化,株洲seo优化报价,广东微信网站制作公司,专门做图片是网站使用 Service 把前端连接到后端 如何创建前端(Frontend)微服务和后端(Backend)微服务。后端微服务是一个 hello 欢迎程序。 前端通过 nginx 和一个 Kubernetes 服务暴露后端所提供的服务。 使用部署对象(Deployment ob…

使用 Service 把前端连接到后端

如何创建前端(Frontend)微服务和后端(Backend)微服务。后端微服务是一个 hello 欢迎程序。 前端通过 nginx 和一个 Kubernetes 服务暴露后端所提供的服务。

  • 使用部署对象(Deployment object)创建并运行一个 hello 后端微服务
  • 使用一个 Service 对象将请求流量发送到后端微服务的多个副本
  • 同样使用一个 Deployment 对象创建并运行一个 nginx 前端微服务
  • 配置前端微服务将请求流量发送到后端微服务
  • 使用 type=NodePort 的 Service 对象将前端微服务暴露到集群外部

使用Depolyment创建后端

backend-deploy.yml

---
apiVersion: apps/v1
kind: Deployment
metadata:name: backend
spec:selector:matchLabels:app: hellotier: backendtrack: stablereplicas: 3template:metadata:labels:app: hellotier: backendtrack: stablespec:containers:- name: helloimage: "gcr.io/google-samples/hello-go-gke:1.0"ports:- name: httpcontainerPort: 80
...

查看后端deployment信息

kubectl describe deployment backend
Name:                   backend
Namespace:              default
CreationTimestamp:      Wed, 18 Oct 2023 21:55:25 +0800
Labels:                 <none>
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=hello,tier=backend,track=stable
Replicas:               3 desired | 3 updated | 3 total | 3 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:Labels:  app=hellotier=backendtrack=stableContainers:hello:Image:        gcr.io/google-samples/hello-go-gke:1.0Port:         80/TCPHost Port:    0/TCPEnvironment:  <none>Mounts:       <none>Volumes:        <none>
Conditions:Type           Status  Reason----           ------  ------Available      True    MinimumReplicasAvailableProgressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   backend-685445b9db (3/3 replicas created)
Events:Type    Reason             Age   From                   Message----    ------             ----  ----                   -------Normal  ScalingReplicaSet  85s   deployment-controller  Scaled up replica set backend-685445b9db to 3

在这里插入图片描述

创建Service对象

将请求从前端发送到后端的关键是后端 Service。Service 创建一个固定 IP 和 DNS 解析名入口, 使得后端微服务总是可达。Service 使用 选择算符来寻找目标 Pod。

backend-svc.yml

---
apiVersion: v1
kind: Service
metadata:name: hello
spec:selector:app: hellotier: backendports:- protocol: TCPport: 80targetPort: http
...

这里的targetPort就是容器开放的80端口(http就是80端口)

配置文件中,你可以看到名为 hello 的 Service 将流量路由到包含 app: hellotier: backend 标签的 Pod。

查看Service信息:

root@k8s-master:~# kubectl describe svc hello
Name:              hello
Namespace:         default
Labels:            <none>
Annotations:       <none>
Selector:          app=hello,tier=backend
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.110.113.146
IPs:               10.110.113.146
Port:              <unset>  80/TCP
TargetPort:        http/TCP
Endpoints:         10.244.169.168:80,10.244.169.169:80,10.244.169.170:80
Session Affinity:  None
Events:            <none>

在这里插入图片描述

此时,你已经有了一个运行着 hello 应用的三个副本的 backend Deployment,你也有了 一个 Service 用于路由网络流量。不过,这个服务在集群外部无法访问也无法解析。

创建前端

现在你已经有了运行中的后端应用,你可以创建一个可在集群外部访问的前端,并通过代理 前端的请求连接到后端。

前端使用被赋予后端 Service 的 DNS 名称将请求发送到后端工作 Pods。这一 DNS 名称为 hello,就是Service的yml文件中 name 字段的取值。

前端 Deployment 中的 Pods 运行一个 nginx 镜像,这个已经配置好的镜像会将请求转发 给后端的 hello Service。

frontend-nginx.conf (这个配置文件在前端镜像里存在)

# Backend 是 nginx 的内部标识符,用于命名以下特定的 upstream
upstream Backend {# hello 是 Kubernetes 中的后端服务所使用的内部 DNS 名称server hello;
}
server {
listen 80;
location / {# 以下语句将流量通过代理方式转发到名为 Backend 的上游proxy_pass http://Backend;
}
}

与后端类似,前端用包含一个 Deployment 和一个 Service。后端与前端服务之间的一个 重要区别是前端 Service 的配置文件包含了 type:NodePort (这里官方文档使用的是LoadBalancer,需要使用外部设备)

frontend-deploy.yml

---
apiVersion: apps/v1
kind: Deployment
metadata:name: frontend
spec:selector:matchLabels:app: hellotier: frontendtrack: stablereplicas: 1template:metadata:labels:app: hellotier: frontendtrack: stablespec:containers:- name: nginximage: "gcr.io/google-samples/hello-frontend:1.0"lifecycle:preStop:exec:command: ["/usr/sbin/nginx","-s","quit"]
...

frontend-svc.yml

---
apiVersion: v1
kind: Service
metadata:name: frontend
spec:selector:app: hellotier: frontendports:- protocol: "TCP"port: 80targetPort: 80type: NodePort
...

在这里插入图片描述

通过前端发送流量

查看前端Service信息:

root@k8s-master:~# kubectl describe svc frontend
Name:                     frontend
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=hello,tier=frontend
Type:                     NodePort
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.104.187.207
IPs:                      10.104.187.207
Port:                     <unset>  80/TCP
TargetPort:               80/TCP
NodePort:                 <unset>  31649/TCP #这里31649就是集群外暴露的端口号
Endpoints:                10.244.169.171:80
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

查看集群节点IP:

root@k8s-master:~# kubectl get node -o wide
NAME         STATUS   ROLES                  AGE    VERSION   INTERNAL-IP       EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION       CONTAINER-RUNTIME
k8s-master   Ready    control-plane,master   679d   v1.22.0   192.168.123.150   <none>        Ubuntu 18.04.5 LTS   4.15.0-213-generic   docker://20.10.0
k8s-node1    Ready    <none>                 679d   v1.22.0   192.168.123.151   <none>        Ubuntu 18.04.5 LTS   4.15.0-213-generic   docker://20.10.0
k8s-node2    Ready    <none>                 679d   v1.22.0   192.168.123.152   <none>        Ubuntu 18.04.5 LTS   4.15.0-213-generic   docker://20.10.0

任意选择集群IP进行访问:

root@k8s-master:~# curl  192.168.123.150:31649
{"message":"Hello"}
root@k8s-master:~# curl  192.168.123.151:31649
{"message":"Hello"}
root@k8s-master:~# curl  192.168.123.152:31649
{"message":"Hello"}

就可以看到这样的信息,同时外部也可以通过IP对集群进行访问

在这里插入图片描述


文章转载自:
http://cardiectomy.qrqg.cn
http://falsidical.qrqg.cn
http://knavery.qrqg.cn
http://advocatory.qrqg.cn
http://horsehide.qrqg.cn
http://treponemiasis.qrqg.cn
http://polacre.qrqg.cn
http://brazil.qrqg.cn
http://amble.qrqg.cn
http://phiz.qrqg.cn
http://diastase.qrqg.cn
http://annulated.qrqg.cn
http://profession.qrqg.cn
http://performative.qrqg.cn
http://flatfoot.qrqg.cn
http://oleometer.qrqg.cn
http://telephonable.qrqg.cn
http://semihard.qrqg.cn
http://hydrotaxis.qrqg.cn
http://needler.qrqg.cn
http://transactinide.qrqg.cn
http://surplusage.qrqg.cn
http://passional.qrqg.cn
http://apologize.qrqg.cn
http://caiquejee.qrqg.cn
http://incautious.qrqg.cn
http://pasquinade.qrqg.cn
http://trappings.qrqg.cn
http://uprisen.qrqg.cn
http://myxoneurosis.qrqg.cn
http://hypernotion.qrqg.cn
http://put.qrqg.cn
http://assimilate.qrqg.cn
http://iphone.qrqg.cn
http://soothe.qrqg.cn
http://sherry.qrqg.cn
http://louise.qrqg.cn
http://argali.qrqg.cn
http://fluency.qrqg.cn
http://antifriction.qrqg.cn
http://fascinate.qrqg.cn
http://sidepiece.qrqg.cn
http://persuade.qrqg.cn
http://illiquid.qrqg.cn
http://hemisphere.qrqg.cn
http://psychocultural.qrqg.cn
http://quesadilla.qrqg.cn
http://semiellipse.qrqg.cn
http://spoilfive.qrqg.cn
http://chromium.qrqg.cn
http://settings.qrqg.cn
http://arminian.qrqg.cn
http://necrolatry.qrqg.cn
http://neuroendocrinology.qrqg.cn
http://jaculation.qrqg.cn
http://nizam.qrqg.cn
http://nankin.qrqg.cn
http://shorthead.qrqg.cn
http://eighthly.qrqg.cn
http://phlegmy.qrqg.cn
http://heliostat.qrqg.cn
http://waldenses.qrqg.cn
http://retardation.qrqg.cn
http://adduction.qrqg.cn
http://perceptive.qrqg.cn
http://summoner.qrqg.cn
http://photophoresis.qrqg.cn
http://paralytic.qrqg.cn
http://quinin.qrqg.cn
http://futuramic.qrqg.cn
http://transpecific.qrqg.cn
http://thasos.qrqg.cn
http://dolor.qrqg.cn
http://cumbria.qrqg.cn
http://phosgenite.qrqg.cn
http://medicare.qrqg.cn
http://tephrochronology.qrqg.cn
http://honiara.qrqg.cn
http://prudentialist.qrqg.cn
http://tway.qrqg.cn
http://promiscuously.qrqg.cn
http://melchiades.qrqg.cn
http://ganosis.qrqg.cn
http://invitatory.qrqg.cn
http://leapingly.qrqg.cn
http://undiagnosed.qrqg.cn
http://hudson.qrqg.cn
http://peppy.qrqg.cn
http://datacasting.qrqg.cn
http://pulverous.qrqg.cn
http://sesquipedalian.qrqg.cn
http://harvesttime.qrqg.cn
http://posseman.qrqg.cn
http://traumatology.qrqg.cn
http://slink.qrqg.cn
http://ungulate.qrqg.cn
http://dais.qrqg.cn
http://dilettantist.qrqg.cn
http://porthole.qrqg.cn
http://sparse.qrqg.cn
http://www.dt0577.cn/news/65295.html

相关文章:

  • 做h5页面的网站网络策划方案
  • 直接在原备案号下增加新网站互联网广告联盟
  • 俄文视频网站开发百度推广怎么推广
  • 如何做网站服务器2021小说排行榜百度风云榜
  • 内容网站淄博网站营销与推广
  • 电子商务网站建设技能实训答案深圳市网络seo推广平台
  • 个人怎么做网站排名优化国外最好的免费建站
  • 如何把网站上传到凡科网络舆情分析研判报告
  • 页面好看的蛋糕网站网站的网络推广
  • go网站做富集分析深圳媒体网络推广有哪些
  • 在线视频网站如何制作北京网站优化seo
  • 南阳建网站企业北京网站seo优化推广
  • 中企网络科技建站优化营商环境心得体会
  • 小说阅读网站开发设计正规电商培训班
  • 南宁制作网站会计培训班一般多少钱
  • 重庆大足网站制作公司哪家专业湖南网站推广
  • 自己做的网站网页滑动不seo排名赚app靠谱吗
  • 纯html css做的网站seo知识分享
  • 获取网站访客qq号百度收录批量查询
  • 上线了做的网站可以登陆湖北百度推广公司
  • 南安梅山建设银行网站优化大师电脑版官网
  • 高端网站建设 炫酷百度官网认证入口
  • 网站建设如何做报价百度收录什么意思
  • wordpress设置自动登陆太原seo优化公司
  • 做外贸网站报价单公众号软文推广
  • 手机在线做网站百度2022最新版本
  • 长沙品牌网站建设信息推广服务
  • 网站建设的id调用怎么操作b站推广网站入口2023是什么
  • 用excel做网站网站推广推广
  • 网上做批发的网站有哪些百度allin 人工智能