Skip to content

Commit 5aa3862

Browse files
authored
fix: update image output handling in release.yml (#391)
* feat: add install script and update image handling in Kubefile * fix: add charts for aiproxy * fix: update ingress path for aiproxy service * feat: add Sealos AI Proxy admin configuration to app.yaml * fix: update adminKey retrieval logic in install script * fix: reorder deletion of aiproxy resources in install script * fix: simplify image list preparation in release.yml * fix: update image caching process in release.yml
1 parent 5fb2596 commit 5aa3862

28 files changed

+920
-552
lines changed

.github/scripts/install.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
set -e
3+
timestamp() {
4+
date +"%Y-%m-%d %T"
5+
}
6+
7+
error() {
8+
flag=$(timestamp)
9+
echo -e "\033[31m ERROR [$flag] >> $* \033[0m"
10+
exit 1
11+
}
12+
13+
logger() {
14+
flag=$(timestamp)
15+
echo -e "\033[36m INFO [$flag] >> $* \033[0m"
16+
}
17+
18+
warn() {
19+
flag=$(timestamp)
20+
echo -e "\033[33m WARN [$flag] >> $* \033[0m"
21+
}
22+
23+
debug() {
24+
flag=$(timestamp)
25+
echo -e "\033[32m DEBUG [$flag] >> $* \033[0m"
26+
}
27+
28+
check_file_exits() {
29+
for f; do
30+
if [[ -f $f ]]; then
31+
logger "The machine $f is installed"
32+
exit 0
33+
fi
34+
done
35+
}
36+
37+
check_file_exits /usr/bin/sealos
38+
39+
pushd "$(mktemp -d)" >/dev/null || exit
40+
until curl -sLo "sealos.tar.gz" "https://github.com/labring/sealos/releases/download/v5.1.0-beta3/sealos_5.1.0-beta3_linux_amd64.tar.gz"; do sleep 3; done
41+
tar -zxf sealos.tar.gz sealos && chmod +x sealos && mv sealos /usr/bin
42+
rm -rf sealos.tar.gz
43+
sealos version
44+
popd >/dev/null

.github/workflows/release.yml

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO != '' && secrets.DOCKERHUB_REPO || secrets.DOCKERHUB_USERNAME != '' && format('{0}/{1}', secrets.DOCKERHUB_USERNAME, 'aiproxy') || '' }}
2121
GHCR_REPO: ghcr.io/${{ github.repository }}
2222
ALIYUN_REGISTRY: ${{ secrets.ALIYUN_REGISTRY }}
23-
ALIYUN_REPO: ${{ secrets.ALIYUN_REPO != '' && secrets.ALIYUN_REPO || secrets.ALIYUN_USERNAME != '' && format('{0}/{1}/{2}', secrets.ALIYUN_REGISTRY, secrets.ALIYUN_USERNAME, 'aiproxy') || '' }}
23+
ALIYUN_REPO: ${{ secrets.ALIYUN_REPO != '' && secrets.ALIYUN_REPO || (secrets.ALIYUN_REGISTRY != '' && secrets.ALIYUN_USERNAME != '') && format('{0}/{1}/{2}', secrets.ALIYUN_REGISTRY, secrets.ALIYUN_USERNAME, 'aiproxy') || '' }}
2424

