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

做视频直播网站需要多少资金知乎推广公司

做视频直播网站需要多少资金,知乎推广公司,杭州企业网站设计公司,上海网站建设设问题 我需要在k8s集群里面部署springboot服务,通过k8s ingress访问集群内部的springboot服务,应该怎么做? 这里假设已经准备好k8s集群,而且也准备好springboot服务的运行镜像了。这里我们将精力放在k8s服务编排上面。 一图胜千言…

问题

我需要在k8s集群里面部署springboot服务,通过k8s ingress访问集群内部的springboot服务,应该怎么做?
这里假设已经准备好k8s集群,而且也准备好springboot服务的运行镜像了。这里我们将精力放在k8s服务编排上面。

一图胜千言

ingress最简扇出模式
上图来自于kubernetes的ingress教程。接下来,我们按照上述部署1个ingress+2个服务。

service1

先用kubectl命令创建一个deployment.yaml和service.yaml,然后,将这两个内容合并到一个文件中,即service1.yaml。具体命令如下:
创建deployment.yaml:

kubectl create deployment service1 --image xxx.dkr.ecr.us-east-1.amazonaws.com/service1:latest -o yaml --dry-run=client > k8s/deployment.yaml 

创建service.yaml:

 kubectl create service clusterip service1 --tcp 8080:8080 -o yaml --dry-run=client > k8s/service.yaml 

根据自己需求,去掉一下不要的内容,调整相关配置,合并成如下内容:

service1.yaml

apiVersion: apps/v1
kind: Deployment
metadata:labels:app: service1name: service1
spec:replicas: 2selector:matchLabels:app: service1template:metadata:labels:app: service1spec:containers:- image: xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/service1:latestname: service1resources:requests:memory: "2Gi"cpu: "2"limits:memory: "2Gi"cpu: "2"# 准备检查,通过则接入流量readinessProbe:httpGet:path: /foo/actuator/healthport: 8080# 活力检查,不通过时重启容器livenessProbe:httpGet:path: /foo/actuator/healthport: 8080
---
apiVersion: v1
kind: Service
metadata:labels:app: service1name: service1
spec:ports:- name: httpport: 4200targetPort: 4200selector:app: service1type: ClusterIP

service2

按之前service1方式,获得如下内容:

service2.yaml

apiVersion: apps/v1
kind: Deployment
metadata:labels:app: service2name: service2
spec:replicas: 2selector:matchLabels:app: service2template:metadata:labels:app: service2spec:containers:- image: xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/service2:latestname: service2resources:requests:memory: "2Gi"cpu: "2"limits:memory: "2Gi"cpu: "2"# 准备检查,通过则接入流量readinessProbe:httpGet:path: /bar/actuator/healthport: 8080# 活力检查,不通过时重启容器livenessProbe:httpGet:path: /bar/actuator/healthport: 8080
---
apiVersion: v1
kind: Service
metadata:labels:app: service2name: service2
spec:ports:- name: httpport: 8080targetPort: 8080selector:app: service2type: ClusterIP

ingress

使用kubectl命令获得ingress基本配置,如下命令:

kubectl create ingress ingress --rule="/path=service1:8080" -o yaml --dry-run=client > k8s/ingress.yaml

根据自己的需求调整后的内容如下:

ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:name: ingress
spec:rules:- http:paths:- backend:service:name: service1port:number: 4200path: /foopathType: Prefix- backend:service:name: service2port:number: 8080path: /barpathType: Prefix

这里有个问题,由于我现在使用的aws云,所以,这k8s ingress在aws云环境下面,需要针对这种情况调整aws云相关配置。

AWS EKS配置AWS Load Balancer Controller

为集群创建 IAM OIDC 提供商

找到现有集群的OpenID Connect 提供商 URL值,点击copy,如下图:
复制集群的OpenID
然后,回到IAM主页,为集群创建 IAM OIDC 提供商,具体如下:
添加提供商
创建提供商如下图:
创建身份提供商

AWS Load Balancer Controller 部署到EKS
创建AWSLoadBalancerControllerIAMPolicy策略

我这里用到aws云区是普通云区,所以,这里使用的aws-load-balancer-controller的策略脚本如下:
https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/main/docs/install/iam_policy.json
下载命令如下:

curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/main/docs/install/iam_policy.json

