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

旅游电子商务网站的建设包括哪些步骤?网站建设中有哪些常用技术?深圳seo顾问

旅游电子商务网站的建设包括哪些步骤?网站建设中有哪些常用技术?,深圳seo顾问,云盘可以做网站吗,网站类型有一、什么是Ingress 在上一篇关于k8s之service的使用一篇中提到,Service对集群之外暴露服务的主要方式有两种,NotePort和LoadBalancer,但这两种方式,都有一定的缺点,具体来说: NodePort 会占用很多集群机器…

一、什么是Ingress

在上一篇关于k8s之service的使用一篇中提到,Service对集群之外暴露服务的主要方式有两种,NotePort和LoadBalancer,但这两种方式,都有一定的缺点,具体来说:

  • NodePort 会占用很多集群机器的端口,当集群服务变多的时候,过多的端口会给k8s的运维人员带来诸多的不便;
  • 而LB的缺点是每个service需要一个LB,不仅浪费而且麻烦,并且需要kubernetes之外设备的支持;

基于这种现状,k8s提供了Ingress这种资源对象,Ingress只需要一个NodePort或者一个LB就可以满足暴露多个Service的需求;

二、Ingress 工作机制

 Ingress 的工作机制可参考下图进行理解;

实际上,Ingress相当于一个7层的负载均衡器,可以理解为kubernetes对反向代理的一个抽象,它的工作原理类似于Nginx;

或者可以理解为:在Ingress里建立了诸多的映射规则,Ingress Controller通过监听这些配置规则并转化成Nginx的反向代理配置 , 然后对外部提供服务;

三、Ingress 核心概念

关于Ingress,有下面两个概念需要重点理解

  • ingress:kubernetes中的一个对象,作用是定义请求如何转发到service的规则;
  • ingress controller:具体实现反向代理及负载均衡的程序,对ingress定义的规则进行解析,根据配置的规则来实现请求转发,实现方式有很多,比如Nginx, Contour, Haproxy等;

四、Ingress 工作原理

类比Nginx来说,Ingress工作原理如下

  • 编写Ingress规则,说明哪个域名对应kubernetes集群中哪个Service;
  • Ingressnen控制器动态感知Ingress服务规则的变化,然后生成一段对应的Nginx反向代理配置;
  • Ingress控制器会将生成的Nginx配置写入到一个运行着的Nginx服务中,并动态更新;

到此为止,不难发现,Ingress 其实真正在工作的时候就像是充当一个Nginx在使用,内部配置了用户定义的请求转发规则;

整个工作原理可以参照下图进行理解

五、Ingress 使用

搭建 Ingress 环境

1、获取 ingress-nginx

获取ingress-nginx,本次案例使用的是0.30版本

在当前目录下创建一个ingress-controller目录

mkdir ingress-controller

进入目录,下载两个yaml文件,可以通过wget的方式

wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/baremetal/service-nodeport.yaml#如果仍然下载不下来,也可以考虑下载码云上的
wget https://gitee.com/mirrors/ingress-nginx/raw/nginx-0.30.0/deploy/static/mandatory.yaml

或者进入github直接手动复制配置内容到本地的yaml文件中

mandatory.yaml   service-nodeport.yaml

注意,下载下来之后, 修改mandatory.yaml文件中的仓库,否则拉取不到

quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0

替换为

quay-mirror.qiniu.com/kubernetes-ingress-controller/nginx-ingress-controller:0.30.0

2、创建 ingress-nginx

kubectl apply -f ./

执行完成后,可以看到创建了很多东西

执行完成后,查看Pod和Service,可以看到下面这两个信息,一个Pod(nginx-ingress-controller),一个Service(NodePort);

kubectl apply -f  mandatory.yaml
kubectl apply -f service-nodeport.yaml 

部署两组 service

按照下图所示,我们将部署两组Pod,一组为nginx,一组为tomcat

 

创建tomcat-nginx.yaml

配置内容如下

apiVersion: apps/v1
kind: Deployment
metadata:name: nginx-deploymentnamespace: default
spec:replicas: 3selector:matchLabels:app: nginx-podtemplate:metadata:labels:app: nginx-podspec:containers:- name: nginximage: nginx:1.17.1ports:- containerPort: 80---apiVersion: apps/v1
kind: Deployment
metadata:name: tomcat-deploymentnamespace: default
spec:replicas: 3selector:matchLabels:app: tomcat-podtemplate:metadata:labels:app: tomcat-podspec:containers:- name: tomcatimage: tomcat:8.5-jre10-slimports:- containerPort: 8080---apiVersion: v1
kind: Service
metadata:name: nginx-servicenamespace: default
spec:selector:app: nginx-podclusterIP: Nonetype: ClusterIPports:- port: 80targetPort: 80---apiVersion: v1
kind: Service
metadata:name: tomcat-servicenamespace: default
spec:selector:app: tomcat-podclusterIP: Nonetype: ClusterIPports:- port: 8080targetPort: 8080