2525
jobs:
2626
release-web:
@@ -282,3 +282,88 @@ jobs:
282282
- name: Inspect image
283283
run: |
284284
docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}
285+
release-sealos-images:
286+
name: Push Sealos Images
287+
permissions:
288+
packages: write
289+
needs: release-docker-images
290+
runs-on: ubuntu-24.04
291+
if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
292+
steps:
293+
- name: Checkout
294+
uses: actions/checkout@v5
295+
- name: install cache images tools
296+
run: |
297+
sudo bash ./.github/scripts/install.sh
298+
- name: Set up QEMU
299+
uses: docker/setup-qemu-action@v3
300+
- uses: docker/setup-buildx-action@v3
301+
- name: Prepare cluster image list
302+
id: cluster_image_targets
303+
run: |
304+
set -euo pipefail
305+
images=("${GHCR_REPO}-cluster")
306+
if [ -n "${DOCKERHUB_REPO}" ]; then
307+
images+=("${DOCKERHUB_REPO}-cluster")
308+
fi
309+
if [ -n "${ALIYUN_REPO}" ]; then
310+
images+=("${ALIYUN_REPO}-cluster")
311+
fi
312+
313+
{
314+
echo "images<<EOF"
315+
printf '%s\n' "${images[@]}"
316+
echo "EOF"
317+
csv=$(IFS=','; printf '%s' "${images[*]}")
318+
echo "names=${csv}"
319+
} >> "${GITHUB_OUTPUT}"
320+
- name: Extract metadata (tags, labels) for Docker
321+
id: meta
322+
uses: docker/metadata-action@v5
323+
with:
324+
images: ${{ steps.cluster_image_targets.outputs.images }}
325+
tags: |
326+
type=ref,event=branch
327+
type=ref,event=pr
328+
type=ref,event=tag
329+
type=semver,pattern={{version}}
330+
type=semver,pattern={{major}}.{{minor}}
331+
type=semver,pattern={{major}}
332+
type=sha
333+
- name: cache images
334+
working-directory: core/deploy
335+
run: |
336+
sudo sealos login -u "${{ github.repository_owner }}" -p "${{ secrets.GITHUB_TOKEN }}" ghcr.io
337+
sed -i "s#image: ghcr.io/labring/aiproxy:latest#image: ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}#g" charts/aiproxy/values.yaml
338+
sudo sealos registry save --registry-dir=registry_amd64 --arch amd64 .
339+
sudo sealos registry save --registry-dir=registry_arm64 --arch arm64 .
340+
- name: Login to GitHub Container Registry
341+
uses: docker/login-action@v3
342+
with:
343+
registry: ghcr.io
344+
username: ${{ github.actor }}
345+
password: ${{ secrets.GITHUB_TOKEN }}
346+
347+
- name: Login to DockerHub
348+
uses: docker/login-action@v3
349+
if: ${{ env.DOCKERHUB_REPO }}
350+
with:
351+
username: ${{ secrets.DOCKERHUB_USERNAME }}
352+
password: ${{ secrets.DOCKERHUB_TOKEN }}
353+
354+
- name: Login to Aliyun Registry
355+
uses: docker/login-action@v3
356+
if: ${{ env.ALIYUN_REGISTRY }}
357+
with:
358+
registry: ${{ env.ALIYUN_REGISTRY }}
359+
username: ${{ secrets.ALIYUN_USERNAME }}
360+
password: ${{ secrets.ALIYUN_PASSWORD }}
361+
- name: Build images
362+
uses: docker/build-push-action@v6
363+
with:
364+
context: ./core/deploy
365+
file: ./core/deploy/Kubefile
366+
labels: ${{ steps.meta.outputs.labels }}
367+
platforms: linux/amd64,linux/arm64
368+
push: ${{ github.event_name != 'pull_request' }}
369+
tags: ${{ steps.meta.outputs.tags }}

core/deploy/Kubefile

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
1-
FROM scratch
2-
COPY registry registry
3-
COPY manifests manifests
4-
COPY scripts scripts
1+
FROM --platform=$BUILDPLATFORM scratch
2+
ARG TARGETARCH
3+
COPY registry_${TARGETARCH} registry
54

6-
ENV cloudDomain="127.0.0.1.nip.io"
7-
ENV cloudPort=""
8-
ENV certSecretName="wildcard-cert"
5+
COPY install.sh install.sh
6+
COPY charts charts
97

10-
ENV ADMIN_KEY=""
11-
ENV SEALOS_JWT_KEY="<sealos-jwt-key-placeholder>"
12-
ENV SQL_DSN="<sql-placeholder>"
13-
ENV LOG_SQL_DSN="<sql-log-placeholder>"
14-
ENV REDIS="<redis-placeholder>"
15-
16-
ENV BALANCE_SEALOS_CHECK_REAL_NAME_ENABLE="false"
17-
ENV BALANCE_SEALOS_NO_REAL_NAME_USED_AMOUNT_LIMIT="1"
18-
19-
ENV SAVE_ALL_LOG_DETAIL="false"
20-
ENV LOG_DETAIL_REQUEST_BODY_MAX_SIZE="128"
21-
ENV LOG_DETAIL_RESPONSE_BODY_MAX_SIZE="128"
22-
23-
CMD ["bash scripts/init.sh"]
8+
CMD ["bash install.sh"]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: aiproxy-database
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"

