kubernetes集群搭建(6):kubernetes基本使用演示
以简单部署访问来演示kubernetes的基本使用
流程: 用户访问client应用,client应用中调用server应用,由于部署了多节点,client在访问server时应该配置server 暴露的虚拟IP地址
由于DNS暂未配置成功,在client调用server时配置的是server的cluster ip而不是服务名
server端与client端均为springboot web应用
1.代码示例:
server端代码:打包为server.jar
@RestController
public class PermissionController { @RequestMapping("/permission/check")
public Result permissionCheck(@RequestBody PermissionParam permissionParam) { System.out.println("接收到验证请求:"+JSON.toJSONString(permissionParam));
if(permissionParam.getRequestURI().equals("/permission/test")){
return new Result();
} else {
return new Result("x00001","无权限进行此操作");
}
} @RequestMapping("/test")
public Result test() {
return new Result("访问成功 "+System.currentTimeMillis());
} }
client端代码:打包为client.jar
@RestController
public class PermissionController { @Value("${server_url}")
private String permissionServerUrl; @Autowired
PermissionCheckService permissionService; @RequestMapping("/permission/test")
public Result permissionTest() {
return new Result("有权限,访问成功。运行参数为:"+ permissionServerUrl);
} @RequestMapping("/test")
public Result test() {
return new Result("访问成功 "+System.currentTimeMillis());
} }
Controller
@Service
public class PermissionCheckService {
@Value("${server_url}")
private String permissionServerUrl; @Autowired
private RestTemplate restTemplate; public Result permissionCheck(Long userId, Integer appId, String uri) throws RestClientException, URISyntaxException {
ResponseEntity<Result> result = restTemplate.postForEntity(new URI(permissionServerUrl + "/permission/check"),
new PermissionParam(userId, appId, uri), Result.class);
return result.getBody();
}
}
service
client端拦截器:用于在接收到请求时,调用server端接口验证是否有权限访问
package com.phicomm.permission.client.config; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import com.alibaba.fastjson.JSON;
import com.phicomm.permission.client.service.PermissionCheckService;
import com.phicomm.permission.lib.Result; @Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter { @Bean
public PermissionCheckInterceptor getPermissionCheckInterceptor() {
return new PermissionCheckInterceptor();
} @Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(getPermissionCheckInterceptor()).addPathPatterns("/**").excludePathPatterns("/test");
super.addInterceptors(registry);
} class PermissionCheckInterceptor implements HandlerInterceptor {
@Autowired
PermissionCheckService permissionCheckService; @Override
public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
throws Exception {
} @Override
public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
throws Exception { } @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
String uri = request.getRequestURI();
Integer appId = 1;
System.out.println("开始权限验证:"+ uri); Result result = permissionCheckService.permissionCheck(1L, appId, uri);
if (result.getStatus().equals(Result.Status.SUCCESS.code())) {
return true;
} else {
response.setContentType("application/json;charset=utf-8");
response.getWriter().write(JSON.toJSONString(result));
return false;
}
} }
}
PermissionCheckInterceptor
2.docker镜像制作:
a.上传server.jar 和 client.jar 及jdk到docker私服待用(jdk已解压并重命名目录,目的是为了让镜像中的jdk路径清晰易记)
[root@localhost ~]# ls -l
总用量 231344
-rw-------. 1 root root 1231 4月 9 21:24 anaconda-ks.cfg
-rw-r--r--. 1 root root 9420658 4月 17 15:29 apache-tomcat-8.0.51.tar.gz
-rw-r--r--. 1 root root 22102842 4月 20 15:08 client.jar
-rw-r--r--. 1 root root 474 4月 19 09:04 Dockerfile_bak
-rw-r--r--. 1 root root 382 4月 20 14:29 DockerfileClient
-rw-r--r--. 1 root root 386 4月 23 11:19 DockerfileServer
drwxr-xr-x. 8 10 143 255 12月 13 2016 jdk
-rw-r--r--. 1 root root 183246769 4月 17 15:26 jdk-8u121-linux-x64.tar.gz
-rw-r--r--. 1 root root 22102433 4月 20 13:23 server.jar
drwxr-xr-x. 9 root root 160 4月 17 15:29 tomcat
[root@localhost ~]#
镜像所需文件
b.编写镜像制作用Dockerfile
[root@localhost ~]# vi DockerfileServer FROM centos
MAINTAINER changw.xiao@qq.com
COPY ./jdk /usr/local/jdk
COPY ./server.jar /root/server.jar ENV JAVA_HOME /usr/local/jdk
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH .:$JAVA_HOME/lib:$JRE_HOME/lib
ENV PATH $PATH:$JAVA_HOME/bin
ENV CATALINA_OPTS -Xms128m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=512M
ENTRYPOINT ["java", "-jar", "/root/server.jar", "--server.port=9999"]
DockerfileServer
[root@localhost ~]# vi DockerfileClient FROM centos
MAINTAINER changw.xiao@qq.com
COPY ./jdk /usr/local/jdk
COPY ./client.jar /root/client.jar ENV JAVA_HOME /usr/local/jdk
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH .:$JAVA_HOME/lib:$JRE_HOME/lib
ENV PATH $PATH:$JAVA_HOME/bin
ENV CATALINA_OPTS -Xms128m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=512M
ENTRYPOINT ["java","-jar","/root/client.jar","--server.port=9998"]
DockerfileClient
c.制作镜像并push到docker私库上
[root@localhost ~]# docker build -f DockerfileServer -t server:v2 --rm=true .
Sending build context to Docker daemon 622.6 MB
Step 1/10 : FROM centos
---> e934aafc2206
Step 2/10 : MAINTAINER changw.xiao@qq.com
---> Using cache
---> 72ab25d99688
Step 3/10 : COPY ./jdk /usr/local/jdk
---> Using cache
---> 527d6efcf1eb
Step 4/10 : COPY ./server.jar /root/server.jar
---> Using cache
---> 7d6ad5d000af
Step 5/10 : ENV JAVA_HOME /usr/local/jdk
---> Using cache
---> 99a7bfe20a2c
Step 6/10 : ENV JRE_HOME $JAVA_HOME/jre
---> Using cache
---> 65fa863798ba
Step 7/10 : ENV CLASSPATH .:$JAVA_HOME/lib:$JRE_HOME/lib
---> Using cache
---> 4884da8b0a46
Step 8/10 : ENV PATH $PATH:$JAVA_HOME/bin
---> Using cache
---> 342ae4b430ce
Step 9/10 : ENV CATALINA_OPTS -Xms128m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=512M
---> Using cache
---> 9f4f69bba1a8
Step 10/10 : ENTRYPOINT java -jar /root/server.jar --server.port=9999
---> Using cache
---> adba02d66112
Successfully built adba02d66112
[root@localhost ~]# docker tag server:v2 127.0.0.1:5000/server:v2
[root@localhost ~]# docker push 127.0.0.1:5000/server:v2
The push refers to a repository [127.0.0.1:5000/server]
d791b1f51432: Layer already exists
3d8fe6c21563: Layer already exists
43e653f84b79: Layer already exists
v2: digest: sha256:0cdc81e870c533efb7d60be2452fdfce2f0b0186d0568537e9a67d205262e7c6 size: 954
[root@localhost ~]# docker images |grep server
127.0.0.1:5000/server v1 adba02d66112 2 days ago 591 MB
127.0.0.1:5000/server v2 adba02d66112 2 days ago 591 MB
server v1 adba02d66112 2 days ago 591 MB
server v2 adba02d66112 2 days ago 591 MB
[root@localhost ~]#
server端镜像server:v2制作
[root@localhost ~]# docker build -f DockerfileClient -t client:v2 --rm=true .
Sending build context to Docker daemon 622.6 MB
Step 1/10 : FROM centos
---> e934aafc2206
Step 2/10 : MAINTAINER changw.xiao@qq.com
---> Using cache
---> 72ab25d99688
Step 3/10 : COPY ./jdk /usr/local/jdk
---> Using cache
---> 527d6efcf1eb
Step 4/10 : COPY ./client.jar /root/client.jar
---> Using cache
---> 397a279f72b9
Step 5/10 : ENV JAVA_HOME /usr/local/jdk
---> Using cache
---> e553d3e47099
Step 6/10 : ENV JRE_HOME $JAVA_HOME/jre
---> Using cache
---> 019ed6b62619
Step 7/10 : ENV CLASSPATH .:$JAVA_HOME/lib:$JRE_HOME/lib
---> Using cache
---> 9fa826201e2b
Step 8/10 : ENV PATH $PATH:$JAVA_HOME/bin
---> Using cache
---> 5922592036e7
Step 9/10 : ENV CATALINA_OPTS -Xms128m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=512M
---> Using cache
---> c563bf822200
Step 10/10 : ENTRYPOINT java -jar /root/client.jar --server.port=9998
---> Using cache
---> 6b9a0358f207
Successfully built 6b9a0358f207
[root@localhost ~]# docker tag client:v2 127.0.0.1:5000/client:v2
[root@localhost ~]# docker push 127.0.0.1:5000/client:v2
The push refers to a repository [127.0.0.1:5000/client]
8e2aa24bef0a: Layer already exists
3d8fe6c21563: Layer already exists
43e653f84b79: Layer already exists
v2: digest: sha256:a3d77ff85edb5272eb22d57b6bfd5ae6052b5903eaf7b09b256de2304207b905 size: 954
[root@localhost ~]# docker images |grep client
127.0.0.1:5000/client v1 6b9a0358f207 2 days ago 591 MB
127.0.0.1:5000/client v2 6b9a0358f207 2 days ago 591 MB
client v1 6b9a0358f207 2 days ago 591 MB
client v2 6b9a0358f207 2 days ago 591 MB
[root@localhost ~]#
client端镜像client:v2制作
3.server端rc配置与部署
3.1.创建server-rc.yaml配置文件
[root@k8s-master ~]# vi server-rc.yaml apiVersion: v1
kind: ReplicationController #指名类型为rc
metadata:
name: serverrc #rc 名字,创建后的pod名字为 serverrc-随机字符
spec:
replicas: 2 #指定副本数量,会一直维持这个数量的副本,如果某节点挂掉,又会立即构建新的来替代
template:
metadata:
labels:
app: server #app名字,相同的名字代表是同一个应用,service会按这个名字来做负载
spec:
containers:
- name: server
image: 192.168.100.6:5000/server:v1 #镜像源
ports:
- containerPort: 9999 #容器端口
3.2.启动server-rc
kubectl create -f /root/server-rc.yaml
3.3.确认启动是否成功
[root@k8s-master ~]# kubectl get pods --all-namespaces | grep serverrc
default serverrc-3qprz 1/1 Running 0 3h
default serverrc-8s274 1/1 Running 0 3h
注意:kubectl get pods默认只显示namespace为default下的,要显示全部 需加上 --all-namespances
3.4.查看详情或错误信息
[root@k8s-master ~]# kubectl describe pod serverrc-3qprz
Name: serverrc-3qprz
Namespace: default
Node: k8s-node1/192.168.100.5 #在哪个节点上部署的
Start Time: Mon, 23 Apr 2018 08:53:06 +0800
Labels: app=server
Status: Running
IP: 172.16.49.2 #容器内对应的ip信息(之前master上 etcdctl mk /atomic.io/network/config '{"Network":"172.16.0.0/16"}' 配置的ip范围内)
Controllers: ReplicationController/serverrc
Containers:
server:
Container ID: docker://00a7c4c588f2d7593bf0bbe6fd07350903f96e00f6e75278283e054580731a4f
Image: 192.168.100.6:5000/server:v1 #使用的镜像
Image ID: docker-pullable://192.168.100.6:5000/server@sha256:0cdc81e870c533efb7d60be2452fdfce2f0b0186d0568537e9a67d205262e7c6
Port: 9999/TCP #端口信息
State: Running
Started: Mon, 23 Apr 2018 08:53:06 +0800
Ready: True
Restart Count: 0
Volume Mounts: <none>
Environment Variables: <none>
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
No volumes.
QoS Class: BestEffort
Tolerations: <none>
No events.#如果没启动成功,这里会有错误信息,根据错误信息不断修改配置最终才会成功
[root@k8s-master ~]#
3.5.测试应用是否部署成功
[root@k8s-master ~]# curl 172.16.49.2:9999/test
{"content":"访问成功 1524458561072","status":"OK","errorCode":null,"errorMsg":null}
[root@k8s-master ~]#
[root@k8s-master ~]#
4.server端service配置与部署
4.1. 由于server端部署的节点可以为多个(本示例仅2个),怎么给client调用方提供唯一的请求地址呢?
传统部署方式一般会在前段做一个负载均衡,提供唯一的地址供调用方使用
但由于kubernets部署环境下,node会因各种情况重建,ip信息也会变化,传统方式已经不再满足需要
可喜的是kubernets提供了service,service就是将同一名字的app信息收集后在前端提供了cluster_ip(重建会变化)和服务名(重建不会变化),
功能和负载均衡一样,但node的销毁、重建不需要用户关心,调用方也只需要知道服务名即可,无需知道node节点任何信息
4.2. 创建server-svc.yaml文件
[root@k8s-master ~]# vi server-svc.yaml apiVersion: v1
kind: Service #指定种类为service
metadata:
name: serversvc #service 名字 提供给调用方使用,调用方无需知道ip 由dns解析服务名为cluster ip
labels:
app: server #rc的名字,service将同一名字的rc作为后端node进行负载
spec:
ports:
- port: 9001 #service暴露在cluster ip上的端口,clusterIP:port 是提供给集群内部客户访问service的入口
targetPort: 9999 #pod上的端口,从port和nodePort上到来的数据最终经过kube-proxy流入到后端pod的targetPort上进入容器,和rc中的containerPort一致
nodePort: 30001 #提供给集群外部客户访问service的入口
protocol: TCP
selector:
app: server
type: NodePort
4.3.创建service 并确认创建成功
kubectl create -f server-svc.yaml
[root@k8s-master ~]# kubectl get svc --all-namespaces
NAMESPACE NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default kubernetes 10.254.0.1 <none> 443/TCP 4h
default serversvc 10.254.77.154 <nodes> 9001:30001/TCP 4h
kube-system kube-dns 10.254.0.2 <none> 53/UDP,53/TCP 2d
[root@k8s-master ~]#
4.4.查看svc详情
[root@k8s-master ~]# kubectl describe svc serversvc
Name: serversvc #服务名,调用方就根据服务名来调用,因为随着svc重建,cluster_ip也会变更的
Namespace: default
Labels: app=server
Selector: app=server
Type: NodePort
IP: 10.254.77.154 #这个即为cluster_ip,相当于nginx做负载均衡时 nginx的ip地址
Port: <unset> 9001/TCP
NodePort: <unset> 30001/TCP
Endpoints: 172.16.20.2:9999,172.16.49.2:9999 #这个为service负载的节点ip和端口
Session Affinity: None
No events. #如果有错,这里会有很多行日志
[root@k8s-master ~]#
4.5.测试访问
[root@k8s-master ~]# curl 172.16.49.2:9999/test #直接通过nodeIP:port 访问成功
{"content":"访问成功 1524460721254","status":"OK","errorCode":null,"errorMsg":null}
[root@k8s-master ~]#
[root@k8s-master ~]# curl 172.16.20.2:9999/test #访问另一节点也成功
{"content":"访问成功 1524460728456","status":"OK","errorCode":null,"errorMsg":null}
[root@k8s-master ~]#
[root@k8s-master ~]# curl 10.254.77.154:9001/test #直接访问cluster_ip 没成功? 其实这里必须要到容器内部才能访问
curl: (7) Failed connect to 10.254.77.154:9001; 拒绝连接
[root@k8s-master ~]#
[root@k8s-master ~]# kubectl exec -it clientrc-8qk3z /bin/bash
[root@clientrc-8qk3z /]# curl 10.254.77.154:9001/test #进入容器内部访问cluster_ip 成功
{"content":"访问成功 1524460861212","status":"OK","errorCode":null,"errorMsg":null}
[root@clientrc-8qk3z /]#
[root@clientrc-8qk3z /]# exit
exit
[root@k8s-master ~]#
5.client端rc创建 并调用server端接口
5.1.client-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: clientrc
spec:
replicas: 2 #节点数量
template:
metadata:
labels:
app: client
spec:
containers:
- name: client
image: 192.168.100.6:5000/client:v1
ports:
- containerPort: 9998 #容器端口
env: #增加了环境变量,用来配置server端地址
- name: server_url #变量名
value: 'http://10.254.77.154:9001/' #变量值,由于我的dns没配置好,所以这里使用了server端的service cluster_ip,如果配置好了dns 这里应该为 value: 'http://serversvc:9001/'
5.2.创建client rc
kubectl create -f client-rc.yaml
5.3.确认启动状态
[root@k8s-master ~]# kubectl get pods --all-namespaces |grep client
default clientrc-8qk3z 1/1 Running 0 4h
default clientrc-hqs06 1/1 Running 0 4h
[root@k8s-master ~]#
[root@k8s-master ~]# kubectl get pods -l app=client -o json | grep podIP
"podIP": "172.16.60.3",
"podIP": "172.16.20.3",
[root@k8s-master ~]#
5.4.client两个节点访问
[root@k8s-master ~]# curl 172.16.60.3:9998/test
{"content":"访问成功 1524461788548","status":"OK","errorCode":null,"errorMsg":null}
[root@k8s-master ~]#
[root@k8s-master ~]# curl 172.16.20.3:9998/test
{"content":"访问成功 1524461800005","status":"OK","errorCode":null,"errorMsg":null}
[root@k8s-master ~]#
5.5.client端调用server端服务
在client端发送需要被拦截器拦截的请求,从而达到调用server端接口的目的
[root@k8s-master ~]# curl 172.16.60.3:9998/permission/test
{"content":"有权限,访问成功。运行参数为:http://10.254.77.154:9001/","status":"OK","errorCode":null,"errorMsg":null}
[root@k8s-master ~]# curl 172.16.60.3:9998/permission/test2
{"errorCode":"x00001","errorMsg":"无权限进行此操作","status":"ERROR"}[root@k8s-master ~]#
通过logs来查看各容器的输出log
kubectl logs serverrc-8s274
server端的日志为:
[root@k8s-master ~]# kubectl logs serverrc-8s274
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.1.RELEASE)
2018-04-23 00:53:11.716 INFO 1 --- [ main] c.p.p.s.PermissionServerApplication : Starting PermissionServerApplication v0.0.1-SNAPSHOT on serverrc-8s274 with PID 1 (/root/server.jar started by root in /)
2018-04-23 00:53:11.737 INFO 1 --- [ main] c.p.p.s.PermissionServerApplication : No active profile set, falling back to default profiles: default
2018-04-23 00:53:11.993 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@574caa3f: startup date [Mon Apr 23 00:53:11 UTC 2018]; root of context hierarchy
2018-04-23 00:53:16.425 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9999 (http)
2018-04-23 00:53:16.500 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-04-23 00:53:16.501 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.29
2018-04-23 00:53:16.569 INFO 1 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-04-23 00:53:16.864 INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-04-23 00:53:16.864 INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4932 ms
2018-04-23 00:53:17.107 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet statViewServlet mapped to [/druid/*]
2018-04-23 00:53:17.111 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-04-23 00:53:17.114 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-04-23 00:53:17.114 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-04-23 00:53:17.114 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-04-23 00:53:17.114 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-04-23 00:53:17.114 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webStatFilter' to urls: [/*]
2018-04-23 00:53:17.873 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-23 00:53:18.366 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@574caa3f: startup date [Mon Apr 23 00:53:11 UTC 2018]; root of context hierarchy
2018-04-23 00:53:18.542 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/permission/check]}" onto public com.phicomm.permission.lib.Result com.phicomm.permission.server.controller.PermissionController.permissionCheck(com.phicomm.permission.lib.PermissionParam)
2018-04-23 00:53:18.543 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/test]}" onto public com.phicomm.permission.lib.Result com.phicomm.permission.server.controller.PermissionController.test()
2018-04-23 00:53:18.556 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-04-23 00:53:18.557 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-04-23 00:53:18.610 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-23 00:53:18.610 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-23 00:53:19.002 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-04-23 00:53:19.003 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'druidDataSource' has been autodetected for JMX exposure
2018-04-23 00:53:19.018 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'druidDataSource': registering with JMX server as MBean [com.alibaba.druid.pool:name=druidDataSource,type=DruidDataSource]
2018-04-23 00:53:19.357 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9999 (http) with context path ''
2018-04-23 00:53:19.373 INFO 1 --- [ main] c.p.p.s.PermissionServerApplication : Started PermissionServerApplication in 8.942 seconds (JVM running for 12.022)
2018-04-23 00:55:59.133 INFO 1 --- [nio-9999-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-04-23 00:55:59.135 INFO 1 --- [nio-9999-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2018-04-23 00:55:59.157 INFO 1 --- [nio-9999-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 22 ms
????????{"appId":1,"requestURI":"/permission/test","userId":1}
????????{"appId":1,"requestURI":"/permission/test2","userId":1}
[root@k8s-master ~]#
server端其中一个node日志
[root@k8s-master ~]# kubectl logs clientrc-8qk3z
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.1.RELEASE)
2018-04-23 00:57:36.442 INFO 1 --- [ main] c.p.p.c.PermissionClientApplication : Starting PermissionClientApplication v0.0.1-SNAPSHOT on clientrc-8qk3z with PID 1 (/root/client.jar started by root in /)
2018-04-23 00:57:36.493 INFO 1 --- [ main] c.p.p.c.PermissionClientApplication : No active profile set, falling back to default profiles: default
2018-04-23 00:57:37.023 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6d1e7682: startup date [Mon Apr 23 00:57:36 UTC 2018]; root of context hierarchy
2018-04-23 00:57:41.401 WARN 1 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.phicomm.permission.client]' package. Please check your configuration.
2018-04-23 00:57:44.780 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9998 (http)
2018-04-23 00:57:44.850 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-04-23 00:57:44.851 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.29
2018-04-23 00:57:44.863 INFO 1 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-04-23 00:57:45.035 INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-04-23 00:57:45.042 INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 8176 ms
2018-04-23 00:57:45.312 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-04-23 00:57:45.316 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-04-23 00:57:45.316 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-04-23 00:57:45.316 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-04-23 00:57:45.316 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-04-23 00:57:45.872 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-23 00:57:46.873 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6d1e7682: startup date [Mon Apr 23 00:57:36 UTC 2018]; root of context hierarchy
2018-04-23 00:57:47.121 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/permission/test]}" onto public com.phicomm.permission.lib.Result com.phicomm.permission.client.controller.PermissionController.permissionTest()
2018-04-23 00:57:47.124 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/test]}" onto public com.phicomm.permission.lib.Result com.phicomm.permission.client.controller.PermissionController.test()
2018-04-23 00:57:47.128 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-04-23 00:57:47.128 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-04-23 00:57:47.186 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-23 00:57:47.186 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-04-23 00:57:48.796 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-04-23 00:57:48.799 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-04-23 00:57:48.870 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.alibaba.druid.pool:name=dataSource,type=DruidDataSource]
2018-04-23 00:57:49.367 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9998 (http) with context path ''
2018-04-23 00:57:49.378 INFO 1 --- [ main] c.p.p.c.PermissionClientApplication : Started PermissionClientApplication in 16.264 seconds (JVM running for 22.435)
2018-04-23 01:00:25.246 INFO 1 --- [nio-9998-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-04-23 01:00:25.246 INFO 1 --- [nio-9998-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2018-04-23 01:00:25.283 INFO 1 --- [nio-9998-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 37 ms
???????/permission/test
???????/permission/test2
cient端某一个node日志
至此,在kubernetes中应用间相互调用基本演示完毕(dns配置服务发现暂未成功)
kubernetes集群搭建(6):kubernetes基本使用演示的更多相关文章
- Kubernetes集群搭建之企业级环境中基于Harbor搭建自己的私有仓库
搭建背景 企业环境中使用Docker环境,一般出于安全考虑,业务使用的镜像一般不会从第三方公共仓库下载.那么就要引出今天的主题 企业级环境中基于Harbor搭建自己的安全认证仓库 介绍 名称:Harb ...
- kubernetes集群搭建(2):docker私有仓库
kubernetes集群搭建(1):环境准备 中各节点已经安装好了docker,请确认docker已启动并正常运行 1.通过命令启动私库 docker run -d -p 5000:5000 --pr ...
- Centos 7 kubernetes集群搭建
一.环境准备 Kubernetes支持在物理服务器或虚拟机中运行,本次使用虚拟机准备测试环境,硬件配置信息如表所示: IP地址 节点角色 CPU Memory Hostname 磁盘 192.168. ...
- Kubernetes集群搭建(详细)
kubernetes集群搭建(kubeadm方式) kubeadm是官方社区推出的一个用于快速部署kubernetes集群的工具.这个工具能通过两条指令完成一个kubernetes集群的部署: # 创 ...
- Kubernetes集群搭建过程中遇到的问题
1. 创建Nginx Pod过程中报如下错误: #kubectlcreate -f nginx-pod.yaml Error from server: error when creating &quo ...
- Kubernetes集群搭建之系统初始化配置篇
Kubernetes的几种部署方式 1. minikube Minikube是一个工具,可以在本地快速运行一个单点的Kubernetes,尝试Kubernetes或日常开发的用户使用.不能用于生产环境 ...
- Kubernetes集群搭建 ver1.20.5
目录 部署方式 1. 基础环境准备 1.1 基础初始化 1.2 安装docker 2. 部署harbor及haproxy高可用反向代理 2.1 镜像加速配置 2.2 高可用master可配置 3. 初 ...
- [云原生]Kubernetes - 集群搭建(第2章)
目录 一.前置知识点 二.kubeadm部署方式介绍 三.安装要求 四.最终目标 五.准备环境 六.环境初始化 6.1 设置系统主机名以及Hosts文件的相互解析 6.2 安装依赖文件(所有节点) 6 ...
- Docker 与 K8S学习笔记(二十三)—— Kubernetes集群搭建
小伙伴们,好久不见,这几个月实在太忙,所以一直没有更新,今天刚好有空,咱们继续k8s的学习,由于我们后面需要深入学习Pod的调度,所以我们原先使用MiniKube搭建的实验环境就不能满足我们的需求了, ...
- Ceph集群搭建及Kubernetes上实现动态存储(StorageClass)
集群准备 ceph集群配置说明 节点名称 IP地址 配置 作用 ceph-moni-0 10.10.3.150 centos7.5 4C,16G,200Disk 管理节点,监视器 monitor ...
随机推荐
- netstat 常用参数总结
netstat 是一个机器网络查看工具 . 网络连接有哪些参数?
- 解题(TakeBusChooseLine)
题目描述 从小明家所在公交站出发有n路公交到公司,现给出每路公交的停站数(不包括起点和终点),及每次停的时间(一路车在每个站停的时间相同)和发车的间隔,先假定每辆车同时在相对时间0分开始发车,且所有车 ...
- selenium之 chromedriver与chrome版本映射表(转载)
chromedriver版本 支持的Chrome版本 v2.34 v61-63 v2.33 v60-62 v2.32 v59-61 v2.31 v58-60 v2.30 v58-60 v2.29 v5 ...
- HDU 4780 Candy Factory(拆点费用流)
Problem Description A new candy factory opens in pku-town. The factory import M machines to produc ...
- Agile PLM 开发中AgileAPI类型对应控制台分类说明
1) 分类中的一级大类PLM后台管理的控制台中,每个分类中的一级大类都对应AgileAPI中一个类型 IServiceRequest对应产品服务请求,表为:psrIPrice对应价格,表为:pr ...
- vue修改端口号
vue修改端口号 默认端口号 修改端口号 重新启动项目 npm run dev
- Quartz.Net进阶之三:SimpleTrigger详述
以前都是将所有的内容放在一篇文章里,就会导致文章很长,对于学习的人来说,有时候这也是一个障碍.所以,以后我的写作习惯,我就会把我写的文章缩短,但是内容不会少,内容更集中.这样,学习起来也不会很累,很容 ...
- Step by Step Guide on Yanhua ACDP Clear BMW EGS ISN
Yanhua Mini ACDP authorize new function on BMW EGS ISN clearing.So here UOBDII want to share this st ...
- ABP框架系列之十四:(Background-Jobs-And-Workers-背景工作和工人)
Introduction ASP.NET Boilerplate provides background jobs and workers those are used to execute some ...
- mysql8.0 linux 安装
1.下载 mysql-8.0.15-linux-glibc2.12-x86_64.tar.xz 2.解压 tar -xvf mysql-8.0.15-linux-glibc2.12-x86_64.ta ...