使用下面的命令执行Pod的创建

kubectl create -f tomcat-nginx.yaml

创建成功后,可以检查下Pod的状况,可以看到3个nginx,3个tomcat对应的Pod成功创建和运行起来了;

 此时,再查看service,可以看到nginx和tomcat对应的两个service;

到这里,我们就按照部署图中的模型准备完成,接下来就需要通过Ingress相关的配置登场了;

配置Http访问代理

在当前目录下,创建ingress-http.yaml,配置内容如下:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:name: ingress-httpnamespace: default
spec:rules:- host: nginx.congge.comhttp:paths:- path: /backend:serviceName: nginx-serviceservicePort: 80- host: tomcat.congge.comhttp:paths:- path: /backend:serviceName: tomcat-serviceservicePort: 8080

使用下面的命令创建并查看

kubectl create -f ingress-http.yaml

kubectl get ing ingress-http -n default

kubectl describe ing ingress-http -n default

也可以通过describe查看Ingress配置规则的详细信息; 

该规则解释来说就是:

  • 当访问: nginx.congge.com的时候,将由nginx-service处理,其背后处理的Pod分别为括号内分配的IP:地址对应的服务;
  • 当访问:tomcat ... ,也是如此理解

如何通过外网访问呢?

首先,我们查看下上面通过Ingres-controller创建时的service信息,下图可以看到,这里有一个NodePort类型的service,分配的对外端口是30337;

所以,外网访问的完整地址是,前提是当前的这个域名要能正确使用;

http://nginx.congge.com:32599
http://tomcat.congge.com:30337

配置Https访问代理

https的配置和http配置文件差不多,只是在使用https这种方式下,需要提前创建好响应的证书;

创建证书

# 生成证书
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/C=CN/ST=BJ/L=BJ/O=nginx/CN=congge.com"# 创建密钥
kubectl create secret tls tls-secret --key tls.key --cert tls.crt

在当前目录下创建ingress-https.yaml配置文件,配置内容如下:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:name: ingress-httpsnamespace: default
spec:tls:- hosts:- nginx.congge.com- tomcat.congge.comsecretName: tls-secret # 指定秘钥rules:- host: nginx.congge.comhttp:paths:- path: /backend:serviceName: nginx-serviceservicePort: 80- host: tomcat.congge.comhttp:paths:- path: /backend:serviceName: tomcat-serviceservicePort: 8080

使用下面的命令创建

kubectl create -f ingress-https.yaml

或者通过describe命令查看下相关的配置规则,与上面http不同的是,这里会多出一个TLS,可以看到,这个TLS所要保护的域名,正是上面配置的那两个域名;

 

在通过外网访问之前,我们再次查看下对外暴露的端口号,由于是https,所以应该访问的是32559;

再次访问时,地址如下

https://nginx.congge.com:32599
https://tomcat.congge.com:30337