core/deploy/charts/aiproxy-database/templates/NOTES.txt

Whitespace-only changes.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "aiproxy-database.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "aiproxy-database.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "aiproxy-database.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "aiproxy-database.labels" -}}
37+
helm.sh/chart: {{ include "aiproxy-database.chart" . }}
38+
{{ include "aiproxy-database.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "aiproxy-database.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "aiproxy-database.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "aiproxy-database.serviceAccountName" -}}
57+
{{- default (include "aiproxy-database.fullname" .) .Values.serviceAccount.name }}
58+
{{- end }}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
labels:
5+
sealos-db-provider-cr: {{.Values.pgsqlLog.name}}
6+
app.kubernetes.io/instance: {{.Values.pgsqlLog.name}}
7+
app.kubernetes.io/managed-by: kbcli
8+
name: {{.Values.pgsqlLog.name}}
9+
namespace: {{.Release.Namespace}}
10+
---
11+
apiVersion: rbac.authorization.k8s.io/v1
12+
kind: Role
13+
metadata:
14+
labels:
15+
sealos-db-provider-cr: {{.Values.pgsqlLog.name}}
16+
app.kubernetes.io/instance: {{.Values.pgsqlLog.name}}
17+
app.kubernetes.io/managed-by: kbcli
18+
name: {{.Values.pgsqlLog.name}}
19+
namespace: {{.Release.Namespace}}
20+
rules:
21+
- apiGroups:
22+
- '*'
23+
resources:
24+
- '*'
25+
verbs:
26+
- '*'
27+
---
28+
apiVersion: rbac.authorization.k8s.io/v1
29+
kind: RoleBinding
30+
metadata:
31+
labels:
32+
sealos-db-provider-cr: {{.Values.pgsqlLog.name}}
33+
app.kubernetes.io/instance: {{.Values.pgsqlLog.name}}
34+
app.kubernetes.io/managed-by: kbcli
35+
name: {{.Values.pgsqlLog.name}}
36+
namespace: {{.Release.Namespace}}
37+
roleRef:
38+
apiGroup: rbac.authorization.k8s.io
39+
kind: Role
40+
name: {{.Values.pgsqlLog.name}}
41+
subjects:
42+
- kind: ServiceAccount
43+
name: {{.Values.pgsqlLog.name}}
44+
namespace: {{.Release.Namespace}}
45+
---
46+
apiVersion: apps.kubeblocks.io/v1alpha1
47+
kind: Cluster
48+
metadata:
49+
labels:
50+
clusterdefinition.kubeblocks.io/name: postgresql
51+
clusterversion.kubeblocks.io/name: {{ .Values.pgsqlLog.version }}
52+
name: {{.Values.pgsqlLog.name}}
53+
namespace: {{.Release.Namespace}}
54+
spec:
55+
affinity:
56+
nodeLabels: {}
57+
podAntiAffinity: Preferred
58+
tenancy: SharedNode
59+
topologyKeys:
60+
- kubernetes.io/hostname
61+
backup:
62+
cronExpression: {{.Values.pgsqlLog.backup.cron}}
63+
enabled: true
64+
method: dump
65+
pitrEnabled: true
66+
retentionPeriod: {{.Values.pgsqlLog.backup.retentionPeriod}}
67+
clusterDefinitionRef: postgresql
68+
clusterVersionRef: {{ .Values.pgsqlLog.version }}
69+
componentSpecs:
70+
- componentDefRef: postgresql
71+
monitor: true
72+
name: postgresql
73+
replicas: {{ .Values.pgsqlLog.replicas }}
74+
resources: {{ toYaml .Values.pgsqlLog.resources | nindent 8 }}
75+
serviceAccountName: {{.Values.pgsqlLog.name}}
76+
switchPolicy:
77+
type: Noop
78+
volumeClaimTemplates:
79+
- name: data
80+
spec:
81+
accessModes:
82+
- ReadWriteOnce
83+
resources:
84+
requests:
85+
storage: {{ .Values.pgsqlLog.storage }}
86+
terminationPolicy: Delete

0 commit comments

Comments
 (0)