add chart: update-server and website-homepage

This commit is contained in:
Haitao Pan 2025-06-11 16:20:35 +08:00
parent 584496cfa8
commit 29da696228
15 changed files with 371 additions and 19 deletions

View File

@ -0,0 +1,134 @@
#!/bin/bash
set -e
CHART_DIR="update-server"
mkdir -p "$CHART_DIR/templates"
# Chart.yaml
cat > "$CHART_DIR/Chart.yaml" <<EOF
apiVersion: v2
name: update-server
description: Simple nginx-based update server (hostPath edition)
version: 0.1.0
EOF
# values.yaml
cat > "$CHART_DIR/values.yaml" <<EOF
image:
repository: nginx
tag: stable
domain: artifact.onwalk.net
pathPrefix: /
storage:
mountPath: /usr/share/nginx/html
hostPath: /mnt/data/update-server
EOF
# deployment.yaml
cat > "$CHART_DIR/templates/deployment.yaml" <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: update-server
labels:
app: update-server
spec:
replicas: 1
selector:
matchLabels:
app: update-server
template:
metadata:
labels:
app: update-server
spec:
containers:
- name: nginx
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: 80
volumeMounts:
- name: update-volume
mountPath: {{ .Values.storage.mountPath }}
- name: nginx-conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
volumes:
- name: update-volume
hostPath:
path: {{ .Values.storage.hostPath }}
type: DirectoryOrCreate
- name: nginx-conf
configMap:
name: update-nginx-config
EOF
# service.yaml
cat > "$CHART_DIR/templates/service.yaml" <<EOF
apiVersion: v1
kind: Service
metadata:
name: update-server
spec:
selector:
app: update-server
ports:
- port: 80
targetPort: 80
EOF
# configmap.yaml
cat > "$CHART_DIR/templates/configmap.yaml" <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: update-nginx-config
data:
nginx.conf: |
server {
listen 80;
server_name localhost;
root {{ .Values.storage.mountPath }};
index index.html;
autoindex on;
location / {
autoindex_exact_size off;
autoindex_localtime on;
try_files \$uri \$uri/ =404;
}
}
EOF
# route.yaml
cat > "$CHART_DIR/templates/route.yaml" <<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: update-route
namespace: default
spec:
parentRefs:
- name: example-gateway
namespace: kong
group: gateway.networking.k8s.io
kind: Gateway
hostnames:
- {{ .Values.domain }}
rules:
- matches:
- path:
type: PathPrefix
value: {{ .Values.pathPrefix }}
backendRefs:
- name: update-server
port: 80
EOF
echo "✅ update-server Helm Chart 初始化完成!"
echo "➡️ 使用方法:"
echo " helm install update-server ./update-server"
echo " 或"
echo " helm upgrade --install update-server ./update-server"

View File

@ -1,24 +1,40 @@
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: pulp-web-route
name: pulp-route
namespace: pulp
spec:
hostnames:
- pulp.onwalk.net
- artifact.onwalk.net # 用于访问 Pulp 服务的域名
parentRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: example-gateway
namespace: kong
- name: example-gateway # 引用 Kong Gateway 或其他 Ingress Gateway
namespace: kong # Kong 所在的命名空间
group: gateway.networking.k8s.io
kind: Gateway # 引用类型为 Gateway
rules:
# 路由匹配 /api 路径的请求到 Pulp API 服务
- matches:
- path:
type: PathPrefix
value: /
value: /api # 匹配以 /api 开头的路径
backendRefs:
- group: ""
kind: Service
name: example-pulp-web-svc
port: 24880
weight: 1
- name: example-pulp-api-svc # Pulp API 服务名
port: 24817 # Pulp API 服务端口
# 路由匹配 /content 路径的请求到 Pulp 内容服务
- matches:
- path:
type: PathPrefix
value: /content # 匹配以 /content 开头的路径
backendRefs:
- name: example-pulp-content-svc # Pulp 内容服务名
port: 24816 # Pulp 内容服务端口
# 路由匹配根路径 / 的请求到 Pulp Web 服务
- matches:
- path:
type: PathPrefix
value: / # 匹配以 / 开头的路径(根路径)
backendRefs:
- name: example-pulp-web-svc # Pulp Web 服务名
port: 24880 # Pulp Web 服务端口

View File