新建一个策略:

aws iam create-policy \--policy-name AWSLoadBalancerControllerIAMPolicy \--policy-document file://iam-policy.json
创建一个ServiceAccount给k8s
eksctl create iamserviceaccount \
--cluster=<cluster-name> \
--namespace=kube-system \
--name=aws-load-balancer-controller \
--attach-policy-arn=arn:aws:iam::<AWS_ACCOUNT_ID>:policy/AWSLoadBalancerControllerIAMPolicy \
--override-existing-serviceaccounts \
--region <region-code> \
--approve

这里用到eksctl命令,给k8s集群创建一个ServiceAccount服务账号aws-load-balancer-controller,并使用上面之前创建的权限策略。怎么安装eksctl命令,可以看看官网,这里就不提了。

helm安装aws-load-balancer-controller

这里假设我们已经会使用k8s集群的包管理器helm了。
添加EKS资源库到helm,如下命令:

helm repo add eks https://aws.github.io/eks-charts

更新本地资源库,如下命令:

helm repo update eks

安装aws-load-balancer-controller,如下命令:

helm install aws-load-balancer-controller eks/aws-load-balancer-controller --set clusterName=my-cluster -n kube-system --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller

等待一段时间出现,如下反馈,说明aws-load-balancer-controller安装成功:

NAME: aws-load-balancer-controller
LAST DEPLOYED: Thu Mar  7 15:11:01 2024
NAMESPACE: kube-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
AWS Load Balancer controller installed!

如果出现,如下错误:
Error: INSTALLATION FAILED: cannot re-use a name that is still in use
说明,需要先卸载,再安装,具体命令如下:

helm delete aws-load-balancer-controller -n kube-system

检查k8s集群中aws-load-balancer-controller是否安装成功,具体命令如下:

kubectl get deployment -n kube-system aws-load-balancer-controller

安装成功示例,如下:

NAME                           READY   UP-TO-DATE   AVAILABLE   AGE
aws-load-balancer-controller   2/2     2            2           10m

调整ingress配置

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:name: ingressannotations:# alb名称alb.ingress.kubernetes.io/load-balancer-name: apg2# 内网alb.ingress.kubernetes.io/scheme: internal# 流量路由到pod层面alb.ingress.kubernetes.io/target-type: ip
spec:# 使用alb作为ingress默认类ingressClassName: albrules:- http:paths:- backend:service:name: service1port:number: 4200path: /foopathType: Prefix- backend:service:name: service2port:number: 8080path: /barpathType: Prefix

调整service配置

除了再ingress里面添加lbc注解之外,还需要再service中添加健康检查的lbc注解:

  annotations:alb.ingress.kubernetes.io/healthcheck-path: /api/demo/actuator/health
service1.yaml
apiVersion: apps/v1
kind: Deployment
metadata:labels:app: service1name: service1
spec:replicas: 2selector:matchLabels:app: service1template:metadata:labels:app: service1spec:containers:- image: xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/service1:latestname: service1resources:requests:memory: "2Gi"cpu: "2"limits:memory: "2Gi"cpu: "2"# 准备检查,通过则接入流量readinessProbe:httpGet:path: /foo/actuator/healthport: 8080# 活力检查,不通过时重启容器livenessProbe:httpGet:path: /foo/actuator/healthport: 8080
---
apiVersion: v1
kind: Service
metadata:labels:app: service1name: service1annotations:# aws目标组健康检查alb.ingress.kubernetes.io/healthcheck-path: /for/actuator/health
spec:ports:- name: httpport: 4200targetPort: 4200selector:app: service1type: ClusterIP
service2.yaml
apiVersion: apps/v1
kind: Deployment
metadata:labels:app: service2name: service2
spec:replicas: 2selector:matchLabels:app: service2template:metadata:labels:app: service2spec:containers:- image: xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/service2:latestname: service2resources:requests:memory: "2Gi"cpu: "2"limits:memory: "2Gi"cpu: "2"# 准备检查,通过则接入流量readinessProbe:httpGet:path: /bar/actuator/healthport: 8080# 活力检查,不通过时重启容器livenessProbe:httpGet:path: /bar/actuator/healthport: 8080
---
apiVersion: v1
kind: Service
metadata:labels:app: service2name: service2annotations:# aws目标组健康检查alb.ingress.kubernetes.io/healthcheck-path: /bar/actuator/health
spec:ports:- name: httpport: 8080targetPort: 8080selector:app: service2type: ClusterIP

