Compare commits
70 Commits
v2.0.4
...
v3.9.6-nat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
521ac4d3f6 | ||
|
|
095245b421 | ||
|
|
af390af277 | ||
|
|
3e55783c5f | ||
|
|
b2fba3cac7 | ||
|
|
26f6647a4d | ||
|
|
84b6f139b9 | ||
|
|
5e865ab425 | ||
|
|
6b4c1b6676 | ||
|
|
ff654bb606 | ||
|
|
8eaa9fd792 | ||
|
|
c7af2dd52c | ||
|
|
373b497d37 | ||
|
|
6d1dc22670 | ||
|
|
52e4616bb3 | ||
|
|
79fba8746f | ||
|
|
80122ebe57 | ||
|
|
148672031f | ||
|
|
fdcc48178f | ||
|
|
1f9029baf1 | ||
|
|
df57e63c3e | ||
|
|
d6b67b428b | ||
|
|
f3eeaf48fd | ||
|
|
46f1b7ca22 | ||
|
|
c7d1bedf79 | ||
|
|
8dc0e1f9d7 | ||
|
|
5cb44e596c | ||
|
|
2f9ff5f9c9 | ||
|
|
cfbd38a09d | ||
|
|
93a1aa6465 | ||
|
|
6adc7bc789 | ||
|
|
899beb46ff | ||
|
|
d78dd16a8d | ||
|
|
cefc01220d | ||
|
|
a9a18c13b6 | ||
|
|
b0e021e0a0 | ||
|
|
58ecbced00 | ||
|
|
d0457dc910 | ||
|
|
8359c9c4dd | ||
|
|
ac8aacbd63 | ||
|
|
969002ab42 | ||
|
|
1e1f1526fc | ||
|
|
e381ac36e1 | ||
|
|
009f6ae5b7 | ||
|
|
ea2d7d76af | ||
|
|
5dbb383d07 | ||
|
|
699d6cc5c3 | ||
|
|
499c3058fe | ||
|
|
057cb5de38 | ||
|
|
bf1f52ad54 | ||
|
|
1696261450 | ||
|
|
5ca35df955 | ||
|
|
21bc585376 | ||
|
|
00684cebf2 | ||
|
|
a29c9c1085 | ||
|
|
838e811619 | ||
|
|
e02119c1f3 | ||
|
|
dfe90c96b2 | ||
|
|
785488505a | ||
|
|
078fdf969e | ||
|
|
e428f7a05c | ||
|
|
d694d0f7ab | ||
|
|
2cc70877a0 | ||
|
|
44c6fab1f4 | ||
|
|
cf924d1ee7 | ||
|
|
d97d39e5c4 | ||
|
|
55f57f9085 | ||
|
|
0389942e4f | ||
|
|
bc853144b8 | ||
|
|
f5b1de075f |
@@ -21,12 +21,45 @@ env:
|
|||||||
# 构建 Job
|
# 构建 Job
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: host
|
runs-on: ubuntu-node22 # 如果host构建 :linux_amd64
|
||||||
|
# container:
|
||||||
|
# image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/ghcr.io/catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Print system info 1
|
||||||
|
run: echo " The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||||
|
- name: Print system info 2
|
||||||
|
run: echo " This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||||
|
- name: Print system info 3
|
||||||
|
run: echo " The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
- name: Print env
|
||||||
|
run: env
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
apt-get update &&
|
||||||
|
apt-get install -y gettext &&
|
||||||
|
apt-get install -y maven &&
|
||||||
|
apt-get install -y sudo &&
|
||||||
|
apt-get install -y iptables
|
||||||
|
- name: Set up Docker
|
||||||
|
uses: http://139.9.216.111:3000/bamanker/setup-docker-action@v4
|
||||||
|
- name: Generate maven config
|
||||||
|
uses: http://139.9.216.111:3000/bamanker/maven-settings-action@v3.1.0
|
||||||
|
with:
|
||||||
|
mirrors: '[{"id": "alimaven", "name": "aliyun maven", "mirrorOf": "central", "url": "http://maven.aliyun.com/nexus/content/groups/public/"}]'
|
||||||
|
|
||||||
|
# - uses: http://localhost:3000/bamanker/setup-node@v6
|
||||||
|
# with:
|
||||||
|
# node-version: 24
|
||||||
|
# cache: 'npm'
|
||||||
|
# - run: node -v
|
||||||
# 下载仓库源码,依赖node环境,因此构建服务器本地需要下载安装node并设置环境变量
|
# 下载仓库源码,依赖node环境,因此构建服务器本地需要下载安装node并设置环境变量
|
||||||
|
|
||||||
|
# - name: Set up Docker Buildx
|
||||||
|
# uses: http://139.9.216.111:3000/bamanker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Checkout repository code
|
- name: Checkout repository code
|
||||||
#使用自定义仓库action
|
#使用自定义仓库action
|
||||||
uses: http://139.9.216.111:3000/bamanker/checkout@v6
|
uses: http://139.9.216.111:3000/bamanker/checkout@v4
|
||||||
|
|
||||||
# 获取 TAG 并设置为环境变量
|
# 获取 TAG 并设置为环境变量
|
||||||
- name: Get version
|
- name: Get version
|
||||||
@@ -39,17 +72,29 @@ jobs:
|
|||||||
- name: Set envVar
|
- name: Set envVar
|
||||||
id: set_envar
|
id: set_envar
|
||||||
run: |
|
run: |
|
||||||
echo "The app version is $APP_TAG" && echo "tag=$APP_TAG" >> $GITHUB_OUTPUT
|
echo "The app version is $APP_TAG" && echo "tag=$APP_TAG" >> $GITHUB_OUTPUT &&
|
||||||
|
echo "now workspace: ${{ github.workspace }}" &&
|
||||||
|
pwd &&
|
||||||
|
docker version &&
|
||||||
|
docker --help
|
||||||
|
|
||||||
# 为其他配置文件注入环境变量
|
# 为其他配置文件注入环境变量
|
||||||
- name: Inject envVar
|
- name: Inject envVar
|
||||||
run: |
|
run: |
|
||||||
envsubst < ./deployment-temp.yml > ./deployment.yml
|
envsubst < ./deployment-temp.yml > ./deployment.yml &&
|
||||||
|
cat ./deployment.yml
|
||||||
|
|
||||||
# 构建java项目
|
# 构建java项目
|
||||||
|
- name: Set up Java
|
||||||
|
uses: http://139.9.216.111:3000/bamanker/setup-graalvm@v1
|
||||||
|
with:
|
||||||
|
distribution: 'graalvm'
|
||||||
|
java-version: '25.0.1'
|
||||||
|
cache: 'maven'
|
||||||
|
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
#使用maven绝对路径执行打包命令
|
#使用maven绝对路径执行打包命令
|
||||||
run: /usr/local/maven/bin/mvn clean package -DskipTests -Pprod
|
run: mvn clean native:compile -DskipTests -Pnative
|
||||||
|
|
||||||
# 登录镜像仓库,方便后续上传镜像
|
# 登录镜像仓库,方便后续上传镜像
|
||||||
- name: Login to Docker Registry
|
- name: Login to Docker Registry
|
||||||
@@ -66,36 +111,36 @@ jobs:
|
|||||||
# run: |
|
# run: |
|
||||||
# echo "datetime=$(date '+%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
|
# echo "datetime=$(date '+%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
# 构建并上传镜像
|
# 构建并上传镜像 TODO 直接用docker命令操作
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: http://139.9.216.111:3000/bamanker/build-push-action@v6 # 获取上一步截取到的版本号,既 1.0.0
|
# uses: http://139.9.216.111:3000/bamanker/build-push-action@v4 # 获取上一步截取到的版本号,既 1.0.0
|
||||||
#只能这样接收
|
#只能这样接收
|
||||||
env:
|
env:
|
||||||
TAG: ${{ steps.set_envar.outputs.tag }}
|
TAG: ${{ steps.set_envar.outputs.tag }}
|
||||||
with:
|
run: |
|
||||||
context: .
|
docker build &&
|
||||||
platforms: linux/amd64
|
docker image ls
|
||||||
file: Dockerfile
|
# ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} --push.
|
||||||
push: true
|
# uses: http://139.9.216.111:3000/bamanker/docker-build-push@v5
|
||||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
# with:
|
||||||
|
# context: .
|
||||||
|
## platforms: linux/amd64
|
||||||
|
# file: Dockerfile
|
||||||
|
# push: true
|
||||||
|
# tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
||||||
|
|
||||||
#发布到 k8s
|
#发布到 k8s
|
||||||
- name: k8s Check and Apply New Deployment
|
- name: Generate kubeconfig
|
||||||
uses: http://139.9.216.111:3000/bamanker/steevchen-kubectl@master
|
uses: http://139.9.216.111:3000/bamanker/kubectl-action@v1.4.0
|
||||||
with:
|
with:
|
||||||
config: ${{ secrets.KUBE_CONFIG }}
|
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
|
||||||
command: apply -f ./deployment.yml
|
- name: Deploy k8s
|
||||||
|
run: kubectl apply -f ./deployment.yml
|
||||||
# command: apply -f http://139.9.216.111:3000/bamanker/myk3sTest/raw/branch/master/.deploy/deployment-temp.yml
|
# command: apply -f http://139.9.216.111:3000/bamanker/myk3sTest/raw/branch/master/.deploy/deployment-temp.yml
|
||||||
- name: k8s Check Pods Health
|
- name: k8s Check Pods Health
|
||||||
uses: http://139.9.216.111:3000/bamanker/steevchen-kubectl@master
|
run: kubectl get pod -n default -l app=${{ env.APP_NAME }}
|
||||||
with:
|
|
||||||
config: ${{ secrets.KUBE_CONFIG }}
|
|
||||||
command: get pod -n default -l app=${{ env.APP_NAME }}
|
|
||||||
|
|
||||||
- name: k8s Update Deployment
|
- name: k8s Update Deployment
|
||||||
uses: http://139.9.216.111:3000/bamanker/steevchen-kubectl@master
|
run: kubectl rollout restart deployment ${{ env.APP_NAME }}
|
||||||
env:
|
|
||||||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
|
||||||
with:
|
|
||||||
command: rollout restart deployment ${{ env.APP_NAME }}-${{ gitea.ref_name }}
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# 基于 java25 构建
|
# 基于 java25 构建
|
||||||
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/openjdk:25-jdk-slim
|
FROM ubuntu:jammy
|
||||||
# 基于构建上下文 . 进行COPY 文件到 /root目录下
|
# 基于构建上下文 . 进行COPY 文件到 /root目录下
|
||||||
COPY target/myk3sTest.jar /root/myk3sTest/
|
COPY target/myk3sTest /root/myk3sTest/
|
||||||
EXPOSE 9090
|
EXPOSE 9090
|
||||||
# 容器启动执行的命令
|
# 容器启动执行的命令
|
||||||
CMD java -jar -Xms20m -Xmx20m -Dspring.profiles.active=test /root/myk3sTest/myk3sTest.jar
|
CMD /root/myk3sTest/myk3sTest -XX:StartFlightRecording='filename=recording.jfr,dumponexit=true,duration=10s'
|
||||||
|
|||||||
@@ -29,14 +29,15 @@ spec:
|
|||||||
- image: $REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$APP_TAG
|
- image: $REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$APP_TAG
|
||||||
name: $APP_NAME
|
name: $APP_NAME
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
readinessProbe:
|
livenessProbe: # 存活探针:失败意味着应用彻底挂了,需要重启来恢复
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /actuator/health
|
path: /test
|
||||||
port: 9090
|
port: 9090
|
||||||
initialDelaySeconds: 1
|
initialDelaySeconds: 10 # 延迟xx秒开始执行
|
||||||
timeoutSeconds: 10
|
periodSeconds: 15 # 每隔15秒执行一次
|
||||||
failureThreshold: 30
|
timeoutSeconds: 10 # 10秒未返回结果则超时
|
||||||
successThreshold: 5
|
failureThreshold: 10 # 探测失败后的重试次数,当达到这个次数后就判定结果为失败
|
||||||
|
# successThreshold: 5
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 9090
|
- containerPort: 9090
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
@@ -56,6 +57,6 @@ spec:
|
|||||||
- name: http
|
- name: http
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
port: 9090
|
port: 9090
|
||||||
nodePort: 9090
|
nodePort: 30909
|
||||||
selector:
|
selector:
|
||||||
app: $APP_NAME
|
app: $APP_NAME
|
||||||
|
|||||||
33
pom.xml
33
pom.xml
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<groupId>com.bamanker</groupId>
|
<groupId>com.bamanker</groupId>
|
||||||
<artifactId>myk3sTest</artifactId>
|
<artifactId>myk3sTest</artifactId>
|
||||||
<version>v1.1.9</version>
|
<version>v3.1-native</version>
|
||||||
<name>myk3sTest</name>
|
<name>myk3sTest</name>
|
||||||
<description>myk3sTest</description>
|
<description>myk3sTest</description>
|
||||||
<url/>
|
<url/>
|
||||||
@@ -70,11 +70,40 @@
|
|||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.graalvm.buildtools</groupId>
|
||||||
|
<artifactId>native-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>com.bamanker.myk3stest.Myk3sTestApplication</mainClass>
|
||||||
|
<buildArgs>
|
||||||
|
<!--开启dashboard-->
|
||||||
|
<!-- <arg>-H:DashboardDump=dailylove -H:+DashboardAll</arg>-->
|
||||||
|
<arg->-H:+ReportExceptionStackTraces</arg->
|
||||||
|
<!--开启JFR-->
|
||||||
|
<arg>--enable-monitoring=jfr</arg>
|
||||||
|
<!-- <arg>--gc=G1</arg>-->
|
||||||
|
<!-- <arg>--pgo</arg>-->
|
||||||
|
<arg>-Ob</arg>
|
||||||
|
<!-- <arg>-march=native</arg>-->
|
||||||
|
<!-- <arg>-H:+BuildReport</arg>-->
|
||||||
|
</buildArgs>
|
||||||
|
<!--启动详细输出-->
|
||||||
|
<verbose>true</verbose>
|
||||||
|
<!--配置jvm参数-->
|
||||||
|
<!-- <jvmArgs>
|
||||||
|
</jvmArgs>-->
|
||||||
|
<!--<agent>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<options>
|
||||||
|
<option>experimental-class-loader-support</option>
|
||||||
|
</options>
|
||||||
|
</agent>-->
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<!--支持yaml读取pom的参数-->
|
<!--支持yaml读取pom的参数-->
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<delimiters>
|
<delimiters>
|
||||||
|
|||||||
Reference in New Issue
Block a user