-7f68566795-8pl29 1/1 Running 3 2d tomcathost-7f68566795-mvg5f 1/1 Running...scale deployment tomcathost --replicas=5 deployment "tomcathost" scaled root@master:~# kubectl get pods...3 2d tomcathost-7f68566795-mvg5f 1/1 Running 3 2d tomcathost-7f68566795...# kubectl set image deployment/tomcathost tomcathost=bolingcavalry/k8stomcatdemo:0.0.3 deployment "tomcathost...18s tomcathost-6dfc87dc8b-pfb56 1/1 Running 0 10s tomcathost-6dfc87dc8b-x8pnn
我们一起来梳理一下吧: 按照原本的设计,此处的URL应该是http://tomcathost:8080/getserverinfo,tomcathost是Tomcat的Pod在kubernetes暴露的...service名称,在kubernetes环境中tomcathost会被解析成Tomcat的Pod地址,请求就到了Tomcat了; 但是,OpenResty的httpc:request_uri这个API...无法将tomcathost这个hostname解析成Tomcat的Pod地址,或者说不会用到kubernetes提供的DNS服务,因此请求无法到达Tomcat的Pod; 开涛大神的实例也用到了这个API...:8080; } 此upstream中的server用到了tomcathost,这是kubernetes中Tomcat的service的名字,能被成功的解析成Tomcat的Pod的IP; 2...service,名字是tomcathost,这样kubernetes环境中的其他Pod通过tomcathost这个hostname就能访问到Tomcat的Pod副本了; 3.
基本环境的配置,与第一章一致,Tomcat的deployment配置如下: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: tomcathost...spec: replicas: 1 template: metadata: labels: name: tomcathost spec: containers...: - name: tomcathost image: bolingcavalry/k8stomcatdemo:0.0.5 tty: true ports...create -f tomcat.yaml,tomcat-svc.yaml 横向扩容,将Pod数从1增加到8 将Pod数从1增加到8,执行以下命令即可: kubectl scale deployment tomcathost
JIT在理论上对结果有影响; 如何停止和删除原有的deployment和service 执行以下命令即可先删除service,再删除deployment: kubectl delete service tomcathost...&& kubectl delete deployment tomcathost 内存资源从256M提升到512M 打开上一章我们搭建web服务时创建的tomcat.yaml文件,内容如下: apiVersion...: extensions/v1beta1 kind: Deployment metadata: name: tomcathost spec: replicas: 1 template:...metadata: labels: name: tomcathost spec: containers: - name: tomcathost
/start_all.sh deployment "tomcathost" created service "tomcathost" created deployment "ng" created service..."ng" created nginx and tomcat running now 验证服务已经启动 先去kubernetes的管理页面看一下服务是否启动,如下图,名为ng、tomcathost的两个服务都已经启动...: 点击tomcathost服务,看到详情信息,里面有pod的情况,如下图: 上图中显示tomcathost是在node1创建的,我的node1机器的IP地址是192.168.119.153
80:30006/TCP 19h tomcat001 NodePort 10.43.141.37 8080:30991/TCP 51d tomcathost...1/1 Running 12 51d tomcat001-768557bfc9-lkl7b 1/1 Running 12 51d tomcathost...-59c9987c6f-8z7hz 1/1 Running 3 19h tomcathost-59c9987c6f-tlbp7 1/1 Running...3 19h tomcathost-59c9987c6f-w9kzz 1/1 Running 3 19h root@maven:~/.kube...1 1 19h tomcat001 2 2 2 2 51d tomcathost
spec: replicas: 1 template: metadata: labels: name: tomcathost spec: containers...: - name: tomcathost image: bolingcavalry/k8stomcatdemo:0.0.5 tty: true ports...在tomcat.yaml所在目录下创建文件tomcat-svc.yaml,内容如下: apiVersion: v1 kind: Service metadata: name: tomcathost...spec: type: NodePort ports: - port: 8080 nodePort: 30008 selector: name: tomcathost..." created service "tomcathost" created root@maven:/usr/local/work/ab# kubectl get services NAME
: - name: tomcathost image: bolingcavalry/k8stomcatdemo:0.0.1-SNAPSHOT tty: true...spec: type: ClusterIP ports: - port: 8080 selector: name: tomcathost 将上述脚本的几个关键点列举一下...: 服务对应的pod是tomcathost; type用ClusterIP,为内部service调用提供统一IP地址; 服务对外暴露了pod的8080端口; Nginx对应的Docker镜像 定制的Nginx...,这是tomcat的service名称,在Nginx运行的时候,通过tomcathost就能访问到tomcat的Pod; 制作Docker镜像的Dockerfile文件内容如下,每行都有注释就不再多说了...kubectl delete deployment tomcathost kubectl delete service ng kubectl delete deployment ng echo "nginx
always disconf_nginx: image: bolingcavalry/disconf_nginx:0.0.1 links: - disconf_tomcat:tomcathost
; #gzip on; #include /etc/nginx/conf.d/*.conf; upstream disconf { server tomcathost...disconf; } } } 主要的配置有三点: 将默认的/etc/nginx/conf.d/*.conf配置注释掉; 增加tomcat的host信息,“tomcathost...”和后面docker run的link参数的别名保持一致; 动静分离的配置,请求url中如果带有api和export,nginx就把请求转发到tomcathost:8080,其他的请求直接访问nginx...restart: always disconf_nginx: image: conf_nginx:0.0.1 links: - disconf_tomcat:tomcathost
conf.d/*.conf; # upstream disconf { # disconf服务的地址,为了通用这个nginx镜像,这里使用的别名的方式 # tomcathost...为disconf服务容器的名称,然后通过link的方式进行关联 server tomcathost:8080; } # server { listen
/bin/bash wget -qO- http://tomcathost:8080/zabbixcustomitemdemo/count?
然后,就可以通过如下地址访问web服务:http://:/resteasy/v1/fruits/apples。
领取专属 10元无门槛券
手把手带您无忧上云