[fix] change

This commit is contained in:
wujiawei
2024-05-29 10:46:07 +08:00
parent 2a0f58f0d1
commit 617e214bd9
307 changed files with 27 additions and 27 deletions

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>top.wu2020</groupId>
<artifactId>wu-smart-agent-network</artifactId>
<version>1.2.6-JDK17-SNAPSHOT</version>
</parent>
<artifactId>wu-lazy-cloud-heartbeat-start</artifactId>
<name>wu-smart-agent-network-heartbeat-start</name>
<description>wu-smart-agent-network-heartbeat-start</description>
<packaging>pom</packaging>
<modules>
<!-- 样例 -->
<module>wu-lazy-cloud-heartbeat-client-start</module>
<module>wu-lazy-cloud-heartbeat-server-start</module>
<module>wu-lazy-cloud-heartbeat-server-cluster-start</module>
</modules>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,22 @@
FROM registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-framework-parent:jdk-17.0.7-x64
MAINTAINER wujiawei <1207537021@qq.com>
RUN echo "Asia/Shanghai" > /etc/timezone
ENV APP_JAR_NAME=$APP_NAME \
JAVA_OPTS="-Xms512m -Xmx1024m -Djava.security.egd=file:/dev/./urandom" \
PARAMS=""
COPY target/*.jar /app.jar
ENTRYPOINT exec java -server $JAVA_OPTS -jar /app.jar $PARAMS

View File

@ -0,0 +1,16 @@
FROM alpine
MAINTAINER wujiawei <1207537021@qq.com>
RUN echo "Asia/Shanghai" > /etc/timezone
COPY target/wu-smart-agent-network-heartbeat-client /native-app
ENTRYPOINT ["/bin/sh" ,"-c", "exec ./native-app"]

View File

@ -0,0 +1,77 @@
```shell
mvn clean package -Pnative
```
## BUILD IMAGE
```shell
mvn spring-boot:build-image -Pnative
docker tag docker.io/library/wu-smart-agent-network-heartbeat-client-start:1.2.6-JDK17-SNAPSHOT registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-client-start:1.2.6-JDK17-NATIVE-SNAPSHOT
docker push registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-client-start:1.2.6-JDK17-NATIVE-SNAPSHOT
```
### 构建docker镜像
```shell
#docker login --username=1207537021@qq.com registry.cn-hangzhou.aliyuncs.com
mvn clean install
docker build -t registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-client-start:1.2.6-JDK17-SNAPSHOT .
docker push registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-client-start:1.2.6-JDK17-SNAPSHOT
```
### run
```shell
docker run -d -it --privileged --name client -p 6004:6004 registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-client-start:1.2.6-JDK17-NATIVE-SNAPSHOT
```
```yaml
# 只在 worker 节点执行
# 替换 x.x.x.x 为 master 节点的内网 IP
export MASTER_IP=124.222.48.62
# 替换 apiserver.demo 为初始化 master 节点时所使用的 APISERVER_NAME
export APISERVER_NAME=apiserver.demo
echo "${MASTER_IP} ${APISERVER_NAME}" >> /etc/hosts
# 替换为 master 节点上 kubeadm token create 命令的输出
kubeadm join apiserver.demo:6443 --token 2wtcsg.0af26p9wzfgvyf5a --discovery-token-ca-cert-hash sha256:92f267bdf14c4cd31d3d767d6ff6a6fbdbb83357720d73b91b42d408d5e4a5e7
```
```shell
# 创建虚拟网卡
cat > /etc/sysconfig/network-scripts/ifcfg-eth0:1 <<EOF
BOOTPROTO=static
DEVICE=eth0:1
IPADDR=k8s-node1 # 你的公网ip
PREFIX=32
TYPE=Ethernet
USERCTL=no
ONBOOT=yes
EOF
# 重启网络
systemctl restart network
```
```RUN
docker run -d -it --name client registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-client-start:1.2.6-JDK17-SNAPSHOT
http://127.0.0.1:18080
```

View File

@ -0,0 +1,50 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations: {}
labels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: wu-smart-agent-network-heartbeat-client-start
name: wu-smart-agent-network-heartbeat-client-start
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: wu-smart-agent-network-heartbeat-client-start
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: wu-smart-agent-network-heartbeat-client-start
spec:
containers:
- env:
- name: spring.lazy.netty.client.inet-host
value: wu-lazy-cloud-heartbeat-server.default
- name: spring.lazy.netty.client.client-id
value: wu-smart-agent-network-heartbeat-client-start
image: >-
registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-client-start:1.2.6-JDK17-NATIVE-SNAPSHOT
imagePullPolicy: Always
name: wu-smart-agent-network-heartbeat-client-start
resources: {}
securityContext:
privileged: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-heartbeat-start</artifactId>
<version>1.2.6-JDK17-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>wu-lazy-cloud-heartbeat-client-start</artifactId>
<description>云下心跳客户端</description>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-heartbeat-client</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.23</version>
<configuration>
<!-- imageName用于设置生成的二进制文件名称 -->
<imageName>${project.artifactId}</imageName>
<!-- mainClass用于指定main方法类路径 -->
<mainClass>org.framework.smart.agent.network.heartbeat.client.LazyCloudHeartbeatClientStart</mainClass>
<buildArgs>
--no-fallback
</buildArgs>
</configuration>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,17 @@
package org.framework.smart.agent.network.heartbeat.client;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.wu.framework.lazy.orm.core.stereotype.LazyScan;
/**
* 云上云下-云下心跳服务器
*/
@LazyScan(scanBasePackages = "org.framework.smart.agent.network.heartbeat.client.infrastructure.entity")
@SpringBootApplication
public class LazyCloudHeartbeatClientStart {
public static void main(String[] args) {
SpringApplication.run(LazyCloudHeartbeatClientStart.class,args);
}
}

