Files
2026-03-27 16:58:41 +08:00

93 lines
5.0 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# docs/05-01-k3s-部署homer首页面板.md — 按需修改 host、ConfigMap 内 config.yml
# Homer 官方镜像约定:自定义配置挂在容器内 /www/assets/config.yml见 b4bz/homer 说明)
# 若不想用 ConfigMap删除本文件最上方的 ConfigMap并去掉 Deployment 里 env/volumes/volumeMounts 三段
---
apiVersion: v1 # ConfigMap存放 Homer 的 config.yml 文本
kind: ConfigMap # 非机密配置,适合放导航 YAML
metadata: # 元数据
name: homer-config # 名称须与 Deployment 中 volume 引用一致
namespace: homer # 与 Deployment 同命名空间
data: # 键值:键名 config.yml 会映射为容器内文件名
config.yml: | # Homer 主配置(修改导航只改这里,不必为每个链接单独写 K8s YAML
---
title: "实验室导航" # 页面主标题
subtitle: "Homer" # 副标题
theme: default # 主题default / dark 等(见官方文档)
connectivityCheck: false # 是否探测链接可达(实验环境可先关)
columns: 3 # 桌面端列数
services: # 分组与书签(在此集中维护)
- name: "示例分组" # 分组名
icon: "fas fa-layer-group" # Font Awesome 图标类名
items: # 该分组下的链接列表
- name: "Homer 项目" # 卡片标题
url: "https://github.com/bastienwirtz/homer" # 跳转地址
target: "_blank" # 新标签页打开
---
apiVersion: apps/v1 # Deployment 使用的 API 版本
kind: Deployment # 工作负载Deployment管理 Pod 副本)
metadata: # 对该资源的标识信息
name: homer # Deployment 名称
namespace: homer # 所属命名空间Pod 也会在该 NS 内)
spec: # Deployment 期望状态
replicas: 1 # Pod 副本数:这里是 1单副本更容易配合本地存储等
selector: # Deployment 用于匹配管理 Pod 的条件
matchLabels: # 标签匹配:必须与 template.metadata.labels 一致
app: homer # 选择带有 app=homer 标签的 Pod
template: # Pod 模板Deployment 会根据该模板创建/更新 Pod
metadata: # Pod 的元信息
labels: # Pod 标签:用于 selector 匹配 Service/Deployment 等
app: homer # Pod 上的标签 app=homer
spec: # Pod 规范
volumes: # Pod 级卷:把 ConfigMap 挂进容器
- name: homer-config # 卷名,供 volumeMounts 引用
configMap: # 来自上方 homer-config
name: homer-config # ConfigMap 名称
items: # 只挂载需要的键,文件名与键名一致
- key: config.yml # ConfigMap.data 中的键
path: config.yml # 在挂载目录下生成的文件名
containers: # 容器列表(本例只有一个容器)
- name: homer # 容器名称(日志/调试中会用到)
image: b4bz/homer:latest # Homer 官方镜像Docker Hub 命名空间 b4bz
env: # 环境变量
- name: INIT_ASSETS # 启动时是否从镜像复制默认 assets
value: "0" # 使用 ConfigMap 提供 config.yml 时设为 0避免覆盖自定义配置
ports: # 容器端口声明(供探测/生成文档等使用)
- containerPort: 8080 # 容器监听端口homer 默认 8080
volumeMounts: # 把 config.yml 挂到 Homer 读取路径
- name: homer-config # 对应 volumes[].name
mountPath: /www/assets/config.yml # 官方镜像中配置文件路径
subPath: config.yml # 单文件挂载(不覆盖整个 /www/assets 目录)
---
apiVersion: v1 # Service 使用的 API 版本
kind: Service # 网络抽象:把一组 Pod 暴露为稳定的访问入口
metadata: # Service 标识
name: homer # Service 名称Ingress/其他对象会引用)
namespace: homer # Service 所在命名空间
spec: # Service 期望状态
selector: # Service 通过标签选择要转发到的 Pod
app: homer # 选择 app=homer 的 Pod
ports: # Service 暴露端口列表
- port: 80 # Service 端口Ingress/集群访问时用它
targetPort: 8080 # 转发目标端口Pod 容器监听的端口
---
apiVersion: networking.k8s.io/v1 # Ingress 使用的 API 版本
kind: Ingress # 入口资源:对外暴露 HTTP/HTTPS 路由
metadata: # Ingress 标识
name: homer # Ingress 名称
namespace: homer # Ingress 所在命名空间
annotations: # 注解:用于 Traefik 等 Ingress Controller 的额外配置
traefik.ingress.kubernetes.io/router.entrypoints: web # Traefik 路由使用的 entrypointHTTP
spec: # Ingress 规则
rules: # 主机/路径规则列表
- host: home.example.com # 要匹配的域名(按需修改)
http: # HTTP 路由规则
paths: # 路径匹配列表
- path: / # 匹配根路径及其子路径
pathType: Prefix # Prefix 表示前缀匹配
backend: # 匹配到后端目标
service: # 使用 Service 作为后端
name: homer # 后端 Service 名称
port: # 后端端口配置
number: 80 # 后端 Service 端口