Compare commits
58 Commits
v3.6.5-nat
...
runson-ima
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cf282b964 | ||
|
|
e3a7e3c2b3 | ||
|
|
c052a11c4b | ||
|
|
4baa013d02 | ||
|
|
6e1ec6a761 | ||
|
|
7ebd4ba157 | ||
|
|
75d0f8d768 | ||
|
|
afa97145c1 | ||
|
|
2f39836963 | ||
|
|
d9807291ad | ||
|
|
27c3ab7b82 | ||
|
|
67ce2b5c86 | ||
|
|
be67a8fef0 | ||
|
|
6b47cfd5f8 | ||
|
|
d5ab5e6727 | ||
|
|
adcf60eeb6 | ||
|
|
5b20c46c5d | ||
|
|
472edfaabd | ||
|
|
e8ac7f9fbc | ||
|
|
cb418d8acd | ||
|
|
d4d6064bcd | ||
|
|
297ce02549 | ||
|
|
4f7cfe396a | ||
|
|
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 | ||
|
|
057cb5de38 | ||
|
|
bf1f52ad54 | ||
|
|
1696261450 | ||
|
|
5ca35df955 | ||
|
|
21bc585376 |
@@ -21,28 +21,51 @@ env:
|
|||||||
# 构建 Job
|
# 构建 Job
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-node24 # 如果host构建 :linux_amd64
|
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
|
- name: Print system info 1
|
||||||
run: echo " The job was automatically triggered by a ${{ gitea.event_name }} event."
|
run: echo " The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||||
|
|
||||||
- name: Print system info 2
|
- name: Print system info 2
|
||||||
run: echo " This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
run: echo " This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||||
|
|
||||||
- name: Print system info 3
|
- name: Print system info 3
|
||||||
run: echo " The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
run: echo " The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
|
||||||
- name: Print env
|
- name: Print env
|
||||||
run: env
|
run: env && blkid
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: apt-get update && apt-get install -y gettext && apt-get install -y maven && apt-get install -y docker.io
|
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.6.0
|
||||||
|
with:
|
||||||
|
# 版本大于28会有兼容性问题
|
||||||
|
version: type=archive,channel=stable,version=v27.4.0
|
||||||
|
daemon-config: |
|
||||||
|
{
|
||||||
|
"registry-mirrors":["https://docker.1ms.run"],
|
||||||
|
"dns": ["8.8.8.8", "114.114.114.114"]
|
||||||
|
}
|
||||||
- name: Generate maven config
|
- name: Generate maven config
|
||||||
uses: http://139.9.216.111:3000/bamanker/maven-settings-action@v3.1.0
|
uses: http://139.9.216.111:3000/bamanker/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
mirrors: '[{"id": "alimaven", "name": "aliyun maven", "mirrorOf": "central", "url": "http://maven.aliyun.com/nexus/content/groups/public/"}]'
|
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
|
# - uses: http://localhost:3000/bamanker/setup-node@v6
|
||||||
# with:
|
# with:
|
||||||
# node-version: 24
|
# node-version: 24
|
||||||
# cache: 'npm'
|
# cache: 'npm'
|
||||||
# - run: node -v
|
# - run: node -v
|
||||||
# 下载仓库源码,依赖node环境,因此构建服务器本地需要下载安装node并设置环境变量
|
# 下载仓库源码,依赖node环境,因此构建服务器本地需要下载安装node并设置环境变量
|
||||||
|
|
||||||
- name: Checkout repository code
|
- name: Checkout repository code
|
||||||
@@ -61,8 +84,7 @@ jobs:
|
|||||||
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 }}" &&
|
echo "now workspace: ${{ github.workspace }}"
|
||||||
pwd
|
|
||||||
|
|
||||||
# 为其他配置文件注入环境变量
|
# 为其他配置文件注入环境变量
|
||||||
- name: Inject envVar
|
- name: Inject envVar
|
||||||
@@ -70,16 +92,15 @@ jobs:
|
|||||||
envsubst < ./deployment-temp.yml > ./deployment.yml &&
|
envsubst < ./deployment-temp.yml > ./deployment.yml &&
|
||||||
cat ./deployment.yml
|
cat ./deployment.yml
|
||||||
|
|
||||||
# 构建java项目
|
# 安装java环境
|
||||||
- name: Set up Java
|
- name: Set up Java
|
||||||
uses: http://139.9.216.111:3000/bamanker/setup-graalvm@v1
|
uses: http://139.9.216.111:3000/bamanker/setup-graalvm@v1
|
||||||
with:
|
with:
|
||||||
distribution: 'graalvm'
|
distribution: 'graalvm'
|
||||||
java-version: '25.0.1'
|
java-version: '25.0.1'
|
||||||
cache: 'maven'
|
cache: 'maven'
|
||||||
|
# maven 构建
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
#使用maven绝对路径执行打包命令
|
|
||||||
run: mvn clean native:compile -DskipTests -Pnative
|
run: mvn clean native:compile -DskipTests -Pnative
|
||||||
|
|
||||||
# 登录镜像仓库,方便后续上传镜像
|
# 登录镜像仓库,方便后续上传镜像
|
||||||
@@ -88,7 +109,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
# 这里也可以通过 secrets 传入,后面再介绍
|
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
|
|
||||||
# # 获取时间戳
|
# # 获取时间戳
|
||||||
@@ -99,29 +119,54 @@ jobs:
|
|||||||
|
|
||||||
# 构建并上传镜像
|
# 构建并上传镜像
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: http://139.9.216.111:3000/bamanker/build-push-action@v4 # 获取上一步截取到的版本号,既 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: .
|
ls &&
|
||||||
platforms: linux/amd64
|
docker build --file Dockerfile --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} . &&
|
||||||
file: Dockerfile
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
||||||
push: true
|
|
||||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
# uses: http://139.9.216.111:3000/bamanker/docker-build-push@v5
|
||||||
|
# with:
|
||||||
|
# context: .
|
||||||
|
## platforms: linux/amd64
|
||||||
|
# file: Dockerfile
|
||||||
|
# push: true
|
||||||
|
# tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
||||||
|
|
||||||
#发布到 k8s
|
#发布到 k8s
|
||||||
- name: Generate kubeconfig
|
#安装 kubectl
|
||||||
uses: http://139.9.216.111:3000/bamanker/kubectl-action@v1.4.0
|
- name: Setup kubectl
|
||||||
with:
|
run: |
|
||||||
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
|
curl -LO "https://dl.k8s.io/release/v1.33.0/bin/linux/amd64/kubectl" &&
|
||||||
- name: Deploy k8s
|
chmod +x kubectl &&
|
||||||
run: kubectl apply -f ./deployment.yml
|
mv kubectl /usr/local/bin/
|
||||||
# command: apply -f http://139.9.216.111:3000/bamanker/myk3sTest/raw/branch/master/.deploy/deployment-temp.yml
|
|
||||||
|
- name: Configure kubeconfig
|
||||||
|
# 假设您的 KUBE_CONFIG 秘密是 Base64 编码的 kubeconfig 文件内容
|
||||||
|
run: |
|
||||||
|
# 1. 创建 ~/.kube 目录
|
||||||
|
mkdir -p $HOME/.kube
|
||||||
|
|
||||||
|
# 2. 将 Base64 编码的 KUBE_CONFIG 秘密解码并写入默认配置文件
|
||||||
|
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > $HOME/.kube/config
|
||||||
|
|
||||||
|
# 3. 确保 kubectl 知道配置文件的位置 (可选, 但安全)
|
||||||
|
echo "KUBECONFIG=$HOME/.kube/config" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Deploy with kubectl
|
||||||
|
run: |
|
||||||
|
kubectl apply -f ./deployment.yml
|
||||||
|
|
||||||
- name: k8s Check Pods Health
|
- name: k8s Check Pods Health
|
||||||
run: kubectl get pod -n default -l app=${{ env.APP_NAME }}
|
run: |
|
||||||
|
kubectl get pod -n default -l app=${{ env.APP_NAME }}
|
||||||
|
|
||||||
- name: k8s Update Deployment
|
- name: k8s Update Deployment
|
||||||
run: kubectl rollout restart deployment ${{ env.APP_NAME }}
|
run: |
|
||||||
|
kubectl rollout restart deployment ${{ env.APP_NAME }}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 基于 java25 构建
|
# 基于 java25 构建
|
||||||
FROM ubuntu:jammy
|
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/ubuntu:jammy
|
||||||
# 基于构建上下文 . 进行COPY 文件到 /root目录下
|
# 基于构建上下文 . 进行COPY 文件到 /root目录下
|
||||||
COPY target/myk3sTest /root/myk3sTest/
|
COPY target/myk3sTest /root/myk3sTest/
|
||||||
EXPOSE 9090
|
EXPOSE 9090
|
||||||
|
|||||||
@@ -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: /test
|
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:
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<groupId>com.bamanker</groupId>
|
<groupId>com.bamanker</groupId>
|
||||||
<artifactId>myk3sTest</artifactId>
|
<artifactId>myk3sTest</artifactId>
|
||||||
<version>v3.1.0-native</version>
|
<version>v3.1-native</version>
|
||||||
<name>myk3sTest</name>
|
<name>myk3sTest</name>
|
||||||
<description>myk3sTest</description>
|
<description>myk3sTest</description>
|
||||||
<url/>
|
<url/>
|
||||||
|
|||||||
Reference in New Issue
Block a user