View File

@ -0,0 +1,24 @@
spring:
lazy:
netty:
client:
inet-host: 127.0.0.1
inet-port: 7001
inet-path: wu-smart-agent-network-heartbeat-server
# inet-host: 124.222.48.62 # 服务端地址
# inet-port: 30676 #服务端端口
# inet-path: wu-smart-agent-network-heartbeat-server
client-id: wujiawei # 客户端ID
# client-id: temp_id # 客户端ID
data:
redis:
host: 192.168.17.221
port: 30553
password: wujiawei
database: 2
datasource:
url: jdbc:h2:~/client_heartbeat;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_UPPER=true;MODE=MySQL;CASE_INSENSITIVE_IDENTIFIERS=TRUE
username: sa
driver-class-name: org.h2.Driver

View File

@ -0,0 +1,5 @@
spring:
datasource:
url: jdbc:h2:~/client_heartbeat
username: sa
driver-class-name: org.h2.Driver

View File

@ -0,0 +1,19 @@
server:
port: 6004
spring:
profiles:
active: dev
lazy:
enable-auto-schema: true
---
## 客户端设置
#spring:
# lazy:
# netty:
# client:
# client-id: 1024
# inet-host: 127.0.0.1
# inet-port: 7101

View File

@ -0,0 +1,22 @@
FROM registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-framework-parent:jdk-17.0.7-x64
MAINTAINER wujiawei <1207537021@qq.com>
RUN echo "Asia/Shanghai" > /etc/timezone
ENV APP_JAR_NAME=$APP_NAME \
JAVA_OPTS="-Xms512m -Xmx1024m -Djava.security.egd=file:/dev/./urandom" \
PARAMS=""
COPY target/*.jar /app.jar
ENTRYPOINT exec java -server $JAVA_OPTS -jar /app.jar $PARAMS

View File

@ -0,0 +1,38 @@
# DOCKER JDK IMAGE
### 打包可执行文件
```shell
mvn clean package -Pnative
```
## BUILD IMAGE
```shell
mvn spring-boot:build-image -Pnative
docker tag docker.io/library/wu-smart-agent-network-heartbeat-server-cluster-start:1.2.6-JDK17-SNAPSHOT registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-cluster-start:1.2.6-JDK17-NATIVE-SNAPSHOT
docker push registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-cluster-start:1.2.6-JDK17-NATIVE-SNAPSHOT
```
```shell
#docker login --username=1207537021@qq.com registry.cn-hangzhou.aliyuncs.com
mvn clean install
docker build -t registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-cluster-start:1.2.6-JDK17-SNAPSHOT .
docker push registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-cluster-start:1.2.6-JDK17-SNAPSHOT
```
```RUN
docker run -d -it -p 18080:18080 --name wu-smart-agent-network-heartbeat-server-cluster-start registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-cluster-start:1.2.6-JDK17-SNAPSHOT
http://127.0.0.1:18080/swagger-ui/index.html
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

View File

@ -0,0 +1,161 @@
# 记录一次k8s pod之间ip无法访问问题排查与定位
![img.png](../../k8s-node-pod-network-k8snodepod.png)
### 问题展现现象
node之间通信正常
部分node上的pod无法通信
### 排查有问题node
#### 使用启动网络测试工具
##### 环境准备
docker
数据库mysql
##### 使用有状态副本集合
```bash
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations:
k8s.kuboard.cn/displayName: 有状态内网穿透集群
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
name: network-server-cluster-start
namespace: default
spec:
podManagementPolicy: OrderedReady
replicas: 10
revisionHistoryLimit: 10
selector:
matchLabels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
serviceName: network-server-cluster-start
template:
metadata:
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
topologyKey: kubernetes.io/hostname
containers:
- env:
- name: spring.datasource.url
value: >-
jdbc:mysql://mysql-host:mysql-port/wu_lazy_cloud_netty_server_cluster?allowMultiQueries=true&useUnicode=true&autoReconnect=true&useAffectedRows=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&databaseTerm=SCHEMA
- name: JAVA_OPTS
value: '-Xms64m -Xmx128m'
- name: spring.datasource.username
value: root
- name: spring.datasource.password
value: laihui
- name: spring.lazy.netty.server.node-id
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: spring.lazy.netty.server.node-port
value: '7101'
envFrom:
- configMapRef:
name: wu-smart-agent-network-heartbeat-server-cluster-start-conf
image: >-
registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-cluster-start:1.2.6-JDK17-NATIVE-SNAPSHOT
imagePullPolicy: Always
name: network-server-cluster-start
ports:
- containerPort: 7101
hostPort: 7101
name: tcp7101
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
updateStrategy:
rollingUpdate:
partition: 0
type: RollingUpdate
---
apiVersion: v1
kind: Service
metadata:
annotations: {}
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
name: network-server-cluster-start
namespace: default
spec:
ipFamilyPolicy: SingleStack
ports:
- name: 6eqe4d
port: 7101
protocol: TCP
targetPort: 7101
selector:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
sessionAffinity: None
type: ClusterIP
---
apiVersion: v1
data:
spring.lazy.netty.server.node-host: '${HOSTNAME}.network-server-cluster-start.default.svc.cluster.local'
kind: ConfigMap
metadata:
name: wu-smart-agent-network-heartbeat-server-cluster-start-conf
namespace: default
---
apiVersion: v1
kind: Service
metadata:
annotations: {}
name: network-server-cluster-start-web
namespace: default
spec:
ports:
- name: sjmxma
nodePort: 33201
port: 6101
protocol: TCP
targetPort: 6101
selector:
k8s.kuboard.cn/name: network-server-cluster-start
sessionAffinity: None
type: NodePort
```
##### 配置参数需要调整的
::: tip 其中 mysql-host、mysql-port 替换成你本地具体数据库
::: 注意副本数量调整为你可以调度的节点数据量
##### 打开页面 http://集群IP:33201/netty-server-ui/index.html (默认账号/密码admin/admin
##### 初始化菜单、添加角色、用户授权角色
##### 打开集群管理页面(查看异常状态节点)
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/88a473b88ee24e86b4a4915c98652636.png)

View File

@ -0,0 +1,129 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations:
k8s.kuboard.cn/displayName: 有状态内网穿透集群
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
name: network-server-cluster-start
namespace: default
spec:
podManagementPolicy: OrderedReady
replicas: 10
revisionHistoryLimit: 10
selector:
matchLabels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
serviceName: network-server-cluster-start
template:
metadata:
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
topologyKey: kubernetes.io/hostname
containers:
- env:
- name: spring.datasource.url
value: >-
jdbc:mysql://cloud-mysql.middleground-management:3306/wu_lazy_cloud_netty_server_cluster?allowMultiQueries=true&useUnicode=true&autoReconnect=true&useAffectedRows=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&databaseTerm=SCHEMA
- name: JAVA_OPTS
value: '-Xms64m -Xmx128m'
- name: spring.datasource.username
value: root
- name: spring.datasource.password
value: laihui
- name: spring.lazy.netty.server.node-id
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: spring.lazy.netty.server.node-port
value: '7101'
envFrom:
- configMapRef:
name: wu-smart-agent-network-heartbeat-server-cluster-start-conf
image: >-
registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-cluster-start:1.2.6-JDK17-NATIVE-SNAPSHOT
imagePullPolicy: Always
name: network-server-cluster-start
ports:
- containerPort: 7101
hostPort: 7101
name: tcp7101
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
updateStrategy:
rollingUpdate:
partition: 0
type: RollingUpdate
---
apiVersion: v1
kind: Service
metadata:
annotations: {}
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
name: network-server-cluster-start
namespace: default
spec:
ipFamilyPolicy: SingleStack
ports:
- name: 6eqe4d
port: 7101
protocol: TCP
targetPort: 7101
selector:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: network-server-cluster-start
sessionAffinity: None
type: ClusterIP
---
apiVersion: v1
data:
spring.lazy.netty.server.node-host: '${HOSTNAME}.network-server-cluster-start.default.svc.cluster.local'
kind: ConfigMap
metadata:
name: wu-smart-agent-network-heartbeat-server-cluster-start-conf
namespace: default
---
apiVersion: v1
kind: Service
metadata:
annotations: {}
name: network-server-cluster-start-web
namespace: default
spec:
ports:
- name: sjmxma
nodePort: 33201
port: 6101
protocol: TCP
targetPort: 6101
selector:
k8s.kuboard.cn/name: network-server-cluster-start
sessionAffinity: None
type: NodePort

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-heartbeat-start</artifactId>
<version>1.2.6-JDK17-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>wu-lazy-cloud-heartbeat-server-cluster-start</artifactId>
<description>云上心跳服务端</description>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-heartbeat-server-cluster</artifactId>
</dependency>
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-smart-acw-client</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.23</version>
<configuration>
<!-- imageName用于设置生成的二进制文件名称 -->
<imageName>${project.artifactId}</imageName>
<!-- mainClass用于指定main方法类路径 -->
<mainClass>org.framework.smart.agent.network.heartbeat.server.cluster.start.LazyCloudHeartbeatServerClusterStart</mainClass>
<buildArgs>
--no-fallback
</buildArgs>
</configuration>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,16 @@
package org.framework.smart.agent.network.heartbeat.server.cluster.start;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* 云上云下-云上心跳服务器
*/
@Slf4j
@SpringBootApplication
public class LazyCloudHeartbeatServerClusterStart {
public static void main(String[] args) {
SpringApplication.run(LazyCloudHeartbeatServerClusterStart.class,args);
}
}