部署

kubectl apply -f ./k8s

清除资源:

kubectl delete -f ./k8s

总结

AWS Load Balancer Controller没有重写路径功能,注意安全。这里只介绍的主要是EKS创建ALB在私有VPC内部访问。这里没有介绍CDN套在API接口外面的情况,一般来说,预算足够的情况下面,都会在API接口外面套一层CDN服务。需要注意的是AWS CloudFront(CDN服务)只支持公网的LB。不知道什么原因维护AWS Load Balancer Controller(LBC)团队的人,死活不肯提供重写路径功能。这里还没有服务监控,有机会再介绍介绍吧!
下面是公有ingress创建ALB的配置:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:name: ingressannotations:# alb名称alb.ingress.kubernetes.io/load-balancer-name: apg2# 只让cdn(CloudFront)访问负载均衡器alb.ingress.kubernetes.io/security-groups: cloudfront-only# pod和node安全组自动生成alb.ingress.kubernetes.io/manage-backend-security-group-rules: "true"# 公网alb.ingress.kubernetes.io/scheme: internet-facing# 流量路由到pod层面alb.ingress.kubernetes.io/target-type: ip
spec:# 使用alb作为ingress默认类ingressClassName: albrules:- http:paths:- backend:service:name: service1port:number: 4200path: /foopathType: Prefix- backend:service:name: service2port:number: 8080path: /barpathType: Prefix

就这样吧,ingress用http端口,然后限制只有cdn节点才能访问,这样公网alb就相对安全了一些。加上前面有cdn的话,基本上没人知道真实的alb地址。

参考:

  • Ingress
  • Deploy a Spring Boot application on a multi-architecture Amazon EKS cluster
  • Spring on Kubernetes
  • Spring Boot Kubernetes
  • Amazon EKS 上的应用程序负载均衡
  • 安装AWS Load Balancer Controller
  • 安装 AWS Load Balancer Controller 附加组件
  • Security Groups for Load Balancers

