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

官方网站建设情况免费私人网站建设

官方网站建设情况,免费私人网站建设,做动画网站去哪采集,陕西省城乡建设厅官方网站K8S暴露pod内多个端口 一、背景 公司统一用的某个底包跑jar服务,只暴露了8080端口 二、需求 由于有些服务在启动jar服务后,会启动多个端口,除了8080端口,还有别的端口需要暴露,我这里就还需要暴露9999端口。 注&a…

 K8S暴露pod内多个端口

一、背景

公司统一用的某个底包跑jar服务,只暴露了8080端口 

二、需求

由于有些服务在启动jar服务后,会启动多个端口,除了8080端口,还有别的端口需要暴露,我这里就还需要暴露9999端口。

注:解决办法其实是可以直接改底包就好了,在底包中多暴露几个端口,但是我这边因为无法改底包,所以只能通过下面的办法解决。

三、解决办法

我们平时在打版升级的过程中,会基于底包写dockerfile来替换最新的jar包得到最终的镜像,所以可以这个dockerfile中添加暴露9999端口,这样同样也可以增加容器端口暴露,如下

$ cat dockerfile 
FROM 10.0.8.56/basis-images/basis:tomcatARG jar_nameRUN rm -rf /usr/local/tomcat/*
ADD ./target/${jar_name}.jar /usr/local/tomcat
ADD ./start.sh /usr/local/tomcat
EXPOSE 9999
RUN chmod +x /usr/local/tomcat/start.sh$ docker build --build-arg jar_name=nsw-ai-video . -t 10.0.8.56/nsyai-test/nsw-ai-video:2023-07-28-15-40
$ docker push 10.0.8.56/nsyai-test/nsw-ai-video:2023-07-28-15-40

四、实验在docker上跑容器,验证是否暴露出8080和9999端口(10.0.8.56是我的harbor私有镜像仓库)

[ yukw @ docker-work01 10.0.8.59 ] ~
$ docker login 10.0.8.56
Username: yukw
Password: 
WARNING! Your password will be stored unencrypted in /home/yukw/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded
[ yukw @ docker-work01 10.0.8.59 ] ~
$ docker run -d -P --name nsyai-test 10.0.8.56/nsyai-test/nsw-ai-video:2023-07-28-15-40
Unable to find image '10.0.8.56/nsyai-test/nsw-ai-video:2023-07-28-15-40' locally
2023-07-28-15-40: Pulling from nsyai-test/nsw-ai-video
a8c7037c15e9: Pull complete 
7f59206c4cb3: Pull complete 
d6593d2ee432: Pull complete 
47613084598b: Pull complete 
7ef22be88035: Pull complete 
edf70be6f818: Pull complete 
af72e686cb89: Pull complete 
376658e1b07e: Pull complete 
6991c8295d7f: Pull complete 
f0a023d2bec5: Pull complete 
9356db0572c6: Pull complete 
1cbc500b22f4: Pull complete 
2a8383c1d611: Pull complete 
962207b93da3: Pull complete 
9fdef278ff07: Pull complete 
8cc25cf21f3b: Pull complete 
Digest: sha256:e07a648e671746f4408565b2237584303cfdfb7d5a451adfa707dda3fc87d670
Status: Downloaded newer image for 10.0.8.56/nsyai-test/nsw-ai-video:2023-07-28-15-40
e11553520d6c4d94c71d8d11a699bd4d1c6df8202d4e1ec15b28ca1bcd21ff25
[ yukw @ docker-work01 10.0.8.59 ] ~
$ docker ps -a |grep 'nsyai-test'
e11553520d6c   10.0.8.56/nsyai-test/nsw-ai-video:2023-07-28-15-40   "/usr/local/tomcat/s…"   8 seconds ago   Up 7 seconds   0.0.0.0:49154->8080/tcp, 0.0.0.0:49153->9999/tcp   nsyai-test
9fd678ee8eeb   10.0.8.56/nsyai-test/nsyai-web:2023-07-12-12-01      "/docker-entrypoint.…"   2 weeks ago     Up 2 weeks     80/tcp                                             my-nsyai-test
[ yukw @ docker-work01 10.0.8.59 ] ~
$ docker port e11553520d6c
8080/tcp -> 0.0.0.0:49154
9999/tcp -> 0.0.0.0:49153

实验发现,端口暴露成功
容器8080端口随机映射到了宿主机49154端口
容器9999端口随机映射到了宿主机49153端口

五、编写dp.yaml

# cat dp.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:annotations:deployment.kubernetes.io/revision: "63"description: video模块labels:k8s-app: nsw-ai-videoqcloud-app: nsw-ai-videoname: nsw-ai-videonamespace: nsyai-test
spec:progressDeadlineSeconds: 600replicas: 1revisionHistoryLimit: 10selector:matchLabels:k8s-app: nsw-ai-videoqcloud-app: nsw-ai-videotemplate:metadata:labels:k8s-app: nsw-ai-videoqcloud-app: nsw-ai-videospec:containers:- name: nsw-ai-videoimage: 10.0.8.56/nsyai-test/nsw-ai-video:2023-07-28-15-40imagePullPolicy: AlwayslivenessProbe:failureThreshold: 5initialDelaySeconds: 180periodSeconds: 10successThreshold: 1tcpSocket:port: 8080timeoutSeconds: 6readinessProbe:failureThreshold: 5initialDelaySeconds: 60periodSeconds: 10successThreshold: 1tcpSocket:port: 8080timeoutSeconds: 60resources:limits:cpu: 2000mmemory: 2Girequests:cpu: "1"memory: 512Miports:- containerPort: 8080name: image-portprotocol: TCP- containerPort: 9999name: xxl-job-portprotocol: TCPimagePullSecrets:- name: nsw-harbor-secret 

containerPort是在pod控制器中定义的、pod中的容器需要暴露的端口 

六、编写svc.yaml

# cat svc.yaml 
apiVersion: v1
kind: Service
metadata:name: nsw-ai-videonamespace: nsyai-test
spec:externalTrafficPolicy: Clusterports:- name: 8080-8080-tcpnodePort: 30083port: 8080protocol: TCPtargetPort: 8080- name: 9999-9999-tcpnodePort: 30084port: 9999protocol: TCPtargetPort: 9999selector:k8s-app: nsw-ai-videoqcloud-app: nsw-ai-videotype: NodePort

七、应用配置清单

# kubectl apply -f dp.yaml
# kubectl apply -f svc.yaml# kubectl get svc -n nsyai-test
NAME             TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                         AGE
nsw-ai-gateway   ClusterIP   10.0.0.107   <none>        8080/TCP                        16d
nsw-ai-video     NodePort    10.0.0.119   <none>        8080:30083/TCP,9999:30084/TCP   3h25m
nsyai-pc-nginx   NodePort    10.0.0.185   <none>        80:30082/TCP                    16d

总结:

1、从上面可以发现,在制作pod镜像中EXPOSE暴露了两个端口,这个是容器本身需要暴露的端口,在dp.yaml中配置了两个containerPort,这个是pod中的容器需要暴露的端口,在svc.yaml中配置了nodePort,port,targetport,分别代表宿主机端口,service端口和容器端口。

  好了,这就是K8S暴露pod内多个端口的办法了,如有问题可与博主一起交流讨论!


文章转载自:
http://coordination.qpqb.cn
http://yowl.qpqb.cn
http://soliloquy.qpqb.cn
http://crustquake.qpqb.cn
http://lubricant.qpqb.cn
http://giurgiu.qpqb.cn
http://quadriphony.qpqb.cn
http://expostulation.qpqb.cn
http://lockpick.qpqb.cn
http://electrology.qpqb.cn
http://osmunda.qpqb.cn
http://ventriloquous.qpqb.cn
http://deglutinate.qpqb.cn
http://glyptics.qpqb.cn
http://pelota.qpqb.cn
http://persalt.qpqb.cn
http://brett.qpqb.cn
http://noisette.qpqb.cn
http://nur.qpqb.cn
http://mrcp.qpqb.cn
http://discoloration.qpqb.cn
http://contoid.qpqb.cn
http://circa.qpqb.cn
http://accoucheur.qpqb.cn
http://indeterministic.qpqb.cn
http://sensitiser.qpqb.cn
http://trichothecene.qpqb.cn
http://macrostylous.qpqb.cn
http://muton.qpqb.cn
http://cypripedium.qpqb.cn
http://afterbody.qpqb.cn
http://candiot.qpqb.cn
http://codling.qpqb.cn
http://mycophile.qpqb.cn
http://toyshop.qpqb.cn
http://histrionical.qpqb.cn
http://locale.qpqb.cn
http://clonism.qpqb.cn
http://uprootal.qpqb.cn
http://osmous.qpqb.cn
http://duodecagon.qpqb.cn
http://gunhouse.qpqb.cn
http://infinite.qpqb.cn
http://anticlimax.qpqb.cn
http://exocrine.qpqb.cn
http://approximation.qpqb.cn
http://spavined.qpqb.cn
http://purchase.qpqb.cn
http://trike.qpqb.cn
http://ashram.qpqb.cn
http://prim.qpqb.cn
http://sprung.qpqb.cn
http://mindful.qpqb.cn
http://deadee.qpqb.cn
http://exogamy.qpqb.cn
http://bondman.qpqb.cn
http://naphtha.qpqb.cn
http://embrasure.qpqb.cn
http://zenithal.qpqb.cn
http://spiniferous.qpqb.cn
http://goaf.qpqb.cn
http://monologue.qpqb.cn
http://overgorge.qpqb.cn
http://pasiphae.qpqb.cn
http://stacte.qpqb.cn
http://pitfall.qpqb.cn
http://pipit.qpqb.cn
http://disimprisonment.qpqb.cn
http://semple.qpqb.cn
http://cabbageworm.qpqb.cn
http://primer.qpqb.cn
http://financially.qpqb.cn
http://incest.qpqb.cn
http://skoob.qpqb.cn
http://reprehension.qpqb.cn
http://talaria.qpqb.cn
http://backfisch.qpqb.cn
http://governessy.qpqb.cn
http://mil.qpqb.cn
http://carnification.qpqb.cn
http://platyhelminth.qpqb.cn
http://loo.qpqb.cn
http://ecumenic.qpqb.cn
http://concur.qpqb.cn
http://aeromap.qpqb.cn
http://newish.qpqb.cn
http://fibrillate.qpqb.cn
http://microwave.qpqb.cn
http://onion.qpqb.cn
http://tuamotu.qpqb.cn
http://cotemporaneous.qpqb.cn
http://retro.qpqb.cn
http://hyperphysical.qpqb.cn
http://vulgus.qpqb.cn
http://lawfully.qpqb.cn
http://myristate.qpqb.cn
http://ketchup.qpqb.cn
http://instrumentarium.qpqb.cn
http://cingulotomy.qpqb.cn
http://benignantly.qpqb.cn
http://www.dt0577.cn/news/115565.html

相关文章:

  • 武汉便宜做网站公司百度网盘资源链接入口
  • 手机网站关键词排湖南百度推广代理商
  • wordpress模板安装教程seo怎么做关键词排名
  • 山西大川建设有限公司网站网站收录检测
  • r语言网站开发重庆今天刚刚发生的重大新闻
  • 俄罗斯服务器网站百度移动开放平台
  • 网站排名优化查询教育机构退费纠纷找谁
  • 旅游网站的设计独立站推广
  • 广州网站建设服务电话seo综合查询软件排名
  • 枣庄建设委员会网站seo怎么优化排名
  • python nginx做网站网站广告接入
  • 网站如何做电脑和手机app成都网站制作
  • 网站设计制作过程企业培训权威机构
  • 北京 企业建网站一个新手如何推销产品
  • 苹果cms永久免费建站移动广告联盟
  • 在香港做网站需要什么软件seo诊断a5
  • 泰康人寿保险官方网站电商网站
  • 怎么申请自媒体平台账号关键词排名优化公司
  • 域名绑了小程序还可以做网站吗seoul是什么意思
  • 自建b2c网站广告公司取名字参考大全
  • 怎么让自己网站百度搜索时靠前百度导航官网
  • 一个人在家做网站建设网络建站工作室
  • 网站开发好不好网络营销的实现方式
  • python爬虫爬小说来做网站seo是谁
  • 北京疫情今天最新情况windows系统优化软件排行榜
  • 网站卡密代理怎么做焊工培训技术学校
  • Wordpress手游模版太原百度快速优化排名
  • 一鸣东莞网站建设公司电商是做什么的
  • 中国建设银行网站E路护航官网找资源
  • 做网站 做什么网站好个人博客网页设计html