View File

@ -0,0 +1,6 @@
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/wu_lazy_cloud_netty_server_cluster?allowMultiQueries=true&useUnicode=true&autoReconnect=true&useAffectedRows=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&databaseTerm=SCHEMA
username: root
password: wujiawei
driver-class-name: com.mysql.cj.jdbc.Driver

View File

@ -0,0 +1,8 @@
spring:
datasource:
url: jdbc:mysql://${MAIN_DB_HOST}/wu_lazy_cloud_netty_server_cluster?allowMultiQueries=true&useUnicode=true&autoReconnect=true&useAffectedRows=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&databaseTerm=SCHEMA
username: root
password: wujiawei
driver-class-name: com.mysql.cj.jdbc.Driver
main:
allow-bean-definition-overriding: true

View File

@ -0,0 +1,25 @@
server:
port: 6101
spring:
profiles:
active: dev
lazy:
enable-auto-schema: true
authorization:
un-check-api-path:
- /v1/api/lazy/netty/server/properties/**
- /v1/api/project/dataSource/**
---
spring:
lazy:
netty:
server:
mode: cluster # 模式:集群、单机版
node-id: default #当前服务ID
node-host: 127.0.0.1 # 当前节点host
node-port: 7101 # 当前节点端口

View File

@ -0,0 +1,22 @@
FROM registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-framework-parent:jdk-17.0.7-x64
MAINTAINER wujiawei <1207537021@qq.com>
RUN echo "Asia/Shanghai" > /etc/timezone
ENV APP_JAR_NAME=$APP_NAME \
JAVA_OPTS="-Xms512m -Xmx1024m -Djava.security.egd=file:/dev/./urandom" \
PARAMS=""
COPY target/*.jar /app.jar
ENTRYPOINT exec java -server $JAVA_OPTS -jar /app.jar $PARAMS

View File

@ -0,0 +1,39 @@
# DOCKER JDK IMAGE
### 打包可执行文件
```shell
mvn clean package -Pnative
```
## BUILD IMAGE
```shell
mvn spring-boot:build-image -Pnative
docker tag docker.io/library/wu-smart-agent-network-heartbeat-server-start:1.2.6-JDK17-SNAPSHOT registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-start:1.2.6-JDK17-NATIVE-SNAPSHOT
docker push registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-start:1.2.6-JDK17-NATIVE-SNAPSHOT
```
```shell
#docker login --username=1207537021@qq.com registry.cn-hangzhou.aliyuncs.com
mvn clean install
docker build -t registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-start:1.2.6-JDK17-SNAPSHOT .
docker push registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-start:1.2.6-JDK17-SNAPSHOT
```
```RUN
docker run -d -it -p 18080:18080 --name wu-smart-agent-network-heartbeat-server-start registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-start:1.2.6-JDK17-SNAPSHOT
http://127.0.0.1:18080/swagger-ui/index.html
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

View File

@ -0,0 +1,89 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations: {}
labels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: wu-lazy-cloud-heartbeat-server
name: wu-lazy-cloud-heartbeat-server
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: wu-lazy-cloud-heartbeat-server
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: wu-lazy-cloud-heartbeat-server
spec:
containers:
- env:
- name: spring.datasource.url
value: >-
jdbc:mysql://cloud-mysql:3306/wu_lazy_cloud_netty_server?allowMultiQueries=true&useUnicode=true&autoReconnect=true&useAffectedRows=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&databaseTerm=SCHEMA
- name: JAVA_OPTS
value: '-Xms64m -Xmx128m'
- name: spring.datasource.username
value: root
- name: spring.datasource.password
value: wujiawei
- name: spring.datasource.driver-class-name
value: com.mysql.cj.jdbc.Driver
image: >-
registry.cn-hangzhou.aliyuncs.com/wu-lazy/wu-smart-agent-network-heartbeat-server-start:1.2.6-JDK17-NATIVE-SNAPSHOT
imagePullPolicy: Always
name: wu-lazy-cloud-heartbeat-server
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
annotations: {}
labels:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: wu-smart-agent-network-heartbeat-server
name: wu-smart-agent-network-heartbeat-server
namespace: default
spec:
ports:
- name: pecjjh
nodePort: 30676
port: 7001
protocol: TCP
targetPort: 7001
- name: z4bg3n
nodePort: 30273
port: 30273
protocol: TCP
targetPort: 30273
- name: wfcigf
nodePort: 30576
port: 6001
protocol: TCP
targetPort: 6001
selector:
k8s.kuboard.cn/layer: gateway
k8s.kuboard.cn/name: wu-smart-agent-network-heartbeat-server
sessionAffinity: None
type: NodePort

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-heartbeat-start</artifactId>
<version>1.2.6-JDK17-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>wu-lazy-cloud-heartbeat-server-start</artifactId>
<description>云上心跳服务端</description>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-lazy-cloud-heartbeat-server</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.23</version>
<configuration>
<!-- imageName用于设置生成的二进制文件名称 -->
<imageName>${project.artifactId}</imageName>
<!-- mainClass用于指定main方法类路径 -->
<mainClass>org.framework.smart.agent.network.heartbeat.server.LazyCloudHeartbeatServerStart</mainClass>
<buildArgs>
--no-fallback
</buildArgs>
</configuration>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,16 @@
package org.framework.smart.agent.network.heartbeat.server;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* 云上云下-云上心跳服务器
*/
@Slf4j
@SpringBootApplication
public class LazyCloudHeartbeatServerStart {
public static void main(String[] args) {
SpringApplication.run(LazyCloudHeartbeatServerStart.class,args);
}
}