@ -4,7 +4,7 @@ kind: Secret
metadata:
name: 'example-pulp-admin-password'
stringData:
password: 'xxxxxxxx'
password: 'a4h3ljbn'
---
apiVersion: v1
kind: ConfigMap
@ -12,14 +12,10 @@ metadata:
name: settings
data:
analytics: "False"
token_server: '"https://artifact.onwalk.net/pulp/api/v3/token/"'
content_origin: '"https://artifact.onwalk.net"'
ansible_api_hostname: '"https://artifact.onwalk.net"'
pypi_api_hostname: '"https://artifact.onwalk.net"'
api_root: '"/pulp/"'
api_root: '"/"'
allowed_export_paths: '[ "/tmp" ]'
allowed_import_paths: '[ "/tmp" ]'
---
apiVersion: repo-manager.pulpproject.org/v1
kind: Pulp
@ -45,4 +41,3 @@ spec:
enabled: true
redis_storage_class: local-path
ingress_type: none

View File

@ -0,0 +1,4 @@
apiVersion: v2
name: update-server
description: Simple nginx-based update server (hostPath edition)
version: 0.1.0

View File

@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: update-nginx-config
data:
nginx.conf: |
server {
listen 80;
server_name localhost;
root {{ .Values.storage.mountPath }};
index index.html;
autoindex on;
location / {
autoindex_exact_size off;
autoindex_localtime on;
try_files $uri $uri/ =404;
}
}

View File

@ -0,0 +1,35 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: update-server
labels:
app: update-server
spec:
replicas: 1
selector:
matchLabels:
app: update-server
template:
metadata:
labels:
app: update-server
spec:
containers:
- name: nginx
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: 80
volumeMounts:
- name: update-volume
mountPath: {{ .Values.storage.mountPath }}
- name: nginx-conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
volumes:
- name: update-volume
hostPath:
path: {{ .Values.storage.hostPath }}
type: DirectoryOrCreate
- name: nginx-conf
configMap:
name: update-nginx-config

View File

@ -0,0 +1,21 @@
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: update-route
namespace: default
spec:
parentRefs:
- name: example-gateway
namespace: kong
group: gateway.networking.k8s.io
kind: Gateway
hostnames:
- {{ .Values.domain }}
rules:
- matches:
- path:
type: PathPrefix
value: {{ .Values.pathPrefix }}
backendRefs:
- name: update-server
port: 80

View File

@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: update-server
spec:
selector:
app: update-server
ports:
- port: 80
targetPort: 80

View File

@ -0,0 +1,10 @@
image:
repository: nginx
tag: stable
domain: artifact.onwalk.net
pathPrefix: /
storage:
mountPath: /usr/share/nginx/html
hostPath: /mnt/data/update-server

View File

@ -0,0 +1,4 @@
apiVersion: v2
name: website-homepage
description: Simple nginx-based update server (hostPath edition)
version: 0.1.0

View File

@ -0,0 +1,29 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: homepage-nginx-config
data:
nginx.conf: |
server {
listen 80;
server_name localhost;
root {{ .Values.storage.mountPath }};
index index.html;
# 关闭目录浏览
autoindex off;
# 静态文件缓存
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?|eot|ttf|svg|otf|webp)$ {
expires 30d;
access_log off;
add_header Cache-Control "public, max-age=2592000, immutable";
}
# 前端路由支持 (HTML5 history mode)
location / {
try_files $uri /index.html;
}
# 可选: 防止隐藏文件被访问
location ~ /\. {
deny all;
}
}

View File

@ -0,0 +1,35 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: homepage-server
labels:
app: homepage-server
spec:
replicas: 1
selector:
matchLabels:
app: homepage-server
template:
metadata:
labels:
app: homepage-server
spec:
containers:
- name: nginx
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: 80
volumeMounts:
- name: update-volume
mountPath: {{ .Values.storage.mountPath }}
- name: nginx-conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
volumes:
- name: update-volume
hostPath:
path: {{ .Values.storage.hostPath }}
type: DirectoryOrCreate
- name: nginx-conf
configMap:
name: homepage-nginx-config

View File

@ -0,0 +1,21 @@
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: homepage-server-route
namespace: default
spec:
parentRefs:
- name: example-gateway
namespace: kong
group: gateway.networking.k8s.io
kind: Gateway
hostnames:
- {{ .Values.domain }}
rules:
- matches:
- path:
type: PathPrefix
value: {{ .Values.pathPrefix }}
backendRefs:
- name: homepage-server
port: 80

View File

@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: homepage-server
spec:
selector:
app: homepage-server
ports:
- port: 80
targetPort: 80

View File

@ -0,0 +1,10 @@
image:
repository: nginx
tag: stable
domain: www.onwalk.net
pathPrefix: /
storage:
mountPath: /usr/share/nginx/html
hostPath: /mnt/data/website/