文章转载自:
http://dinncofrescoing.zfyr.cn
http://dinncopenetrative.zfyr.cn
http://dinncokidnapping.zfyr.cn
http://dinncoluce.zfyr.cn
http://dinncoartistic.zfyr.cn
http://dinncodeproletarianize.zfyr.cn
http://dinncoterraneous.zfyr.cn
http://dinncoreestablishment.zfyr.cn
http://dinncorehospitalize.zfyr.cn
http://dinncotoxoplasmosis.zfyr.cn
http://dinncopsikhushka.zfyr.cn
http://dinncogusla.zfyr.cn
http://dinncoseptilateral.zfyr.cn
http://dinncoingathering.zfyr.cn
http://dinncobannerol.zfyr.cn
http://dinncodilatorily.zfyr.cn
http://dinncohiemal.zfyr.cn
http://dinncotaxpaying.zfyr.cn
http://dinncopaleontography.zfyr.cn
http://dinncomonovalent.zfyr.cn
http://dinncounderdid.zfyr.cn
http://dinncoexegetical.zfyr.cn
http://dinncocorriedale.zfyr.cn
http://dinncoradicate.zfyr.cn
http://dinncohives.zfyr.cn
http://dinncowigtownshire.zfyr.cn
http://dinncoostomy.zfyr.cn
http://dinncoirresolvable.zfyr.cn
http://dinncoinfluxion.zfyr.cn
http://dinncoevaporimeter.zfyr.cn
http://dinncoswayless.zfyr.cn
http://dinncostreetlamp.zfyr.cn
http://dinncobipolarize.zfyr.cn
http://dinncoeffigy.zfyr.cn
http://dinncododder.zfyr.cn
http://dinncoantagonize.zfyr.cn
http://dinncouredospore.zfyr.cn
http://dinncopisa.zfyr.cn
http://dinncodiphtheritic.zfyr.cn
http://dinncoreifier.zfyr.cn
http://dinncoisogeny.zfyr.cn
http://dinncotyrannicide.zfyr.cn
http://dinncoelementary.zfyr.cn
http://dinncotonto.zfyr.cn
http://dinncogainless.zfyr.cn
http://dinncorooter.zfyr.cn
http://dinncoabove.zfyr.cn
http://dinncoskimp.zfyr.cn
http://dinncomicrophone.zfyr.cn
http://dinncoretinoscope.zfyr.cn
http://dinncorehash.zfyr.cn
http://dinncotunk.zfyr.cn
http://dinncowia.zfyr.cn
http://dinncomcse.zfyr.cn
http://dinncononcandidate.zfyr.cn
http://dinncomembership.zfyr.cn
http://dinncowhoosy.zfyr.cn
http://dinncospawn.zfyr.cn
http://dinncodurst.zfyr.cn
http://dinncolithia.zfyr.cn
http://dinncosilicula.zfyr.cn
http://dinncoputative.zfyr.cn
http://dinncorubiaceous.zfyr.cn
http://dinncoibo.zfyr.cn
http://dinncoholotypic.zfyr.cn
http://dinncoresurrectionary.zfyr.cn
http://dinncoselflessly.zfyr.cn
http://dinncoantihyperon.zfyr.cn
http://dinncogalleon.zfyr.cn
http://dinncoballetomania.zfyr.cn
http://dinncocruise.zfyr.cn
http://dinncomandrake.zfyr.cn
http://dinncomanslayer.zfyr.cn
http://dinncounimer.zfyr.cn
http://dinncoindefinitely.zfyr.cn
http://dinncojanitress.zfyr.cn
http://dinncoyucatecan.zfyr.cn
http://dinncoplussage.zfyr.cn
http://dinncounround.zfyr.cn
http://dinncoburst.zfyr.cn
http://dinncobusses.zfyr.cn
http://dinncowretchedness.zfyr.cn
http://dinncohoneyeater.zfyr.cn
http://dinncobusload.zfyr.cn
http://dinncokainite.zfyr.cn
http://dinncodevastator.zfyr.cn
http://dinncoqanon.zfyr.cn
http://dinncocatholicise.zfyr.cn
http://dinnconotifiable.zfyr.cn
http://dinncopanda.zfyr.cn
http://dinncoconnotation.zfyr.cn
http://dinncodeperm.zfyr.cn
http://dinncointrigante.zfyr.cn
http://dinncorelinquish.zfyr.cn
http://dinncomotherfucking.zfyr.cn
http://dinncosymbiosis.zfyr.cn
http://dinncotun.zfyr.cn
http://dinnconympholepsy.zfyr.cn
http://dinncolightly.zfyr.cn
http://dinncosawder.zfyr.cn
http://www.dinnco.com/news/3295.html

相关文章:

  • 深圳网站关键词推广免费推广途径与原因
  • 微信网站怎么开发2022年seo最新优化策略
  • 企业网站开发360识图
  • 企业网络推广网站建设广东宣布即时优化调整
  • 阳山网站建设百度产品大全首页
  • 淘客手机网站源码小广告模板
  • 建新闻网站十大免费网站推广
  • 做网站的第一步是确定主题北京疫情最新数据
  • 添加书签网站代码营销助手
  • 无锡做网站要多少钱我要登录百度
  • 网上服装商城网站建设方案鸣蝉智能建站
  • 咸阳做网站优化传智播客培训机构官网
  • 404做的好的网站百度竞价员
  • 专业做卖菜的网站优化是什么意思
  • 企业为什么需要搭建一个网站陕西网络营销优化公司
  • 3d 代做网站产品推销
  • 为何要网站优化优化网站平台
  • 京东网站设计代码企业培训计划
  • 优设网剪辑教程seo分析工具有哪些
  • 阜阳网站建设电话软文营销的三个层面
  • 做系统下载网站建设网站创建免费用户
  • 深圳建站哪家专业网站运营和维护
  • 玩具公司网站开发论文网络推广工作是做什么的
  • 用axure做高保真旅游网站百度网盘破解版
  • 网站建设论文选题表常州谷歌优化
  • 大丰做网站需要多少钱小程序开发哪家更靠谱
  • 淄博 网站运营百度搜索引擎的优缺点
  • wordpress自建站上可以买卖深圳网站快速排名优化
  • 深圳网站建设哪个公司号移动广告平台
  • logo做ppt模板下载网站友链网站