View File

@ -0,0 +1,15 @@
---
## h2 配置
spring:
datasource:
url: jdbc:h2:./wu_lazy_cloud_netty_server:wu_lazy_cloud_netty_server;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_UPPER=true;MODE=MySQL;CASE_INSENSITIVE_IDENTIFIERS=TRUE
username: sa
driver-class-name: org.h2.Driver
---
#spring:
# datasource:
# url: jdbc:mysql://127.0.0.1:3306/wu_lazy_cloud_netty_server?allowMultiQueries=true&useUnicode=true&autoReconnect=true&useAffectedRows=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&databaseTerm=SCHEMA
# username: root
# password: wujiawei
# driver-class-name: com.mysql.cj.jdbc.Driver

View File

@ -0,0 +1,8 @@
spring:
datasource:
url: jdbc:mysql://${MAIN_DB_HOST}/wu_lazy_cloud_netty_server?allowMultiQueries=true&useUnicode=true&autoReconnect=true&useAffectedRows=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&databaseTerm=SCHEMA
username: root
password: wujiawei
driver-class-name: com.mysql.cj.jdbc.Driver
main:
allow-bean-definition-overriding: true

View File

@ -0,0 +1,35 @@
server:
port: 6001
spring:
profiles:
active: dev
lazy:
enable-auto-schema: true
netty:
server:
mode: standalone # 模式:集群、单机版
node-id: default #当前服务ID
node-host: 127.0.0.1 # 当前节点host
node-port: 7001 # 当前节点端口
ddl-configure:
ddl-auto: create
---
# 添加api 过滤
spring:
lazy:
authorization:
un-check-api-path:
- /acw-client/java/api/**
- /v1/online/**
- /v1/api/**
---
# 服务端与客户端集成
#spring:
# lazy:
# netty:
# client:
# inet-host: ${spring.lazy.netty.server.node-host}
# inet-port: ${spring.lazy.netty.server.node-port}
# client-id: standalone