文章转载自:
http://dinncolifeline.wbqt.cn
http://dinncode.wbqt.cn
http://dinncogairish.wbqt.cn
http://dinncobrompton.wbqt.cn
http://dinncodecentralisation.wbqt.cn
http://dinncoboong.wbqt.cn
http://dinncoratable.wbqt.cn
http://dinncoothello.wbqt.cn
http://dinncopriestless.wbqt.cn
http://dinncolens.wbqt.cn
http://dinncogufa.wbqt.cn
http://dinncomacchinetta.wbqt.cn
http://dinncounattached.wbqt.cn
http://dinncorampion.wbqt.cn
http://dinncoalabamian.wbqt.cn
http://dinncofunebrial.wbqt.cn
http://dinncooutpoll.wbqt.cn
http://dinncoelfish.wbqt.cn
http://dinncoanaesthetist.wbqt.cn
http://dinncoovercrust.wbqt.cn
http://dinnconitrosyl.wbqt.cn
http://dinncoshereef.wbqt.cn
http://dinncodiarthrodial.wbqt.cn
http://dinncofoh.wbqt.cn
http://dinncotelevox.wbqt.cn
http://dinncoineludible.wbqt.cn
http://dinncozoochore.wbqt.cn
http://dinncojot.wbqt.cn
http://dinncotelome.wbqt.cn
http://dinncoamatory.wbqt.cn
http://dinncotrinary.wbqt.cn
http://dinncotwelvepence.wbqt.cn
http://dinncodogfish.wbqt.cn
http://dinncodope.wbqt.cn
http://dinncodisaggregation.wbqt.cn
http://dinncodeliquesce.wbqt.cn
http://dinncofranking.wbqt.cn
http://dinncointerrelated.wbqt.cn
http://dinncosugarhouse.wbqt.cn
http://dinncoprowler.wbqt.cn
http://dinncorozzer.wbqt.cn
http://dinncofarmyard.wbqt.cn
http://dinncocybernetic.wbqt.cn
http://dinncocannular.wbqt.cn
http://dinncosnippet.wbqt.cn
http://dinncoforegather.wbqt.cn
http://dinncomoniliasis.wbqt.cn
http://dinncobeatitude.wbqt.cn
http://dinncocondonement.wbqt.cn
http://dinncochemiosmotic.wbqt.cn
http://dinncominor.wbqt.cn
http://dinncoyeo.wbqt.cn
http://dinncodredlock.wbqt.cn
http://dinncoarteriogram.wbqt.cn
http://dinncops.wbqt.cn
http://dinncozirconium.wbqt.cn
http://dinncomonochromical.wbqt.cn
http://dinncokitchensink.wbqt.cn
http://dinnconit.wbqt.cn
http://dinncofulcrum.wbqt.cn
http://dinncostructuralist.wbqt.cn
http://dinncoobedientiary.wbqt.cn
http://dinncoatlantic.wbqt.cn
http://dinncomagnetodisk.wbqt.cn
http://dinncohypobarism.wbqt.cn
http://dinncobiotite.wbqt.cn
http://dinncovomitous.wbqt.cn
http://dinncomedicament.wbqt.cn
http://dinncokrakatau.wbqt.cn
http://dinncodruid.wbqt.cn
http://dinncothumbtack.wbqt.cn
http://dinncoringtaw.wbqt.cn
http://dinncoiaea.wbqt.cn
http://dinncocoot.wbqt.cn
http://dinncothermobarograph.wbqt.cn
http://dinncobedizen.wbqt.cn
http://dinncotherefore.wbqt.cn
http://dinncohomy.wbqt.cn
http://dinncoeructate.wbqt.cn
http://dinncohonorably.wbqt.cn
http://dinncoslushy.wbqt.cn
http://dinncoastigmatometry.wbqt.cn
http://dinncoblende.wbqt.cn
http://dinncosensorium.wbqt.cn
http://dinncogreenery.wbqt.cn
http://dinncounhomogeneous.wbqt.cn
http://dinncocalf.wbqt.cn
http://dinncohopscotch.wbqt.cn
http://dinncoanthology.wbqt.cn
http://dinncohariana.wbqt.cn
http://dinncoelasmobranchiate.wbqt.cn
http://dinncobareheaded.wbqt.cn
http://dinncopreclude.wbqt.cn
http://dinncoreagent.wbqt.cn
http://dinncoamadou.wbqt.cn
http://dinncomillimicrosecond.wbqt.cn
http://dinncohyphenation.wbqt.cn
http://dinncoapostasy.wbqt.cn
http://dinncomutant.wbqt.cn
http://dinncolowland.wbqt.cn
http://www.dinnco.com/news/154707.html

相关文章:

  • 怎么搞免费的网站seo排名点击报价
  • 安康做网站电话1688如何搜索关键词排名
  • 搭建漏洞网站北京seo推广公司
  • 南川网站建设怎么分析一个网站seo
  • wordpress主题美化seo优化广告
  • 智慧团建网快速排名seo
  • 根目录下两个网站怎么做域名解析社群营销案例
  • 栖霞建设招标网站浏览器下载大全
  • 网站建设调研报告的前言推广平台有哪些
  • 宿迁建设局网站a类证查询深圳seo推广外包
  • 织梦开发供需网站宁波专业seo外包
  • 网站建设 百度云盘百度网址怎么输入?
  • 制作网站专业公司吗长沙百度推广开户
  • 做网站要域名吗线下引流推广方法
  • 梧州网站优化价格seo优化价格
  • 做理论的网站武汉关键词排名工具
  • vps除了做网站还能做什么网站建设方案书模板
  • 怎么去掉网站底部信息最近五天的新闻大事
  • 做蛋糕网站的 实训报告图新闻头条今日要闻
  • 优秀网站设计案例分析外链工厂 外链
  • 做产品类的工作上什么网站好p站关键词排名
  • 房地产公司网站制作微信朋友圈软文大全
  • 肇庆网络营销外包公司郑州网站seo优化公司
  • 贵阳公司做网站加强服务保障 满足群众急需需求
  • 建网站需要多大的宽带自己有网站怎么推广
  • python 爬虫 做网站怎么利用互联网推广
  • 手机版网站嵌入代码企业类网站有哪些例子
  • 怎样做动态网站模板建站平台
  • 做网站的要求seo定义
  • wordpress 导航标签长春百度seo公司