比较提交
26
次代码提交
+10
@@ -0,0 +1,10 @@
|
|||||||
|
# 华为云OBS S3凭据 (velero备份 + CNPG WAL归档)
|
||||||
|
S3_ACCESS_KEY_ID=placeholder
|
||||||
|
S3_ACCESS_SECRET_KEY=placeholder
|
||||||
|
|
||||||
|
# DNSPod API凭据 (cert-manager ACME DNS验证)
|
||||||
|
DNSPOD_SECRET_ID=placeholder
|
||||||
|
DNSPOD_SECRET_KEY=placeholder
|
||||||
|
|
||||||
|
# Gitea Actions Runner Token
|
||||||
|
GITEA_ACTIONS_TOKEN=placeholder
|
||||||
+3
@@ -2,6 +2,9 @@
|
|||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
# Secrets
|
||||||
|
.env
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
### k3s 部署仓库 让你快速拥有一个高可用的k3s集群 并且具有完备的生产级能力(监控、告警、防护、负载、备份)
|
### k3s 部署仓库 让你快速拥有一个高可用的k3s集群 并且具有完备的生产级能力(监控、告警、防护、负载、备份)
|
||||||
|
|
||||||
#### install 集群安装相关
|
#### 集群安装相关
|
||||||
|
|
||||||
参见 [install/README.md](install/README.md)
|
参见 [ansible/README.md](ansible/README.md)
|
||||||
|
|
||||||
#### apps 相关应用
|
#### apps 相关应用
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# 环境变量模板
|
||||||
|
# 复制为 .env 并填写实际值,然后 source .env
|
||||||
|
|
||||||
|
# Tailscale Auth Key (必须)
|
||||||
|
export TAILSCALE_AUTH_KEY=""
|
||||||
|
|
||||||
|
# K3s HA Server URL (添加节点时需要)
|
||||||
|
export HA_SERVER_URL="https://k3s.example.com:6443"
|
||||||
|
|
||||||
|
# SSH 密码 (如果使用密码认证,必须设置;如果使用密钥认证,留空)
|
||||||
|
export SSH_PASSWORD=""
|
||||||
|
|
||||||
|
# SSH 公钥路径 (默认 ~/.ssh/id_rsa.pub)
|
||||||
|
# export SSH_PUBKEY=""
|
||||||
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Ansible 临时文件
|
||||||
|
*.retry
|
||||||
|
|
||||||
|
# 敏感文件
|
||||||
|
kubeconfig.yaml
|
||||||
|
kubeconfig-*.yaml
|
||||||
|
*.pem
|
||||||
|
*.key
|
||||||
|
|
||||||
|
# 本地环境
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
|
||||||
+157
@@ -0,0 +1,157 @@
|
|||||||
|
# K3s Ansible 自动化安装
|
||||||
|
|
||||||
|
一键部署 K3s 集群,支持国内镜像加速、Tailscale 组网、SSH 安全加固。
|
||||||
|
|
||||||
|
## 目录结构
|
||||||
|
|
||||||
|
```
|
||||||
|
ansible/
|
||||||
|
├── ansible.cfg # Ansible 配置
|
||||||
|
├── inventory/
|
||||||
|
│ ├── hosts.yml # 主机清单 ⭐ 需修改
|
||||||
|
│ └── group_vars/all.yml # 全局变量
|
||||||
|
├── roles/
|
||||||
|
│ ├── ssh/ # SSH 安全加固
|
||||||
|
│ │ ├── tasks/main.yml
|
||||||
|
│ │ ├── handlers/main.yml
|
||||||
|
│ │ └── templates/sshd_config.j2
|
||||||
|
│ ├── common/ # 基础配置 (hostname, sysctl, tailscale)
|
||||||
|
│ │ ├── tasks/main.yml
|
||||||
|
│ │ └── handlers/main.yml
|
||||||
|
│ └── k3s/ # K3s 安装
|
||||||
|
│ ├── tasks/main.yml
|
||||||
|
│ └── templates/
|
||||||
|
│ ├── k3s-server.yaml.j2 # Server 配置 (统一 init/join)
|
||||||
|
│ ├── k3s-agent.yaml.j2 # Agent 配置
|
||||||
|
│ └── registries.yaml.j2 # 镜像加速
|
||||||
|
└── playbooks/
|
||||||
|
└── site.yml # 完整安装
|
||||||
|
```
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
### 1. 配置主机清单
|
||||||
|
|
||||||
|
编辑 `inventory/hosts.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
masters:
|
||||||
|
hosts:
|
||||||
|
master1:
|
||||||
|
ansible_host: 10.0.0.1
|
||||||
|
node_hostname: master1
|
||||||
|
cluster_init: true # 首个节点设为 true
|
||||||
|
node_region: cn-sh # 区域标签
|
||||||
|
use_mirror: true # 使用镜像加速
|
||||||
|
enable_lb: true # 启用 LB
|
||||||
|
netfilter_mode: "" # 阿里云/华为云设为 nodivert
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 设置环境变量
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 必须
|
||||||
|
export TAILSCALE_AUTH_KEY="tskey-auth-xxx"
|
||||||
|
|
||||||
|
# 首次安装 (SSH 加固)
|
||||||
|
export SSH_PASSWORD="your-root-password"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 执行安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd k3s/ansible
|
||||||
|
|
||||||
|
# 方式一: 首次安装 (含 SSH 加固,端口改为 2103,启用密钥认证)
|
||||||
|
ansible-playbook playbooks/site.yml --tags ssh,common,k3s,status
|
||||||
|
|
||||||
|
# 方式二: 常规安装 (已配置 SSH 密钥)
|
||||||
|
ansible-playbook playbooks/site.yml
|
||||||
|
|
||||||
|
# 方式三: 仅安装首个 master
|
||||||
|
ansible-playbook playbooks/site.yml -l first-master-name
|
||||||
|
|
||||||
|
# 方式四: 添加新节点
|
||||||
|
ansible-playbook playbooks/site.yml -l new-node-name
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 获取 kubeconfig
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 安装完成后自动保存到 ansible/kubeconfig.yaml
|
||||||
|
sed -i '' 's/127.0.0.1/k3s.yourdomain.com/g' kubeconfig.yaml
|
||||||
|
export KUBECONFIG=$(pwd)/kubeconfig.yaml
|
||||||
|
kubectl get nodes
|
||||||
|
```
|
||||||
|
|
||||||
|
## 节点变量
|
||||||
|
|
||||||
|
| 变量 | 类型 | 默认值 | 说明 |
|
||||||
|
|------|------|--------|------|
|
||||||
|
| `ansible_host` | string | - | 节点 IP |
|
||||||
|
| `node_hostname` | string | - | 主机名 |
|
||||||
|
| `cluster_init` | bool | false | 首个 master 设为 true |
|
||||||
|
| `node_region` | string | - | 区域标签 (cn-sh/hk/us-west) |
|
||||||
|
| `use_mirror` | bool | false | 使用镜像加速 |
|
||||||
|
| `enable_lb` | bool | - | 启用 K3s LB |
|
||||||
|
| `netfilter_mode` | string | "" | Tailscale netfilter: off/nodivert/on |
|
||||||
|
| `node_labels` | dict | - | 自定义标签 |
|
||||||
|
| `node_taints` | list | - | 节点污点 (格式: key=value:effect) |
|
||||||
|
|
||||||
|
## 环境变量
|
||||||
|
|
||||||
|
| 变量 | 必须 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| `TAILSCALE_AUTH_KEY` | ✅ | Tailscale Auth Key |
|
||||||
|
| `SSH_PASSWORD` | 首次安装 | SSH 密码 |
|
||||||
|
| `SSH_PUBKEY` | - | SSH 公钥 (默认 ~/.ssh/id_rsa.pub) |
|
||||||
|
|
||||||
|
## 镜像加速
|
||||||
|
|
||||||
|
当 `use_mirror: true` 时自动启用:
|
||||||
|
|
||||||
|
- K3s 安装脚本: `rancher-mirror.rancher.cn`
|
||||||
|
- 常规容器镜像加速
|
||||||
|
|
||||||
|
## SSH 安全加固
|
||||||
|
|
||||||
|
首次安装时 (`--tags ssh`) 自动执行:
|
||||||
|
|
||||||
|
1. 端口改为 2103
|
||||||
|
2. 禁用密码登录
|
||||||
|
3. 启用密钥认证
|
||||||
|
4. 自动添加本地公钥
|
||||||
|
|
||||||
|
## 集群安装流程
|
||||||
|
|
||||||
|
Playbook 按以下顺序执行:
|
||||||
|
|
||||||
|
1. **初始化节点安装**: 安装 `cluster_init: true` 的第一个 master 节点
|
||||||
|
2. **动态获取 Token**: 从初始化节点读取 `/var/lib/rancher/k3s/server/node-token`
|
||||||
|
3. **Token 注入**: 将 K3S_TOKEN 和 K3S_SERVER_URL 设置为所有节点的 fact
|
||||||
|
4. **其他 Master 节点**: 使用动态获取的 Token 加入集群
|
||||||
|
5. **Agent 节点**: 使用动态获取的 Token 加入集群
|
||||||
|
|
||||||
|
这样在一次性安装整个集群时,无需手动设置 `K3S_TOKEN` 环境变量。
|
||||||
|
|
||||||
|
## 常用命令
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 测试连接
|
||||||
|
ansible all -m ping
|
||||||
|
|
||||||
|
# 仅运行特定阶段
|
||||||
|
ansible-playbook playbooks/site.yml --tags common
|
||||||
|
ansible-playbook playbooks/site.yml --tags k3s
|
||||||
|
|
||||||
|
# 指定节点
|
||||||
|
ansible-playbook playbooks/site.yml -l master1,agent1
|
||||||
|
|
||||||
|
# 调试模式
|
||||||
|
ansible-playbook playbooks/site.yml -vvv
|
||||||
|
|
||||||
|
# 检查语法
|
||||||
|
ansible-playbook playbooks/site.yml --syntax-check
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
## 安装方法
|
## 手动安装方法
|
||||||
|
|
||||||
需要在每个节点上执行以下命令 节点系统需求 debian 11+ ubuntu 20.04+
|
需要在每个节点上执行以下命令 节点系统需求 debian 11+ ubuntu 20.04+
|
||||||
|
|
||||||
@@ -39,12 +39,7 @@ sysctl -p /etc/sysctl.d/99-tailscale.conf
|
|||||||
|
|
||||||
采用config.yaml的方式进行配置(非环境变量) 使集群配置能够进行git版本控制
|
采用config.yaml的方式进行配置(非环境变量) 使集群配置能够进行git版本控制
|
||||||
|
|
||||||
- master-init.config.yaml 是第一个master节点的配置
|
参考roles/k3s/templates下的配置文件模版
|
||||||
- master.config.yaml 是master从节点的配置 (单节点不需要)
|
|
||||||
- agent.config.yaml 是agent节点的配置 (单节点不需要)
|
|
||||||
|
|
||||||
注意!! 将tls-san改为你自己的域名 如果你的节点没有配置域名 请将其替换为节点的ip地址,
|
|
||||||
`YOU_SHOULD_MODIFY_THIS_JOIN_KEY` 替换为你申请的tailscale auth key
|
|
||||||
|
|
||||||
根据节点类型, 将上述文件中的内容写入到此处
|
根据节点类型, 将上述文件中的内容写入到此处
|
||||||
|
|
||||||
@@ -59,7 +54,7 @@ mkdir -p /etc/rancher/k3s && vim /etc/rancher/k3s/config.yaml
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl -sfL https://get.k3s.io | \
|
curl -sfL https://get.k3s.io | \
|
||||||
INSTALL_K3S_VERSION=v1.33.2+k3s1 \
|
INSTALL_K3S_VERSION=v1.34.2+k3s1 \
|
||||||
sh -s - server
|
sh -s - server
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -69,7 +64,7 @@ curl -sfL https://get.k3s.io | \
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | \
|
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | \
|
||||||
INSTALL_K3S_VERSION=v1.33.2+k3s1 \
|
INSTALL_K3S_VERSION=v1.34.2+k3s1 \
|
||||||
INSTALL_K3S_MIRROR=cn \
|
INSTALL_K3S_MIRROR=cn \
|
||||||
sh -s - server
|
sh -s - server
|
||||||
```
|
```
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
[defaults]
|
||||||
|
inventory = inventory/hosts.yml
|
||||||
|
roles_path = roles
|
||||||
|
host_key_checking = False
|
||||||
|
retry_files_enabled = False
|
||||||
|
stdout_callback = default
|
||||||
|
callbacks_enabled = ansible.builtin.default
|
||||||
|
interpreter_python = auto_silent
|
||||||
|
deprecation_warnings = False
|
||||||
|
|
||||||
|
[callback_default]
|
||||||
|
result_format = yaml
|
||||||
|
|
||||||
|
[privilege_escalation]
|
||||||
|
become = True
|
||||||
|
become_method = sudo
|
||||||
|
become_user = root
|
||||||
|
|
||||||
|
[ssh_connection]
|
||||||
|
pipelining = True
|
||||||
|
ssh_args = -o ControlMaster=auto -o ControlPersist=60s
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# K3s Ansible 全局变量
|
||||||
|
---
|
||||||
|
# ============================================
|
||||||
|
# 敏感信息 (通过环境变量传入)
|
||||||
|
# ============================================
|
||||||
|
tailscale_auth_key: "{{ lookup('env', 'TAILSCALE_AUTH_KEY') }}"
|
||||||
|
# 高可用集群的 server_url 需要指向负载均衡器地址,单节点集群则指向自身
|
||||||
|
ha_server_url: "{{ lookup('env', 'HA_SERVER_URL') | default('', true) }}"
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# K3s 配置
|
||||||
|
# ============================================
|
||||||
|
# K3s Server URL (优先使用 HA_SERVER_URL,否则动态使用 init 节点地址)
|
||||||
|
k3s_server_url: "{{ ha_server_url if (ha_server_url | length > 0) else '' }}"
|
||||||
|
k3s_version: "v1.34.2+k3s1"
|
||||||
|
|
||||||
|
# ETCD 配置
|
||||||
|
etcd_snapshot_retention: 1
|
||||||
|
etcd_snapshot_schedule_cron: "0 0 * * *"
|
||||||
|
etcd_snapshot_compress: true
|
||||||
|
|
||||||
|
# 禁用的组件
|
||||||
|
k3s_disable_components:
|
||||||
|
- traefik
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# 安装源配置
|
||||||
|
# ============================================
|
||||||
|
# 国内镜像源
|
||||||
|
mirror_k3s_install_url: "https://rancher-mirror.rancher.cn/k3s/k3s-install.sh"
|
||||||
|
# 官方源
|
||||||
|
global_k3s_install_url: "https://get.k3s.io"
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# 镜像加速配置 (use_mirror: true 时启用)
|
||||||
|
# ============================================
|
||||||
|
registry_mirrors:
|
||||||
|
docker.io:
|
||||||
|
- "docker.1ms.run"
|
||||||
|
- "docker.m.daocloud.io"
|
||||||
|
ghcr.io:
|
||||||
|
- "ghcr.m.daocloud.io"
|
||||||
|
registry.k8s.io:
|
||||||
|
- "k8s.m.daocloud.io"
|
||||||
|
quay.io:
|
||||||
|
- "quay.m.daocloud.io"
|
||||||
|
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
# K3s 集群主机清单
|
||||||
|
---
|
||||||
|
all:
|
||||||
|
vars:
|
||||||
|
# SSH 配置
|
||||||
|
ansible_user: root
|
||||||
|
# 默认端口,首次安装时使用22,后续会被动态覆盖
|
||||||
|
ansible_port: 22
|
||||||
|
ansible_password: "{{ lookup('env', 'SSH_PASSWORD') | default(omit, true) }}"
|
||||||
|
|
||||||
|
# SSH 安全配置
|
||||||
|
ssh_new_port: 2103
|
||||||
|
ssh_pubkey: "{{ lookup('env', 'SSH_PUBKEY') | default(lookup('file', '~/.ssh/id_rsa.pub'), true) }}"
|
||||||
|
|
||||||
|
children:
|
||||||
|
# Master 节点 (Server)
|
||||||
|
masters:
|
||||||
|
hosts:
|
||||||
|
tca:
|
||||||
|
ansible_host: tca.node.dev.cm
|
||||||
|
node_hostname: tca
|
||||||
|
cluster_init: true
|
||||||
|
node_region: cn-sh
|
||||||
|
use_mirror: true
|
||||||
|
node_taints:
|
||||||
|
- "node-role.kubernetes.io/control-plane:NoSchedule"
|
||||||
|
tcb:
|
||||||
|
ansible_host: tcb.node.dev.cm
|
||||||
|
node_hostname: tcb
|
||||||
|
node_region: cn-sh
|
||||||
|
use_mirror: true
|
||||||
|
node_taints:
|
||||||
|
- "node-role.kubernetes.io/control-plane:NoSchedule"
|
||||||
|
tcc:
|
||||||
|
ansible_host: tcc.node.dev.cm
|
||||||
|
node_hostname: tcc
|
||||||
|
node_region: cn-sh
|
||||||
|
use_mirror: true
|
||||||
|
node_taints:
|
||||||
|
- "node-role.kubernetes.io/control-plane:NoSchedule"
|
||||||
|
|
||||||
|
# Agent 节点 (Worker)
|
||||||
|
agents:
|
||||||
|
hosts:
|
||||||
|
tce:
|
||||||
|
ansible_host: tce.node.dev.cm
|
||||||
|
node_hostname: tce
|
||||||
|
node_region: cn-sh
|
||||||
|
use_mirror: true
|
||||||
|
tcd:
|
||||||
|
ansible_host: tcd.node.dev.cm
|
||||||
|
node_hostname: tcd
|
||||||
|
node_region: cn-sh
|
||||||
|
use_mirror: true
|
||||||
|
tchk:
|
||||||
|
ansible_host: tchk.node.dev.cm
|
||||||
|
node_hostname: tchk
|
||||||
|
node_region: cn-hk
|
||||||
|
tthk:
|
||||||
|
ansible_host: tthk.node.dev.cm
|
||||||
|
node_hostname: tthk
|
||||||
|
node_region: cn-hk
|
||||||
|
enable_lb: true
|
||||||
|
alihk:
|
||||||
|
ansible_host: alihk.node.dev.cm
|
||||||
|
node_hostname: alihk
|
||||||
|
node_region: cn-hk
|
||||||
|
enable_lb: true
|
||||||
|
netfilter_mode: nodivert
|
||||||
|
alihka:
|
||||||
|
ansible_host: alihka.node.dev.cm
|
||||||
|
node_hostname: alihka
|
||||||
|
node_region: cn-hk
|
||||||
|
netfilter_mode: nodivert
|
||||||
|
hwhk:
|
||||||
|
ansible_host: hwhk.node.dev.cm
|
||||||
|
node_hostname: hwhk
|
||||||
|
node_region: cn-hk
|
||||||
|
enable_lb: true
|
||||||
|
netfilter_mode: nodivert
|
||||||
|
hwsg:
|
||||||
|
ansible_host: hwsg.node.dev.cm
|
||||||
|
node_hostname: hwsg
|
||||||
|
node_region: sg-sg
|
||||||
|
enable_lb: true
|
||||||
|
netfilter_mode: nodivert
|
||||||
|
hwa:
|
||||||
|
ansible_host: hwa.node.dev.cm
|
||||||
|
node_hostname: hwa
|
||||||
|
node_region: cn-sh
|
||||||
|
use_mirror: true
|
||||||
|
netfilter_mode: nodivert
|
||||||
|
clawhk:
|
||||||
|
ansible_host: clawhk.node.dev.cm
|
||||||
|
node_hostname: clawhk
|
||||||
|
node_region: cn-hk
|
||||||
|
clawjp:
|
||||||
|
ansible_host: clawjp.node.dev.cm
|
||||||
|
node_hostname: clawjp
|
||||||
|
node_region: jp-tyo
|
||||||
|
orajpa:
|
||||||
|
ansible_host: orajpa.node.dev.cm
|
||||||
|
node_hostname: orajpa
|
||||||
|
node_region: jp-tyo
|
||||||
|
orakra:
|
||||||
|
ansible_host: orakra.node.dev.cm
|
||||||
|
node_hostname: orakra
|
||||||
|
node_region: kr-sel
|
||||||
|
orasga:
|
||||||
|
ansible_host: orasga.node.dev.cm
|
||||||
|
node_hostname: orasga
|
||||||
|
node_region: sg-sg
|
||||||
|
# 以下为内网节点 需要手动先配置好vpn才能访问
|
||||||
|
homea:
|
||||||
|
ansible_host: homea
|
||||||
|
node_hostname: homea
|
||||||
|
node_region: cn-sh
|
||||||
|
use_mirror: true
|
||||||
|
homeb:
|
||||||
|
ansible_host: homeb
|
||||||
|
node_hostname: homeb
|
||||||
|
node_region: cn-sh
|
||||||
|
use_mirror: true
|
||||||
|
|
||||||
|
# 节点分组
|
||||||
|
k3s_cluster:
|
||||||
|
children:
|
||||||
|
masters:
|
||||||
|
agents:
|
||||||
|
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
# K3s 集群安装 Playbook
|
||||||
|
---
|
||||||
|
# ============================================
|
||||||
|
# 阶段 0: 提前检测 检测环境变量和 SSH 端口
|
||||||
|
# ============================================
|
||||||
|
- name: Pre-check Environment and SSH Port
|
||||||
|
hosts: k3s_cluster
|
||||||
|
gather_facts: false
|
||||||
|
tags: [always]
|
||||||
|
tasks:
|
||||||
|
# 环境验证 (run_once 确保只执行一次)
|
||||||
|
- name: Check TAILSCALE_AUTH_KEY
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: "请设置: export TAILSCALE_AUTH_KEY='tskey-auth-xxx'"
|
||||||
|
when: lookup('env', 'TAILSCALE_AUTH_KEY') | length == 0
|
||||||
|
run_once: true
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Check SSH credentials
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: |
|
||||||
|
{% if lookup('env', 'SSH_PASSWORD') | length > 0 %}
|
||||||
|
✓ 优先使用密码登录
|
||||||
|
{% else %}
|
||||||
|
✓ 使用密钥登录
|
||||||
|
{% endif %}
|
||||||
|
run_once: true
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
# SSH 端口探测
|
||||||
|
- name: Try new SSH port ({{ ssh_new_port }})
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
host: "{{ ansible_host }}"
|
||||||
|
port: "{{ ssh_new_port }}"
|
||||||
|
timeout: 3
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
register: new_port_check
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Set SSH port based on availability
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
ansible_port: "{{ ssh_new_port if new_port_check is succeeded else 22 }}"
|
||||||
|
|
||||||
|
- name: Display detected SSH port
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ inventory_hostname }}: 使用端口 {{ ansible_port }}"
|
||||||
|
when: ansible_verbosity > 0
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# 阶段 1: SSH 安全加固 (可选,首次安装时使用)
|
||||||
|
# ============================================
|
||||||
|
- name: SSH Security Hardening
|
||||||
|
hosts: k3s_cluster
|
||||||
|
gather_facts: false
|
||||||
|
tags: [ssh, never]
|
||||||
|
roles:
|
||||||
|
- ssh
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# 阶段 2: 基础配置
|
||||||
|
# ============================================
|
||||||
|
- name: Common Setup
|
||||||
|
hosts: k3s_cluster
|
||||||
|
gather_facts: true
|
||||||
|
tags: [common]
|
||||||
|
roles:
|
||||||
|
- common
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# 阶段 3: 安装 K3s (按顺序: init -> masters -> agents)
|
||||||
|
# ============================================
|
||||||
|
- name: Install K3s on init node
|
||||||
|
hosts: masters
|
||||||
|
gather_facts: true
|
||||||
|
serial: 1
|
||||||
|
tags: [k3s]
|
||||||
|
roles:
|
||||||
|
- role: k3s
|
||||||
|
when: cluster_init | default(false)
|
||||||
|
|
||||||
|
- name: Fetch K3S_TOKEN & K3S_SERVER_URL from init node
|
||||||
|
hosts: k3s_cluster
|
||||||
|
gather_facts: false
|
||||||
|
run_once: true
|
||||||
|
tags: [k3s]
|
||||||
|
tasks:
|
||||||
|
- name: Find init node
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
init_node: "{{ item }}"
|
||||||
|
loop: "{{ groups['masters'] }}"
|
||||||
|
when: hostvars[item].cluster_init | default(false)
|
||||||
|
|
||||||
|
- name: Detect init node SSH port
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
host: "{{ hostvars[init_node].ansible_host }}"
|
||||||
|
port: "{{ ssh_new_port }}"
|
||||||
|
timeout: 3
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
register: init_node_port_check
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Set init node SSH port
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
init_node_port: "{{ ssh_new_port if init_node_port_check is succeeded else 22 }}"
|
||||||
|
|
||||||
|
- name: Read K3S_TOKEN from init node
|
||||||
|
ansible.builtin.slurp:
|
||||||
|
src: /var/lib/rancher/k3s/server/node-token
|
||||||
|
register: k3s_token_content
|
||||||
|
delegate_to: "{{ init_node }}"
|
||||||
|
vars:
|
||||||
|
ansible_port: "{{ hostvars[inventory_hostname].init_node_port }}"
|
||||||
|
|
||||||
|
- name: Determine K3S_SERVER_URL
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
# 优先使用 HA_SERVER_URL 环境变量,否则使用 init 节点地址
|
||||||
|
k3s_server_url: "{{ ha_server_url if (ha_server_url | length > 0) else 'https://' + hostvars[init_node].ansible_host + ':6443' }}"
|
||||||
|
|
||||||
|
- name: Set K3S_TOKEN and K3S_SERVER_URL for target hosts
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
k3s_token: "{{ k3s_token_content.content | b64decode | trim }}"
|
||||||
|
k3s_server_url: "{{ k3s_server_url }}"
|
||||||
|
delegate_to: "{{ item }}"
|
||||||
|
delegate_facts: true
|
||||||
|
loop: "{{ ansible_play_hosts }}"
|
||||||
|
|
||||||
|
- name: Install K3s on other masters
|
||||||
|
hosts: masters
|
||||||
|
gather_facts: true
|
||||||
|
serial: 1
|
||||||
|
tags: [k3s]
|
||||||
|
roles:
|
||||||
|
- role: k3s
|
||||||
|
when: not (cluster_init | default(false))
|
||||||
|
|
||||||
|
- name: Install K3s on agents
|
||||||
|
hosts: agents
|
||||||
|
gather_facts: true
|
||||||
|
tags: [k3s]
|
||||||
|
roles:
|
||||||
|
- k3s
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# 阶段 4: 显示集群状态
|
||||||
|
# ============================================
|
||||||
|
- name: Show cluster status
|
||||||
|
hosts: masters
|
||||||
|
gather_facts: false
|
||||||
|
tags: [status]
|
||||||
|
run_once: true
|
||||||
|
tasks:
|
||||||
|
- name: Get nodes
|
||||||
|
ansible.builtin.command: kubectl get nodes -o wide
|
||||||
|
environment:
|
||||||
|
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
|
||||||
|
register: nodes
|
||||||
|
changed_when: false
|
||||||
|
when: cluster_init | default(false)
|
||||||
|
|
||||||
|
- name: Display nodes
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: |
|
||||||
|
══════════════════════════════════════════════════════════════
|
||||||
|
K3s 集群节点:
|
||||||
|
{{ nodes.stdout }}
|
||||||
|
══════════════════════════════════════════════════════════════
|
||||||
|
when: cluster_init | default(false)
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
- name: Apply sysctl
|
||||||
|
ansible.builtin.command: sysctl --system
|
||||||
|
changed_when: true
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
# 基础配置 Role
|
||||||
|
# 功能: hostname、sysctl、Tailscale 安装
|
||||||
|
---
|
||||||
|
- name: Set hostname
|
||||||
|
ansible.builtin.hostname:
|
||||||
|
name: "{{ node_hostname }}"
|
||||||
|
when: node_hostname is defined
|
||||||
|
|
||||||
|
- name: Update /etc/hosts
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/hosts
|
||||||
|
regexp: '^127\.0\.1\.1'
|
||||||
|
line: "127.0.1.1 {{ node_hostname }}"
|
||||||
|
when: node_hostname is defined
|
||||||
|
|
||||||
|
- name: Configure sysctl for IP forwarding
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /etc/sysctl.d/99-k3s.conf
|
||||||
|
content: |
|
||||||
|
net.ipv4.ip_forward = 1
|
||||||
|
net.ipv6.conf.all.forwarding = 1
|
||||||
|
mode: "0644"
|
||||||
|
notify: Apply sysctl
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- curl
|
||||||
|
- wget
|
||||||
|
- ca-certificates
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Check if Tailscale is installed
|
||||||
|
ansible.builtin.command: which tailscale
|
||||||
|
register: common_tailscale_check
|
||||||
|
failed_when: false
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Download Tailscale install script
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: https://tailscale.com/install.sh
|
||||||
|
dest: /tmp/tailscale-install.sh
|
||||||
|
mode: "0755"
|
||||||
|
when: common_tailscale_check.rc != 0
|
||||||
|
|
||||||
|
- name: Install Tailscale
|
||||||
|
ansible.builtin.command: /tmp/tailscale-install.sh
|
||||||
|
when: common_tailscale_check.rc != 0
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Remove Tailscale install script
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /tmp/tailscale-install.sh
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Enable Tailscale service
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: tailscaled
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
# K3s 安装 Role (统一 Server 和 Agent)
|
||||||
|
---
|
||||||
|
- name: Validate TAILSCALE_AUTH_KEY
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: "请设置环境变量: export TAILSCALE_AUTH_KEY='tskey-auth-xxx'"
|
||||||
|
when: (tailscale_auth_key | default('')) | length == 0
|
||||||
|
|
||||||
|
- name: Create K3s config directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/rancher/k3s
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
# 检查安装状态
|
||||||
|
- name: Check if K3s is installed
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /usr/local/bin/k3s
|
||||||
|
register: k3s_binary
|
||||||
|
|
||||||
|
# 检查当前K3s版本
|
||||||
|
- name: Check current K3s version
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: /usr/local/bin/k3s --version
|
||||||
|
register: k3s_current_version
|
||||||
|
failed_when: false
|
||||||
|
changed_when: false
|
||||||
|
when: k3s_binary.stat.exists
|
||||||
|
|
||||||
|
# 部署配置文件(注册变更状态)
|
||||||
|
- name: Deploy K3s server config
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: k3s-server.yaml.j2
|
||||||
|
dest: /etc/rancher/k3s/config.yaml
|
||||||
|
mode: "0600"
|
||||||
|
when: "'masters' in group_names"
|
||||||
|
register: k3s_server_config
|
||||||
|
|
||||||
|
- name: Deploy K3s agent config
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: k3s-agent.yaml.j2
|
||||||
|
dest: /etc/rancher/k3s/config.yaml
|
||||||
|
mode: "0600"
|
||||||
|
when: "'agents' in group_names"
|
||||||
|
register: k3s_agent_config
|
||||||
|
|
||||||
|
- name: Deploy registries.yaml
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: registries.yaml.j2
|
||||||
|
dest: /etc/rancher/k3s/registries.yaml
|
||||||
|
mode: "0644"
|
||||||
|
when: use_mirror | default(false)
|
||||||
|
|
||||||
|
# 判断是否需要安装/重启
|
||||||
|
# 使用 -e force_reinstall=true 可强制重新安装
|
||||||
|
- name: Set K3s installation flag
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
k3s_needs_install: "{{
|
||||||
|
not k3s_binary.stat.exists or
|
||||||
|
(force_reinstall | default(false) | bool) or
|
||||||
|
(k3s_server_config.changed | default(false)) or
|
||||||
|
(k3s_agent_config.changed | default(false)) or
|
||||||
|
(k3s_binary.stat.exists and k3s_current_version.stdout is defined and k3s_version not in k3s_current_version.stdout)
|
||||||
|
}}"
|
||||||
|
|
||||||
|
# 设置安装变量
|
||||||
|
- name: Set K3s install variables
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
k3s_install_url: "{{ mirror_k3s_install_url if (use_mirror | default(false)) else global_k3s_install_url }}"
|
||||||
|
k3s_install_mirror: "{{ 'INSTALL_K3S_MIRROR=cn' if (use_mirror | default(false)) else '' }}"
|
||||||
|
|
||||||
|
|
||||||
|
# 下载安装脚本
|
||||||
|
- name: Download K3s install script
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: "{{ k3s_install_url }}"
|
||||||
|
dest: /tmp/k3s-install.sh
|
||||||
|
mode: "0755"
|
||||||
|
when: k3s_needs_install
|
||||||
|
|
||||||
|
# 安装 K3s
|
||||||
|
- name: Install K3s server
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: /tmp/k3s-install.sh server
|
||||||
|
environment:
|
||||||
|
INSTALL_K3S_VERSION: "{{ k3s_version }}"
|
||||||
|
INSTALL_K3S_MIRROR: "{{ 'cn' if (use_mirror | default(false)) else '' }}"
|
||||||
|
when:
|
||||||
|
- "'masters' in group_names"
|
||||||
|
- k3s_needs_install
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Install K3s agent
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: /tmp/k3s-install.sh agent
|
||||||
|
environment:
|
||||||
|
INSTALL_K3S_VERSION: "{{ k3s_version }}"
|
||||||
|
INSTALL_K3S_MIRROR: "{{ 'cn' if (use_mirror | default(false)) else '' }}"
|
||||||
|
when:
|
||||||
|
- "'agents' in group_names"
|
||||||
|
- k3s_needs_install
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
# 清理安装脚本
|
||||||
|
- name: Remove install script
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /tmp/k3s-install.sh
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
# 等待 K3s 就绪 (仅 Server)
|
||||||
|
- name: Wait for K3s server ready
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
path: /var/lib/rancher/k3s/server/node-token
|
||||||
|
timeout: 120
|
||||||
|
when: "'masters' in group_names"
|
||||||
|
|
||||||
|
# 保存 kubeconfig (仅 cluster-init)
|
||||||
|
- name: Fetch kubeconfig
|
||||||
|
ansible.builtin.fetch:
|
||||||
|
src: /etc/rancher/k3s/k3s.yaml
|
||||||
|
dest: "{{ playbook_dir }}/../kubeconfig.yaml"
|
||||||
|
flat: true
|
||||||
|
when: cluster_init | default(false)
|
||||||
|
|
||||||
|
- name: Update kubeconfig server address
|
||||||
|
ansible.builtin.replace:
|
||||||
|
path: "{{ playbook_dir }}/../kubeconfig.yaml"
|
||||||
|
regexp: 'server: https://127\.0\.0\.1:6443'
|
||||||
|
replace: "server: {{ k3s_server_url }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
when: cluster_init | default(false)
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# K3s Agent 配置模板
|
||||||
|
---
|
||||||
|
server: "{{ k3s_server_url }}"
|
||||||
|
token: "{{ k3s_token }}"
|
||||||
|
|
||||||
|
# Tailscale VPN
|
||||||
|
vpn-auth: "name=tailscale,joinKey={{ tailscale_auth_key }}{% if netfilter_mode | default('') %},extraArgs=--netfilter-mode={{ netfilter_mode }}{% endif %}"
|
||||||
|
|
||||||
|
# 节点标签
|
||||||
|
node-label:
|
||||||
|
{% if node_region is defined %}
|
||||||
|
- "topology.kubernetes.io/region={{ node_region }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if enable_lb is defined %}
|
||||||
|
- "svccontroller.k3s.cattle.io/enablelb={{ enable_lb | string | lower }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if node_labels is defined %}
|
||||||
|
{% for key, value in node_labels.items() %}
|
||||||
|
- "{{ key }}={{ value }}"
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# 节点污点
|
||||||
|
{% if node_taints is defined %}
|
||||||
|
node-taint:
|
||||||
|
{% for taint in node_taints %}
|
||||||
|
- "{{ taint }}"
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# Kubelet 资源预留
|
||||||
|
{% if kubelet_reserved is defined %}
|
||||||
|
kubelet-arg:
|
||||||
|
- "kube-reserved={{ kubelet_reserved }}"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# K3s Server 统一配置模板 (master-init 和 master-join)
|
||||||
|
---
|
||||||
|
{% if cluster_init | default(false) %}
|
||||||
|
# 首个节点初始化集群
|
||||||
|
cluster-init: true
|
||||||
|
{% else %}
|
||||||
|
# 加入已有集群
|
||||||
|
server: "{{ k3s_server_url }}"
|
||||||
|
token: "{{ k3s_token }}"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# TLS SAN: 包含 HA 地址 + 所有 master 节点地址
|
||||||
|
tls-san:
|
||||||
|
{% if ha_server_url | default('') | length > 0 %}
|
||||||
|
- "{{ ha_server_url | regex_replace('^https?://([^:]+)(:[0-9]+)?$', '\\1') }}"
|
||||||
|
{% endif %}
|
||||||
|
{% for host in groups['masters'] %}
|
||||||
|
- "{{ hostvars[host].ansible_host }}"
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
# ETCD 快照配置
|
||||||
|
etcd-snapshot-retention: {{ etcd_snapshot_retention }}
|
||||||
|
etcd-snapshot-schedule-cron: "{{ etcd_snapshot_schedule_cron }}"
|
||||||
|
etcd-snapshot-compress: {{ etcd_snapshot_compress | lower }}
|
||||||
|
|
||||||
|
# Tailscale VPN
|
||||||
|
vpn-auth: "name=tailscale,joinKey={{ tailscale_auth_key }}{% if netfilter_mode | default('') %},extraArgs=--netfilter-mode={{ netfilter_mode }}{% endif %}"
|
||||||
|
|
||||||
|
# 禁用组件
|
||||||
|
disable:
|
||||||
|
{% for component in k3s_disable_components %}
|
||||||
|
- {{ component }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
# 节点标签
|
||||||
|
node-label:
|
||||||
|
{% if node_region is defined %}
|
||||||
|
- "topology.kubernetes.io/region={{ node_region }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if enable_lb is defined %}
|
||||||
|
- "svccontroller.k3s.cattle.io/enablelb={{ enable_lb | string | lower }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if node_labels is defined %}
|
||||||
|
{% for key, value in node_labels.items() %}
|
||||||
|
- "{{ key }}={{ value }}"
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# 节点污点
|
||||||
|
{% if node_taints is defined %}
|
||||||
|
node-taint:
|
||||||
|
{% for taint in node_taints %}
|
||||||
|
- "{{ taint }}"
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# 镜像加速配置
|
||||||
|
---
|
||||||
|
mirrors:
|
||||||
|
{% for registry, endpoints in registry_mirrors.items() %}
|
||||||
|
"{{ registry }}":
|
||||||
|
endpoint:
|
||||||
|
{% for endpoint in endpoints %}
|
||||||
|
- "https://{{ endpoint }}"
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
- name: Restart sshd
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: sshd
|
||||||
|
state: restarted
|
||||||
|
listen: Restart sshd
|
||||||
|
|
||||||
|
- name: Update ansible port
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
ansible_port: "{{ ssh_new_port }}"
|
||||||
|
listen: Update ansible port
|
||||||
|
|
||||||
|
- name: Wait for new SSH port
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
port: "{{ ssh_new_port }}"
|
||||||
|
host: "{{ ansible_host }}"
|
||||||
|
delay: 5
|
||||||
|
timeout: 60
|
||||||
|
delegate_to: localhost
|
||||||
|
become: false
|
||||||
|
listen: Wait for new SSH port
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# SSH 安全加固 Role
|
||||||
|
# 功能: 修改端口、配置密钥认证、禁用密码登录
|
||||||
|
---
|
||||||
|
- name: Ensure .ssh directory exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /root/.ssh
|
||||||
|
state: directory
|
||||||
|
mode: "0700"
|
||||||
|
|
||||||
|
- name: Add SSH public key
|
||||||
|
ansible.builtin.authorized_key:
|
||||||
|
user: root
|
||||||
|
key: "{{ ssh_pubkey }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Backup original sshd_config
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: /etc/ssh/sshd_config
|
||||||
|
dest: /etc/ssh/sshd_config.bak
|
||||||
|
remote_src: true
|
||||||
|
force: false
|
||||||
|
mode: "0600"
|
||||||
|
|
||||||
|
- name: Deploy secure sshd_config
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: sshd_config.j2
|
||||||
|
dest: /etc/ssh/sshd_config
|
||||||
|
mode: "0600"
|
||||||
|
validate: "/usr/sbin/sshd -t -f %s"
|
||||||
|
notify:
|
||||||
|
- Restart sshd
|
||||||
|
- Update ansible port
|
||||||
|
- Wait for new SSH port
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# SSH 配置模板
|
||||||
|
Port {{ ssh_new_port }}
|
||||||
|
PermitRootLogin prohibit-password
|
||||||
|
PasswordAuthentication no
|
||||||
|
PubkeyAuthentication yes
|
||||||
|
ChallengeResponseAuthentication no
|
||||||
|
UsePAM yes
|
||||||
|
X11Forwarding no
|
||||||
|
PrintMotd no
|
||||||
|
AcceptEnv LANG LC_*
|
||||||
|
Subsystem sftp /usr/lib/openssh/sftp-server
|
||||||
|
|
||||||
-70
@@ -1,70 +0,0 @@
|
|||||||
### apps
|
|
||||||
|
|
||||||
应用部署方法
|
|
||||||
|
|
||||||
```shell
|
|
||||||
kubectl apply -f apps/xxx -R
|
|
||||||
```
|
|
||||||
|
|
||||||
举例:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
kubectl apply -f apps/infra/data/redis -R
|
|
||||||
```
|
|
||||||
|
|
||||||
你可以一次性将所有的应用部署到k8s集群中 但是此处建议分开部署 每个文件夹单独执行 以保证不会出现错误与性能问题
|
|
||||||
|
|
||||||
注意!! 在部署前你需要替换yaml中的YOU_SHOULD_MODIFY_THIS_ 开头的字段 替换为自己的值 这些值的来源部分是自己生成的、部分是需要你自己去申请的
|
|
||||||
|
|
||||||
比如说你需要去华为云申请一个access key id和secret key 还有一个bucket name 这些值需要你自己去申请
|
|
||||||
|
|
||||||
### 应用说明
|
|
||||||
|
|
||||||
./kube文件夹下的请全部执行 此文件架内部为集群优化相关内容 例如dns延迟优化
|
|
||||||
(patch-affinity.yaml 按需 仅在你想让k3s自带的system服务使用特定节点时使用 比如保留核心服务停留在高可用节点上)
|
|
||||||
|
|
||||||
- infra-net: 网络相关的应用
|
|
||||||
- nginx: 负载均衡服务 替换集群默认的ingress(traefik)
|
|
||||||
- crowdsec: 安全防护服务
|
|
||||||
- tailscale: 集群内网加速服务 如果对集群内网加速没有需求 可以不安装
|
|
||||||
- infra-data: 数据存储相关的应用
|
|
||||||
- redis: redis服务
|
|
||||||
- postgresql-ha: postgresql服务
|
|
||||||
- cloudnative: postgresql服务 操作符版本 推荐
|
|
||||||
- infra-devops: devops相关的应用
|
|
||||||
- gitea: git托管服务
|
|
||||||
- cert-manager: 证书管理服务
|
|
||||||
- reflector: 密钥同步服务
|
|
||||||
- velero: 备份服务
|
|
||||||
- infra-monitor: 监控相关的应用
|
|
||||||
- prometheus: 监控服务
|
|
||||||
- loki: 日志服务
|
|
||||||
- apps: 其他应用 个人应用部分
|
|
||||||
- whoami: 测试服务
|
|
||||||
|
|
||||||
### 调试集群内服务方法 运行此命令
|
|
||||||
|
|
||||||
```shell
|
|
||||||
kubectl run -i --tty --rm --restart=Never \
|
|
||||||
--overrides='{"apiVersion": "v1", "spec": {"nodeSelector": {"kubernetes.io/hostname": "homea"}}}' \
|
|
||||||
--image=nicolaka/netshoot:latest \
|
|
||||||
debug -- sh
|
|
||||||
```
|
|
||||||
|
|
||||||
### 密钥相关
|
|
||||||
|
|
||||||
可以将helm部署中使用到的密钥放到k8s的secret中
|
|
||||||
然后使用reflector将secret中的密钥同步到其他namespace中
|
|
||||||
|
|
||||||
```shell
|
|
||||||
kubectl -n infra-devops create secret generic s3-devcm-hw \
|
|
||||||
--from-literal=ACCESS_KEY_ID=xxxxx \
|
|
||||||
--from-literal=ACCESS_SECRET_KEY=xxxxx
|
|
||||||
|
|
||||||
kubectl -n infra-devops annotate secret s3-devcm-hw \
|
|
||||||
reflector.v1.k8s.emberstack.com/reflection-allowed=true \
|
|
||||||
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces=infra-data \
|
|
||||||
reflector.v1.k8s.emberstack.com/reflection-auto-enabled=true \
|
|
||||||
reflector.v1.k8s.emberstack.com/reflection-auto-namespace=infra-data --overwrite
|
|
||||||
|
|
||||||
```
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
apiVersion: postgresql.cnpg.io/v1
|
|
||||||
kind: Cluster
|
|
||||||
metadata:
|
|
||||||
name: cnpg17-cluster-hk
|
|
||||||
namespace: infra-data
|
|
||||||
spec:
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
preferredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
- preference:
|
|
||||||
matchExpressions:
|
|
||||||
- key: topology.kubernetes.io/region
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- cn-hk
|
|
||||||
weight: 1
|
|
||||||
instances: 1
|
|
||||||
imageName: ghcr.io/cloudnative-pg/postgresql:17.4
|
|
||||||
enableSuperuserAccess: true
|
|
||||||
storage:
|
|
||||||
size: 10Gi
|
|
||||||
postgresql:
|
|
||||||
parameters:
|
|
||||||
archive_timeout: 30min
|
|
||||||
backup:
|
|
||||||
retentionPolicy: "7d"
|
|
||||||
barmanObjectStore:
|
|
||||||
destinationPath: s3://devcm/cnpg/
|
|
||||||
endpointURL: https://obs.cn-east-3.myhuaweicloud.com
|
|
||||||
s3Credentials:
|
|
||||||
accessKeyId:
|
|
||||||
name: s3-devcm-hw
|
|
||||||
key: ACCESS_KEY_ID
|
|
||||||
secretAccessKey:
|
|
||||||
name: s3-devcm-hw
|
|
||||||
key: ACCESS_SECRET_KEY
|
|
||||||
wal:
|
|
||||||
compression: gzip
|
|
||||||
|
|
||||||
---
|
|
||||||
apiVersion: postgresql.cnpg.io/v1
|
|
||||||
kind: ScheduledBackup
|
|
||||||
metadata:
|
|
||||||
name: cnpg17-cluster-hk-backups
|
|
||||||
namespace: infra-data
|
|
||||||
spec:
|
|
||||||
schedule: "0 0 0 * * *"
|
|
||||||
immediate: true
|
|
||||||
backupOwnerReference: self
|
|
||||||
cluster:
|
|
||||||
name: cnpg17-cluster-hk
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
apiVersion: postgresql.cnpg.io/v1
|
|
||||||
kind: Cluster
|
|
||||||
metadata:
|
|
||||||
name: cnpg17-cluster-sh
|
|
||||||
namespace: infra-data
|
|
||||||
spec:
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
preferredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
- preference:
|
|
||||||
matchExpressions:
|
|
||||||
- key: topology.kubernetes.io/region
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- cn-sh
|
|
||||||
weight: 1
|
|
||||||
instances: 1
|
|
||||||
imageName: ghcr.io/cloudnative-pg/postgresql:17.4
|
|
||||||
enableSuperuserAccess: true
|
|
||||||
storage:
|
|
||||||
size: 10Gi
|
|
||||||
postgresql:
|
|
||||||
parameters:
|
|
||||||
archive_timeout: 30min
|
|
||||||
backup:
|
|
||||||
retentionPolicy: "7d"
|
|
||||||
barmanObjectStore:
|
|
||||||
destinationPath: s3://devcm/cnpg/
|
|
||||||
endpointURL: https://obs.cn-east-3.myhuaweicloud.com
|
|
||||||
s3Credentials:
|
|
||||||
accessKeyId:
|
|
||||||
name: s3-devcm-hw
|
|
||||||
key: ACCESS_KEY_ID
|
|
||||||
secretAccessKey:
|
|
||||||
name: s3-devcm-hw
|
|
||||||
key: ACCESS_SECRET_KEY
|
|
||||||
wal:
|
|
||||||
compression: gzip
|
|
||||||
|
|
||||||
---
|
|
||||||
apiVersion: postgresql.cnpg.io/v1
|
|
||||||
kind: ScheduledBackup
|
|
||||||
metadata:
|
|
||||||
name: cnpg17-cluster-sh-backups
|
|
||||||
namespace: infra-data
|
|
||||||
spec:
|
|
||||||
schedule: "0 0 0 * * *"
|
|
||||||
immediate: true
|
|
||||||
backupOwnerReference: self
|
|
||||||
cluster:
|
|
||||||
name: cnpg17-cluster-sh
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
|
||||||
kind: HelmChart
|
|
||||||
metadata:
|
|
||||||
name: cloudnative-pg
|
|
||||||
namespace: infra-data
|
|
||||||
spec:
|
|
||||||
repo: https://cloudnative-pg.github.io/charts
|
|
||||||
chart: cloudnative-pg
|
|
||||||
targetNamespace: infra-data
|
|
||||||
version: 0.25.0
|
|
||||||
valuesContent: |-
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
requiredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
nodeSelectorTerms:
|
|
||||||
- matchExpressions:
|
|
||||||
- key: topology.kubernetes.io/region
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- "cn-sh"
|
|
||||||
tolerations:
|
|
||||||
- key: "node-role.kubernetes.io/control-plane"
|
|
||||||
operator: "Exists"
|
|
||||||
effect: "NoSchedule"
|
|
||||||
image:
|
|
||||||
tag: "1.25.3"
|
|
||||||
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
|
||||||
kind: HelmChart
|
|
||||||
metadata:
|
|
||||||
name: redis-cluster-sh
|
|
||||||
namespace: infra-data
|
|
||||||
spec:
|
|
||||||
chart: oci://registry-1.docker.io/bitnamicharts/redis
|
|
||||||
targetNamespace: infra-data
|
|
||||||
version: 20.7.0
|
|
||||||
valuesContent: |-
|
|
||||||
global:
|
|
||||||
redis:
|
|
||||||
password: ribiPwYQNU6GWxCYR0Nj
|
|
||||||
master:
|
|
||||||
nodeAffinityPreset:
|
|
||||||
type: soft
|
|
||||||
key: topology.kubernetes.io/region
|
|
||||||
values:
|
|
||||||
- cn-sh
|
|
||||||
replica:
|
|
||||||
replicaCount: 0
|
|
||||||
nodeAffinityPreset:
|
|
||||||
type: soft
|
|
||||||
key: topology.kubernetes.io/region
|
|
||||||
values:
|
|
||||||
- cn-sh
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
# 安装后需要将clusterIssuer的cnameStrategy策略设置为Follow
|
|
||||||
apiVersion: helm.cattle.io/v1
|
|
||||||
kind: HelmChart
|
|
||||||
metadata:
|
|
||||||
name: cert-manager-webhook-dnspod
|
|
||||||
namespace: infra-devops
|
|
||||||
spec:
|
|
||||||
chart: oci://registry-1.docker.io/imroc/cert-manager-webhook-dnspod
|
|
||||||
targetNamespace: infra-devops
|
|
||||||
version: 1.4.5
|
|
||||||
valuesContent: |-
|
|
||||||
namespace: infra-devops
|
|
||||||
certManager:
|
|
||||||
namespace: infra-devops
|
|
||||||
groupName: cert.dev.cm
|
|
||||||
clusterIssuer:
|
|
||||||
# 此处需在部署后修改clusterIssuer 添加在dns01下
|
|
||||||
# cnameStrategy: Follow
|
|
||||||
staging: false
|
|
||||||
email: [email protected]
|
|
||||||
secretId: AKIDzmKdvDSfonogKip55pIVR6h7ScjaBWcg
|
|
||||||
secretKey: zudDdtytkPr8HI9oKeniSxIRPCmCe0CD
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
requiredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
nodeSelectorTerms:
|
|
||||||
- matchExpressions:
|
|
||||||
- key: topology.kubernetes.io/region
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- "cn-sh"
|
|
||||||
tolerations:
|
|
||||||
- key: "node-role.kubernetes.io/control-plane"
|
|
||||||
operator: "Exists"
|
|
||||||
effect: "NoSchedule"
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
# 需要提前安装crds
|
|
||||||
# kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.18.2/cert-manager.crds.yaml
|
|
||||||
apiVersion: helm.cattle.io/v1
|
|
||||||
kind: HelmChart
|
|
||||||
metadata:
|
|
||||||
name: cert-manager
|
|
||||||
namespace: infra-devops
|
|
||||||
spec:
|
|
||||||
repo: https://charts.jetstack.io
|
|
||||||
chart: cert-manager
|
|
||||||
targetNamespace: infra-devops
|
|
||||||
version: v1.19.2
|
|
||||||
valuesContent: |-
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
requiredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
nodeSelectorTerms:
|
|
||||||
- matchExpressions:
|
|
||||||
- key: topology.kubernetes.io/region
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- "cn-sh"
|
|
||||||
tolerations:
|
|
||||||
- key: "node-role.kubernetes.io/control-plane"
|
|
||||||
operator: "Exists"
|
|
||||||
effect: "NoSchedule"
|
|
||||||
webhook:
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
requiredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
nodeSelectorTerms:
|
|
||||||
- matchExpressions:
|
|
||||||
- key: topology.kubernetes.io/region
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- "cn-sh"
|
|
||||||
tolerations:
|
|
||||||
- key: "node-role.kubernetes.io/control-plane"
|
|
||||||
operator: "Exists"
|
|
||||||
effect: "NoSchedule"
|
|
||||||
cainjector:
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
requiredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
nodeSelectorTerms:
|
|
||||||
- matchExpressions:
|
|
||||||
- key: topology.kubernetes.io/region
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- "cn-sh"
|
|
||||||
tolerations:
|
|
||||||
- key: "node-role.kubernetes.io/control-plane"
|
|
||||||
operator: "Exists"
|
|
||||||
effect: "NoSchedule"
|
|
||||||
# 在删除证书时同时删除secret
|
|
||||||
enableCertificateOwnerRef: true
|
|
||||||
prometheus:
|
|
||||||
enabled: true
|
|
||||||
servicemonitor:
|
|
||||||
enabled: true
|
|
||||||
interval: 300s
|
|
||||||
prometheusInstance: kube-prometheus
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
apiVersion: fluxcd.controlplane.io/v1
|
|
||||||
kind: FluxInstance
|
|
||||||
metadata:
|
|
||||||
name: flux
|
|
||||||
namespace: flux-system
|
|
||||||
spec:
|
|
||||||
distribution:
|
|
||||||
version: "2.x"
|
|
||||||
registry: "ghcr.io/fluxcd"
|
|
||||||
artifact: "oci://ghcr.io/controlplaneio-fluxcd/flux-operator-manifests"
|
|
||||||
components:
|
|
||||||
- source-controller
|
|
||||||
- source-watcher
|
|
||||||
- kustomize-controller
|
|
||||||
- helm-controller
|
|
||||||
- notification-controller
|
|
||||||
cluster:
|
|
||||||
type: kubernetes
|
|
||||||
size: small
|
|
||||||
multitenant: false
|
|
||||||
networkPolicy: true
|
|
||||||
domain: "cluster.local"
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
|
||||||
kind: HelmChart
|
|
||||||
metadata:
|
|
||||||
name: reflector
|
|
||||||
namespace: infra-devops
|
|
||||||
spec:
|
|
||||||
repo: https://emberstack.github.io/helm-charts
|
|
||||||
chart: reflector
|
|
||||||
targetNamespace: infra-devops
|
|
||||||
version: 9.1.45
|
|
||||||
valuesContent: |-
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
requiredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
nodeSelectorTerms:
|
|
||||||
- matchExpressions:
|
|
||||||
- key: topology.kubernetes.io/region
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- "cn-sh"
|
|
||||||
preferredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
- weight: 1
|
|
||||||
preference:
|
|
||||||
matchExpressions:
|
|
||||||
- key: kubernetes.io/hostname
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- tce
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
|
||||||
kind: HelmChart
|
|
||||||
metadata:
|
|
||||||
name: velero
|
|
||||||
namespace: infra-devops
|
|
||||||
spec:
|
|
||||||
repo: https://vmware-tanzu.github.io/helm-charts
|
|
||||||
chart: velero
|
|
||||||
targetNamespace: infra-devops
|
|
||||||
version: 11.3.2
|
|
||||||
valuesContent: |-
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
requiredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
nodeSelectorTerms:
|
|
||||||
- matchExpressions:
|
|
||||||
- key: topology.kubernetes.io/region
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- "cn-sh"
|
|
||||||
preferredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
- weight: 1
|
|
||||||
preference:
|
|
||||||
matchExpressions:
|
|
||||||
- key: kubernetes.io/hostname
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- homea
|
|
||||||
deployNodeAgent: true
|
|
||||||
snapshotsEnabled: false
|
|
||||||
configuration:
|
|
||||||
backupSyncPeriod: 1h0m0s
|
|
||||||
defaultRepoMaintainFrequency: 3h0m0s
|
|
||||||
repositoryMaintenanceJob:
|
|
||||||
repositoryConfigData:
|
|
||||||
global:
|
|
||||||
keepLatestMaintenanceJobs: 1
|
|
||||||
backupStorageLocation:
|
|
||||||
- name: devcm-hw
|
|
||||||
default: true
|
|
||||||
provider: aws
|
|
||||||
bucket: devcm
|
|
||||||
prefix: velero
|
|
||||||
config:
|
|
||||||
region: cn-east-3
|
|
||||||
s3ForcePathStyle: false
|
|
||||||
s3Url: https://obs.cn-east-3.myhuaweicloud.com
|
|
||||||
checksumAlgorithm: ""
|
|
||||||
credentials:
|
|
||||||
useSecret: true
|
|
||||||
secretContents:
|
|
||||||
cloud: |
|
|
||||||
[default]
|
|
||||||
aws_access_key_id = A9RI5BC15F3L9EI8T51T
|
|
||||||
aws_secret_access_key = ky1n3OlNNu7wjgctVjCqb03HWxjZucRGhvcEBp51
|
|
||||||
initContainers:
|
|
||||||
- name: velero-plugin-for-aws
|
|
||||||
image: velero/velero-plugin-for-aws:v1.13.0
|
|
||||||
volumeMounts:
|
|
||||||
- mountPath: /target
|
|
||||||
name: plugins
|
|
||||||
nodeAgent:
|
|
||||||
nodeSelector:
|
|
||||||
backup.velero.io/enable: "true"
|
|
||||||
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# 更新 ConfigMap 中的静态文件
|
|
||||||
cat > configmap-static.yaml << 'EOF'
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: static
|
|
||||||
namespace: infra-net
|
|
||||||
data:
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# 直接遍历 static 目录并追加到文件
|
|
||||||
for file in static/*; do
|
|
||||||
filename=$(basename "$file")
|
|
||||||
echo " $filename: |" >> configmap-static.yaml
|
|
||||||
sed 's/^/ /' "$file" >> configmap-static.yaml
|
|
||||||
echo "" >> configmap-static.yaml
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "ConfigMap updated successfully!"
|
|
||||||
@@ -1,302 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta content="width=device-width,initial-scale=1,user-scalable=no,viewport-fit=cover" name="viewport">
|
|
||||||
<title>出于安全原因 请完成验证</title>
|
|
||||||
<script src="{{captcha_frontend_js}}" async defer></script>
|
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
padding: 0;
|
|
||||||
margin: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#error {
|
|
||||||
position: relative;
|
|
||||||
height: 100vh
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error {
|
|
||||||
position: absolute;
|
|
||||||
left: 50%;
|
|
||||||
top: 50%;
|
|
||||||
-webkit-transform: translate(-50%, -50%);
|
|
||||||
-ms-transform: translate(-50%, -50%);
|
|
||||||
transform: translate(-50%, -50%)
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error-bg {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
overflow: hidden
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error-bg > div {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: 1px;
|
|
||||||
background-color: #eee
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error-bg > div:nth-child(1) {
|
|
||||||
left: 20%
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error-bg > div:nth-child(2) {
|
|
||||||
left: 40%
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error-bg > div:nth-child(3) {
|
|
||||||
left: 60%
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error-bg > div:nth-child(4) {
|
|
||||||
left: 80%
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error-bg > div:after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: -.5px;
|
|
||||||
-webkit-transform: translateY(-160px);
|
|
||||||
-ms-transform: translateY(-160px);
|
|
||||||
transform: translateY(-160px);
|
|
||||||
height: 160px;
|
|
||||||
width: 2px;
|
|
||||||
background-color: #1cfafe
|
|
||||||
}
|
|
||||||
|
|
||||||
@-webkit-keyframes drop {
|
|
||||||
90% {
|
|
||||||
height: 20px
|
|
||||||
}
|
|
||||||
|
|
||||||
100% {
|
|
||||||
height: 160px;
|
|
||||||
-webkit-transform: translateY(calc(100vh + 160px));
|
|
||||||
transform: translateY(calc(100vh + 160px))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes drop {
|
|
||||||
90% {
|
|
||||||
height: 20px
|
|
||||||
}
|
|
||||||
|
|
||||||
100% {
|
|
||||||
height: 160px;
|
|
||||||
-webkit-transform: translateY(calc(100vh + 160px));
|
|
||||||
transform: translateY(calc(100vh + 160px))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error-bg > div:nth-child(1):after {
|
|
||||||
-webkit-animation: drop 3s infinite linear;
|
|
||||||
animation: drop 3s infinite linear;
|
|
||||||
-webkit-animation-delay: .2s;
|
|
||||||
animation-delay: .2s
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error-bg > div:nth-child(2):after {
|
|
||||||
-webkit-animation: drop 2s infinite linear;
|
|
||||||
animation: drop 2s infinite linear;
|
|
||||||
-webkit-animation-delay: .7s;
|
|
||||||
animation-delay: .7s
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error-bg > div:nth-child(3):after {
|
|
||||||
-webkit-animation: drop 3s infinite linear;
|
|
||||||
animation: drop 3s infinite linear;
|
|
||||||
-webkit-animation-delay: .9s;
|
|
||||||
animation-delay: .9s
|
|
||||||
}
|
|
||||||
|
|
||||||
#error .error-bg > div:nth-child(4):after {
|
|
||||||
-webkit-animation: drop 2s infinite linear;
|
|
||||||
animation: drop 2s infinite linear;
|
|
||||||
-webkit-animation-delay: 1.2s;
|
|
||||||
animation-delay: 1.2s
|
|
||||||
}
|
|
||||||
|
|
||||||
.error {
|
|
||||||
max-width: 520px;
|
|
||||||
width: 100%;
|
|
||||||
padding: 20px;
|
|
||||||
text-align: center
|
|
||||||
}
|
|
||||||
|
|
||||||
.error .error-code {
|
|
||||||
height: 210px;
|
|
||||||
line-height: 210px
|
|
||||||
}
|
|
||||||
|
|
||||||
.error .error-code h1 {
|
|
||||||
font-family: oswald, sans-serif;
|
|
||||||
font-size: 80px;
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 0;
|
|
||||||
text-shadow: 4px 4px 0 #1cfafe
|
|
||||||
}
|
|
||||||
|
|
||||||
.error h2 {
|
|
||||||
font-family: oswald, sans-serif;
|
|
||||||
font-size: 42px;
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 0;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 1.6px
|
|
||||||
}
|
|
||||||
|
|
||||||
.error p {
|
|
||||||
font-family: lato, sans-serif;
|
|
||||||
color: #000;
|
|
||||||
font-weight: 400;
|
|
||||||
margin-top: 20px;
|
|
||||||
margin-bottom: 25px
|
|
||||||
}
|
|
||||||
|
|
||||||
.error a {
|
|
||||||
font-family: lato, sans-serif;
|
|
||||||
padding: 10px 30px;
|
|
||||||
display: inline-block;
|
|
||||||
color: #000;
|
|
||||||
font-weight: 400;
|
|
||||||
text-transform: uppercase;
|
|
||||||
-webkit-box-shadow: 0 0 0 2px #000, 2px 2px 0 2px #1cfafe;
|
|
||||||
box-shadow: 0 0 0 2px #000, 2px 2px 0 2px #1cfafe;
|
|
||||||
text-decoration: none;
|
|
||||||
-webkit-transition: .2s all;
|
|
||||||
transition: .2s all
|
|
||||||
}
|
|
||||||
|
|
||||||
.error a:not(:first-of-type) {
|
|
||||||
margin-left: 20px
|
|
||||||
}
|
|
||||||
|
|
||||||
.error a:hover {
|
|
||||||
background-color: #1cfafe;
|
|
||||||
-webkit-box-shadow: 0 0 0 0 #000, 0 0 0 2px #1cfafe;
|
|
||||||
box-shadow: 0 0 0 0 #000, 0 0 0 2px #1cfafe
|
|
||||||
}
|
|
||||||
|
|
||||||
.error-social > a {
|
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
line-height: 40px;
|
|
||||||
padding: 0;
|
|
||||||
margin: 0 5px
|
|
||||||
}
|
|
||||||
|
|
||||||
.error-social > a:hover {
|
|
||||||
background-color: #1cfafe;
|
|
||||||
-webkit-box-shadow: 0 0 0 0 #000, 0 0 0 2px #1cfafe;
|
|
||||||
box-shadow: 0 0 0 0 #000, 0 0 0 2px #1cfafe
|
|
||||||
}
|
|
||||||
|
|
||||||
#captcha-form {
|
|
||||||
position: relative;
|
|
||||||
width: 300px;
|
|
||||||
height: 65px;
|
|
||||||
overflow: hidden;
|
|
||||||
margin: 0 auto 30px;
|
|
||||||
background-color: #fff;
|
|
||||||
-webkit-box-shadow: 0 0 0 2px #000, 2px 2px 0 2px #1cfafe;
|
|
||||||
box-shadow: 0 0 0 2px #000, 2px 2px 0 2px #1cfafe;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
z-index: 1;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 65px;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading:has(+ *) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading::before {
|
|
||||||
content: "";
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
border: 2px solid #000;
|
|
||||||
border-right-color: #1cfafe;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: spin 1s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
#captcha {
|
|
||||||
position: relative;
|
|
||||||
z-index: 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes spin {
|
|
||||||
from {
|
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (max-width: 480px) {
|
|
||||||
.error .error-code {
|
|
||||||
height: 122px;
|
|
||||||
line-height: 122px
|
|
||||||
}
|
|
||||||
|
|
||||||
.error .error-code h1 {
|
|
||||||
font-size: 60px
|
|
||||||
}
|
|
||||||
|
|
||||||
.error h2 {
|
|
||||||
font-size: 26px
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="error">
|
|
||||||
<div class="error-bg">
|
|
||||||
<div></div>
|
|
||||||
<div></div>
|
|
||||||
<div></div>
|
|
||||||
<div></div>
|
|
||||||
</div>
|
|
||||||
<div class="error">
|
|
||||||
<div class="error-code">
|
|
||||||
<h1>FillCode</h1>
|
|
||||||
</div>
|
|
||||||
<h2>请完成验证</h2>
|
|
||||||
<p>请完成下面验证, 页面将会自动跳转到访问页面。</p>
|
|
||||||
<form id="captcha-form" method="POST">
|
|
||||||
<div id="captcha" class="{{captcha_frontend_key}}" data-sitekey="{{captcha_site_key}}"
|
|
||||||
data-callback="captchaCallback" data-size="flexible"></div>
|
|
||||||
<div class="loading">验证码加载中, 请稍等...</div>
|
|
||||||
</form>
|
|
||||||
<a href="mailto:[email protected]">联系我们</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
function captchaCallback() {
|
|
||||||
setTimeout(() => document.querySelector('#captcha-form').submit(), 500)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
// 配置
|
|
||||||
const pwaCdnConfig = {
|
|
||||||
cdnUrl: 'https://cdn.fillcode.com/',
|
|
||||||
serviceWorkerUrl: '/__static/sw-cdn.js',
|
|
||||||
staticRegex: /\.(js|css|png|jpg|jpeg|gif|svg|webp|woff|woff2|ttf|ico)$/,
|
|
||||||
debug: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PWA 初始化函数
|
|
||||||
*/
|
|
||||||
async function initializePWA() {
|
|
||||||
// 检查支持
|
|
||||||
if (!('serviceWorker' in navigator)) return console.log('PWA-CDN: Service Worker not supported')
|
|
||||||
|
|
||||||
let registration;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 注册Service Worker - 使用相对路径
|
|
||||||
registration = await navigator.serviceWorker.register(pwaCdnConfig.serviceWorkerUrl, {scope: '/'})
|
|
||||||
|
|
||||||
console.log('PWA-CDN: Service Worker registered')
|
|
||||||
} catch (error) {
|
|
||||||
console.error('PWA-CDN: Failed to register Service Worker:', error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送初始配置
|
|
||||||
const sendConfig = () => {
|
|
||||||
registration.active.postMessage({type: 'CONFIG', config: pwaCdnConfig})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果注册失败,直接返回错误
|
|
||||||
if(!registration) return console.error('PWA-CDN: Service Worker registration failed, cannot send config')
|
|
||||||
|
|
||||||
// 更新配置函数
|
|
||||||
window.updatePWACDNConfig = (newConfig) => {
|
|
||||||
Object.assign(pwaCdnConfig, newConfig)
|
|
||||||
sendConfig()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 等待Service Worker激活后发送配置
|
|
||||||
if (registration.active) sendConfig()
|
|
||||||
|
|
||||||
// 监听Service Worker更新事件
|
|
||||||
registration.addEventListener('updatefound', () => {
|
|
||||||
const newWorker = registration.installing
|
|
||||||
|
|
||||||
newWorker.addEventListener('statechange', () => {
|
|
||||||
if (newWorker.state === 'activated') sendConfig()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 启动 PWA-CDN
|
|
||||||
* */
|
|
||||||
initializePWA().catch(console.error)
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
// Service Worker 配置 - 默认值
|
|
||||||
let config = {
|
|
||||||
cdnUrl: 'https://cdn.fillcode.com/',
|
|
||||||
serviceWorkerUrl: '/__static/sw-cdn.js',
|
|
||||||
staticRegex: /(.*\.(css|js|png|jpg|jpeg|gif|svg|webp|ico|woff|woff2|ttf|eot)|avatars[^/]+)$/,
|
|
||||||
debug: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
// 监听配置更新消息
|
|
||||||
self.addEventListener('message', e => {
|
|
||||||
if (e.data.type !== 'CONFIG') return
|
|
||||||
|
|
||||||
config = e.data.config
|
|
||||||
|
|
||||||
if (config.debug) console.log('PWA-CDN: Config updated', config)
|
|
||||||
})
|
|
||||||
|
|
||||||
// 拦截网络请求
|
|
||||||
self.addEventListener('fetch', e => {
|
|
||||||
const url = new URL(e.request.url)
|
|
||||||
|
|
||||||
// 如果请求不是GET方法,直接返回
|
|
||||||
if (e.request.method !== 'GET') return
|
|
||||||
|
|
||||||
// 如果请求的域名不是当前页面的域名
|
|
||||||
if (url.origin !== self.location.origin) return
|
|
||||||
|
|
||||||
// 过滤__static路径下的请求
|
|
||||||
if (url.pathname.startsWith('/__static/')) return
|
|
||||||
|
|
||||||
// 如果请求的路径不匹配静态资源正则表达式,直接返回
|
|
||||||
if (!config.staticRegex.test(url.pathname)) return
|
|
||||||
|
|
||||||
// 判断是否是强制需要同源请求
|
|
||||||
const requiresSameOrigin = ['worker', 'sharedworker', 'serviceworker'].includes(e.request.destination)
|
|
||||||
|
|
||||||
// 如果是强制需要同源请求的资源类型,直接返回
|
|
||||||
if (requiresSameOrigin) return
|
|
||||||
|
|
||||||
// 开始处理静态资源请求
|
|
||||||
e.respondWith(handleStaticResource(e.request, url))
|
|
||||||
})
|
|
||||||
|
|
||||||
// 处理静态资源请求
|
|
||||||
async function handleStaticResource(request, url) {
|
|
||||||
// 生成CDN子路径
|
|
||||||
const hostname = self.location.hostname
|
|
||||||
const cdnPath = hostname.replace(/\./g, '-')
|
|
||||||
|
|
||||||
const targetUrl = config.cdnUrl + cdnPath + url.pathname + url.search
|
|
||||||
|
|
||||||
if (config.debug) console.log('PWA-CDN:', url.href, '->', targetUrl)
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 创建新请求
|
|
||||||
const newRequest = new Request(targetUrl, {
|
|
||||||
...request,
|
|
||||||
mode: 'cors',
|
|
||||||
redirect: 'error',
|
|
||||||
})
|
|
||||||
|
|
||||||
// 请求目标域名,浏览器会自动处理缓存
|
|
||||||
const response = await fetch(newRequest)
|
|
||||||
|
|
||||||
// 检查响应状态
|
|
||||||
if (!response.ok) throw new Error('PWA-CDN: Non-2xx response detected')
|
|
||||||
|
|
||||||
return response
|
|
||||||
} catch (error) {
|
|
||||||
if (config.debug) console.warn('PWA-CDN: Fallback to original request for', url.href, error)
|
|
||||||
|
|
||||||
// 失败时回退到原始请求
|
|
||||||
return fetch(request)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Service Worker 生命周期
|
|
||||||
self.addEventListener('install', () => {
|
|
||||||
if (config.debug) console.log('PWA-CDN: Service Worker installing')
|
|
||||||
self.skipWaiting().catch(console.error)
|
|
||||||
})
|
|
||||||
|
|
||||||
self.addEventListener('activate', () => {
|
|
||||||
if (config.debug) console.log('PWA-CDN: Service Worker activated')
|
|
||||||
self.clients.claim().catch(console.error)
|
|
||||||
})
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
### path core中服务的节点亲和性 使他们只运行在master节点上
|
|
||||||
```shell
|
|
||||||
kubectl patch -n kube-system deployment coredns --patch-file=apps/kube/patch-affinity.yaml
|
|
||||||
```
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
spec:
|
|
||||||
template:
|
|
||||||
spec:
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
requiredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
nodeSelectorTerms:
|
|
||||||
- matchExpressions:
|
|
||||||
- key: node-role.kubernetes.io/control-plane
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- "true"
|
|
||||||
+230
@@ -0,0 +1,230 @@
|
|||||||
|
# Flux GitOps 迁移指南
|
||||||
|
|
||||||
|
补充一份面向本地演练和远端平滑切换的执行清单,见 [TEST_MIGRATION_PLAN.md](TEST_MIGRATION_PLAN.md)。
|
||||||
|
|
||||||
|
## 目录结构
|
||||||
|
|
||||||
|
```
|
||||||
|
flux/
|
||||||
|
├── clusters/
|
||||||
|
│ └── dev-cm/ # 集群级别编排
|
||||||
|
│ ├── kustomization.yaml # 资源列表
|
||||||
|
│ ├── sources.yaml # HelmRepository 源
|
||||||
|
│ ├── kube-system.yaml # CoreDNS / NodeLocalDNS
|
||||||
|
│ ├── infra-devops.yaml # cert-manager / reflector / velero
|
||||||
|
│ ├── infra-data.yaml # CNPG / Valkey
|
||||||
|
│ ├── infra-monitor.yaml # Loki / Prometheus
|
||||||
|
│ ├── infra-net.yaml # Nginx / CrowdSec / Tailscale
|
||||||
|
│ ├── infra-gitops.yaml # Gitea
|
||||||
|
│ └── apps.yaml # Halo / RustDesk / Fillcode / SinceAI
|
||||||
|
├── infrastructure/
|
||||||
|
│ ├── sources/ # 所有 HelmRepository 定义
|
||||||
|
│ ├── kube-system/ # CoreDNS 自定义 + NodeLocalDNS
|
||||||
|
│ ├── infra-devops/ # cert-manager, webhook-dnspod, reflector, velero
|
||||||
|
│ ├── infra-data/ # CNPG operator, Barman, PG集群, Valkey
|
||||||
|
│ ├── infra-net/ # ingress-nginx, CrowdSec, Tailscale DERP, 证书
|
||||||
|
│ ├── infra-monitor/ # Loki, Promtail, Prometheus+Grafana
|
||||||
|
│ └── infra-gitops/ # Gitea, Gitea Actions
|
||||||
|
└── apps/ # Halo, RustDesk, Whoami, 证书, Ingress
|
||||||
|
```
|
||||||
|
|
||||||
|
## 依赖顺序
|
||||||
|
|
||||||
|
```
|
||||||
|
sources (HelmRepository)
|
||||||
|
│
|
||||||
|
├── kube-system (无依赖)
|
||||||
|
│
|
||||||
|
└── infra-devops (cert-manager → webhook-dnspod → ClusterIssuer, reflector, velero)
|
||||||
|
│
|
||||||
|
├── infra-data (CNPG operator → Barman plugin → PG集群 + ObjectStore, Valkey)
|
||||||
|
│ │
|
||||||
|
│ ├── infra-monitor (Loki → Promtail, Prometheus+Grafana→PG)
|
||||||
|
│ │ │
|
||||||
|
│ │ ├── infra-net (Nginx, 证书, CrowdSec→Loki+PG, Tailscale)
|
||||||
|
│ │ │
|
||||||
|
│ │ └── infra-gitops (Gitea→PG+Valkey, Gitea Actions→Gitea)
|
||||||
|
│ │
|
||||||
|
│ └───────┴── apps (Halo→PG, RustDesk, Whoami, 证书, Ingress)
|
||||||
|
```
|
||||||
|
|
||||||
|
## K3s 保留项
|
||||||
|
|
||||||
|
以下资源**继续由 K3s HelmChart 管理**,不迁移到 Flux:
|
||||||
|
|
||||||
|
- `k3s/apps/infra/gitops/namespaces.yaml` — infra-gitops 命名空间
|
||||||
|
- `k3s/apps/infra/gitops/flux/helmchart.yaml` — flux-operator HelmChart
|
||||||
|
- `k3s/apps/infra/gitops/flux/flux-instance.yaml` — FluxInstance (含 sync 配置)
|
||||||
|
- `k3s/apps/infra/gitops/flux/networkpolicy.yaml` — flux-operator NetworkPolicy
|
||||||
|
- `k3s/apps/infra/gitops/flux/clusterrolebinding.yaml` — flux-web RBAC
|
||||||
|
|
||||||
|
## 迁移步骤
|
||||||
|
|
||||||
|
### 1. 创建 Git 认证 Secret
|
||||||
|
|
||||||
|
Flux 需要 HTTPS 凭据来访问 Gitea 仓库。在集群中创建 Secret:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl -n infra-gitops create secret generic flux-git-auth \
|
||||||
|
--from-literal=username=<GITEA_USERNAME> \
|
||||||
|
--from-literal=password=<GITEA_ACCESS_TOKEN>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 确认仓库 URL
|
||||||
|
|
||||||
|
检查 `k3s/apps/infra/gitops/flux/flux-instance.yaml` 中的 `sync.url` 字段,确保指向正确的 deploy 仓库地址。当前设置为:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
sync:
|
||||||
|
url: https://git.dev.cm/devcm/deploy.git
|
||||||
|
```
|
||||||
|
|
||||||
|
如果组织名或仓库名不同,请修改。
|
||||||
|
|
||||||
|
### 3. 提交并推送 Flux 清单
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add flux/
|
||||||
|
git add k3s/apps/infra/gitops/flux/flux-instance.yaml
|
||||||
|
git commit -m "feat: 迁移到 Flux GitOps 管理"
|
||||||
|
git push origin main
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 应用更新后的 FluxInstance
|
||||||
|
|
||||||
|
FluxInstance 的 sync 配置更新后,K3s 会自动检测变更并重新应用。也可以手动触发:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl apply -f k3s/apps/infra/gitops/flux/flux-instance.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
这会让 flux-operator 创建:
|
||||||
|
|
||||||
|
- `GitRepository/flux` — 监听 deploy 仓库
|
||||||
|
- `Kustomization/flux` — 应用 `flux/clusters/dev-cm/` 路径下的所有资源
|
||||||
|
|
||||||
|
### 5. 等待 Flux 完成同步
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 查看 GitRepository 状态
|
||||||
|
kubectl -n infra-gitops get gitrepository flux
|
||||||
|
|
||||||
|
# 查看所有 Kustomization 状态
|
||||||
|
kubectl -n infra-gitops get kustomization
|
||||||
|
|
||||||
|
# 查看所有 HelmRelease 状态
|
||||||
|
kubectl get helmrelease -A
|
||||||
|
|
||||||
|
# 实时查看 Flux 事件
|
||||||
|
kubectl -n infra-gitops get events --sort-by='.lastTimestamp' --watch
|
||||||
|
```
|
||||||
|
|
||||||
|
等待所有 Kustomization 和 HelmRelease 状态变为 `Ready`。
|
||||||
|
|
||||||
|
### 6. 验证资源被 Flux 接管
|
||||||
|
|
||||||
|
对于每个已有的 Helm Release,Flux 会检测到已存在的资源并进行接管(adopt)。验证:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 检查所有 HelmRelease 是否就绪
|
||||||
|
kubectl get helmrelease -A -o wide
|
||||||
|
|
||||||
|
# 检查某个具体的 release
|
||||||
|
kubectl -n infra-devops describe helmrelease cert-manager
|
||||||
|
```
|
||||||
|
|
||||||
|
### 7. 清理旧的 K3s HelmChart 资源
|
||||||
|
|
||||||
|
确认 Flux 已成功接管所有资源后,删除旧的 K3s HelmChart CR(不会影响已部署的应用):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 列出所有 K3s HelmChart
|
||||||
|
kubectl get helmchart -A
|
||||||
|
|
||||||
|
# 逐个删除(保留 flux-operator)
|
||||||
|
kubectl delete helmchart -n infra-devops cert-manager
|
||||||
|
kubectl delete helmchart -n infra-devops cert-manager-webhook-dnspod
|
||||||
|
kubectl delete helmchart -n infra-devops reflector
|
||||||
|
kubectl delete helmchart -n infra-devops velero
|
||||||
|
kubectl delete helmchart -n infra-data cloudnative-pg
|
||||||
|
kubectl delete helmchart -n infra-data cloudnative-pg-plugin-barman
|
||||||
|
kubectl delete helmchart -n infra-data valkey-cluster-sh
|
||||||
|
kubectl delete helmchart -n infra-net ingress-nginx
|
||||||
|
kubectl delete helmchart -n infra-net crowdsec
|
||||||
|
kubectl delete helmchart -n infra-net tailscale-derp-hk
|
||||||
|
kubectl delete helmchart -n infra-monitor loki
|
||||||
|
kubectl delete helmchart -n infra-monitor loki-promtail
|
||||||
|
kubectl delete helmchart -n infra-monitor prometheus
|
||||||
|
kubectl delete helmchart -n infra-gitops gitea
|
||||||
|
kubectl delete helmchart -n infra-gitops gitea-actions
|
||||||
|
kubectl delete helmchart -n apps fillcode-whoami
|
||||||
|
kubectl delete helmchart -n apps halo
|
||||||
|
kubectl delete helmchart -n apps rustdesk
|
||||||
|
```
|
||||||
|
|
||||||
|
> **注意**: K3s HelmChart 使用 `helm.cattle.io/v1` API。删除 HelmChart CR 默认**不会**卸载已部署的 Helm release。Flux 的 HelmRelease 会接管这些 release 的后续管理。
|
||||||
|
|
||||||
|
### 8. 清理旧的 K3s 清单文件
|
||||||
|
|
||||||
|
确认一切正常后,可以移除 `k3s/apps/` 中已迁移到 Flux 的文件(保留 flux 相关的):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 保留以下文件(K3s 继续管理):
|
||||||
|
# k3s/apps/infra/gitops/namespaces.yaml
|
||||||
|
# k3s/apps/infra/gitops/flux/
|
||||||
|
|
||||||
|
# 其余文件可以删除或归档
|
||||||
|
```
|
||||||
|
|
||||||
|
## 资源映射表
|
||||||
|
|
||||||
|
| 原 K3s HelmChart | Flux HelmRelease | 命名空间 |
|
||||||
|
| ---------------------------- | ---------------------------- | ------------- |
|
||||||
|
| cert-manager | cert-manager | infra-devops |
|
||||||
|
| cert-manager-webhook-dnspod | cert-manager-webhook-dnspod | infra-devops |
|
||||||
|
| reflector | reflector | infra-devops |
|
||||||
|
| velero | velero | infra-devops |
|
||||||
|
| cloudnative-pg | cloudnative-pg | infra-data |
|
||||||
|
| cloudnative-pg-plugin-barman | cloudnative-pg-plugin-barman | infra-data |
|
||||||
|
| valkey-cluster-sh | valkey-cluster-sh | infra-data |
|
||||||
|
| ingress-nginx | ingress-nginx | infra-net |
|
||||||
|
| crowdsec | crowdsec | infra-net |
|
||||||
|
| tailscale-derp-hk | tailscale-derp-hk | infra-net |
|
||||||
|
| loki | loki | infra-monitor |
|
||||||
|
| loki-promtail | loki-promtail | infra-monitor |
|
||||||
|
| prometheus | prometheus | infra-monitor |
|
||||||
|
| gitea | gitea | infra-gitops |
|
||||||
|
| gitea-actions | gitea-actions | infra-gitops |
|
||||||
|
| fillcode-whoami | fillcode-whoami | apps |
|
||||||
|
| halo | halo | apps |
|
||||||
|
| rustdesk | rustdesk | apps |
|
||||||
|
|
||||||
|
## HelmRelease 内依赖关系
|
||||||
|
|
||||||
|
| HelmRelease | dependsOn |
|
||||||
|
| ---------------------------- | ------------------------------ |
|
||||||
|
| cert-manager-webhook-dnspod | cert-manager |
|
||||||
|
| cloudnative-pg-plugin-barman | cloudnative-pg |
|
||||||
|
| loki-promtail | loki |
|
||||||
|
| crowdsec | ingress-nginx, loki (cross-ns) |
|
||||||
|
| gitea-actions | gitea |
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
|
||||||
|
1. **Helm Release 接管**: Flux 默认会检测与 HelmRelease 同名的已存在 Helm release。如果名称不匹配,需要在 `spec.releaseName` 中指定原始名称。
|
||||||
|
|
||||||
|
2. **CRD 管理**: cert-manager 和 kube-prometheus-stack 的 HelmRelease 配置了 `install.crds: CreateReplace` 和 `upgrade.crds: CreateReplace` 以确保 CRD 被正确管理。
|
||||||
|
|
||||||
|
3. **跨命名空间引用**: 所有 HelmRepository 位于 `infra-gitops` 命名空间。HelmRelease 通过 `sourceRef.namespace: infra-gitops` 跨命名空间引用。FluxInstance 配置为单租户模式 (`multitenant: false`),允许此行为。
|
||||||
|
|
||||||
|
4. **kube-system 资源**: `prune: false` 用于 kube-system Kustomization,防止 Flux 意外删除系统资源。
|
||||||
|
|
||||||
|
5. **Velero CRD**: Velero HelmRelease 保持 `upgradeCRDs: false`,与原始配置一致。
|
||||||
|
|
||||||
|
6. **敏感信息**: 以下 Secret 需要手动维护(不在 Git 中管理):
|
||||||
|
- `flux-git-auth` (Gitea 访问令牌)
|
||||||
|
- `dnspod-secret` (DNSPod API 凭据)
|
||||||
|
- `s3-devcm-hw` (华为云 OBS 凭据)
|
||||||
|
- `cnpg17-cluster-*-app` (PostgreSQL 密码, 由 CNPG 自动管理)
|
||||||
|
- `valkey-cluster-sh` (Valkey 密码)
|
||||||
|
- `gitea-actions` (Gitea Actions runner token)
|
||||||
@@ -1,28 +1,23 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
kind: HelmChart
|
kind: HelmRelease
|
||||||
metadata:
|
metadata:
|
||||||
name: halo
|
name: halo
|
||||||
namespace: apps
|
namespace: apps
|
||||||
spec:
|
spec:
|
||||||
repo: https://halo-sigs.github.io/charts/
|
interval: 30m
|
||||||
chart: halo
|
chart:
|
||||||
targetNamespace: apps
|
spec:
|
||||||
version: 1.3.2
|
chart: halo
|
||||||
valuesContent: |-
|
version: 1.3.2
|
||||||
affinity:
|
sourceRef:
|
||||||
podAffinity:
|
kind: HelmRepository
|
||||||
preferredDuringSchedulingIgnoredDuringExecution:
|
name: halo
|
||||||
- weight: 100
|
namespace: infra-gitops
|
||||||
podAffinityTerm:
|
interval: 12h
|
||||||
labelSelector:
|
values:
|
||||||
matchLabels:
|
|
||||||
cnpg.io/cluster: cnpg17-cluster-hk
|
|
||||||
role: primary
|
|
||||||
topologyKey: kubernetes.io/hostname
|
|
||||||
namespaceSelector: {}
|
|
||||||
image:
|
image:
|
||||||
repository: halohub/halo-pro
|
repository: halohub/halo-pro
|
||||||
tag: 2.22.12
|
tag: 2.23.1
|
||||||
service:
|
service:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
ingress:
|
ingress:
|
||||||
@@ -41,6 +36,9 @@ spec:
|
|||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
podAnnotations:
|
podAnnotations:
|
||||||
backup.velero.io/backup-volumes: halo-data
|
backup.velero.io/backup-volumes: halo-data
|
||||||
|
persistence:
|
||||||
|
annotations:
|
||||||
|
helm.sh/resource-policy: keep
|
||||||
metrics:
|
metrics:
|
||||||
enabled: true
|
enabled: true
|
||||||
mysql:
|
mysql:
|
||||||
@@ -52,10 +50,8 @@ spec:
|
|||||||
host: cnpg17-cluster-hk-rw.infra-data
|
host: cnpg17-cluster-hk-rw.infra-data
|
||||||
port: 5432
|
port: 5432
|
||||||
user: app
|
user: app
|
||||||
password: FybaFtf6NV5jnxhj5bOPpHbO6KypZeHiyiskgAWkM5nioW2j82HtCf6GnW9xVKjE
|
password: from-secret
|
||||||
database: halo
|
database: halo
|
||||||
|
existingSecret: cnpg17-cluster-hk-app
|
||||||
haloUsername: rohow
|
haloUsername: rohow
|
||||||
haloExternalUrl: https://dev.cm
|
haloExternalUrl: https://dev.cm
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,27 +1,32 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
kind: HelmChart
|
kind: HelmRelease
|
||||||
metadata:
|
metadata:
|
||||||
name: rustdesk
|
name: rustdesk
|
||||||
namespace: apps
|
namespace: apps
|
||||||
spec:
|
spec:
|
||||||
repo: https://devcm-repo.github.io/helm-charts
|
interval: 30m
|
||||||
chart: rustdesk-server
|
chart:
|
||||||
targetNamespace: apps
|
spec:
|
||||||
version: 0.0.5
|
chart: rustdesk-server
|
||||||
valuesContent: |-
|
version: 0.0.7
|
||||||
nodeSelector:
|
sourceRef:
|
||||||
kubernetes.io/hostname: tcd
|
kind: HelmRepository
|
||||||
|
name: devcm-repo
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
values:
|
||||||
rustdeskServer:
|
rustdeskServer:
|
||||||
encryptedOnly: true
|
encryptedOnly: true
|
||||||
mustLogin: true
|
mustLogin: true
|
||||||
server: desk-server.dev.cm
|
server: desk-server.dev.cm
|
||||||
|
podAnnotations:
|
||||||
|
backup.velero.io/backup-volumes: data
|
||||||
extraEnvs:
|
extraEnvs:
|
||||||
- name: TZ
|
- name: TZ
|
||||||
value: "Asia/Shanghai"
|
value: "Asia/Shanghai"
|
||||||
- name: RUSTDESK_API_LANG
|
- name: RUSTDESK_API_LANG
|
||||||
value: "zh-CN"
|
value: "zh-CN"
|
||||||
|
|
||||||
rustdeskApi:
|
rustdeskApi:
|
||||||
server: desk.dev.cm
|
server: desk.dev.cm
|
||||||
ingress:
|
ingress:
|
||||||
@@ -1,14 +1,20 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
kind: HelmChart
|
kind: HelmRelease
|
||||||
metadata:
|
metadata:
|
||||||
name: fillcode-whoami
|
name: fillcode-whoami
|
||||||
namespace: apps
|
namespace: apps
|
||||||
spec:
|
spec:
|
||||||
repo: https://cowboysysop.github.io/charts/
|
interval: 30m
|
||||||
chart: whoami
|
chart:
|
||||||
targetNamespace: apps
|
spec:
|
||||||
version: 5.1.2
|
chart: whoami
|
||||||
valuesContent: |-
|
version: 5.1.2
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: cowboysysop
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
values:
|
||||||
ingress:
|
ingress:
|
||||||
enabled: true
|
enabled: true
|
||||||
ingressClassName: nginx
|
ingressClassName: nginx
|
||||||
@@ -20,5 +26,3 @@ spec:
|
|||||||
- host: whoami.fillcode.com
|
- host: whoami.fillcode.com
|
||||||
paths:
|
paths:
|
||||||
- /
|
- /
|
||||||
|
|
||||||
|
|
||||||
@@ -3,7 +3,6 @@ kind: Ingress
|
|||||||
metadata:
|
metadata:
|
||||||
name: fillcode
|
name: fillcode
|
||||||
namespace: apps
|
namespace: apps
|
||||||
annotations:
|
|
||||||
spec:
|
spec:
|
||||||
ingressClassName: nginx
|
ingressClassName: nginx
|
||||||
rules:
|
rules:
|
||||||
@@ -21,4 +20,3 @@ spec:
|
|||||||
- hosts:
|
- hosts:
|
||||||
- fillcode.com
|
- fillcode.com
|
||||||
secretName: fillcode-com-crt
|
secretName: fillcode-com-crt
|
||||||
|
|
||||||
@@ -20,4 +20,3 @@ spec:
|
|||||||
name: halo
|
name: halo
|
||||||
port:
|
port:
|
||||||
number: 80
|
number: 80
|
||||||
|
|
||||||
@@ -24,4 +24,3 @@ spec:
|
|||||||
- hosts:
|
- hosts:
|
||||||
- shop.sinceai.com
|
- shop.sinceai.com
|
||||||
secretName: sinceai-com-crt
|
secretName: sinceai-com-crt
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
- certificate-fillcode-com.yaml
|
||||||
|
- certificate-sinceai-com.yaml
|
||||||
|
- helmrelease-halo.yaml
|
||||||
|
- ingress-fillcode.yaml
|
||||||
|
- ingress-halo-www.yaml
|
||||||
|
- ingress-halo-static.yaml
|
||||||
|
- ingress-sinceai-shop.yaml
|
||||||
|
- helmrelease-whoami.yaml
|
||||||
|
- helmrelease-rustdesk.yaml
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: apps
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
retryInterval: 1m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux
|
||||||
|
path: ./flux/apps
|
||||||
|
prune: true
|
||||||
|
dependsOn:
|
||||||
|
- name: infra-data-post
|
||||||
|
- name: infra-net
|
||||||
|
- name: infra-gitops
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-data
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
retryInterval: 1m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux
|
||||||
|
path: ./flux/infrastructure/infra-data
|
||||||
|
prune: true
|
||||||
|
force: true
|
||||||
|
wait: true
|
||||||
|
dependsOn:
|
||||||
|
- name: infra-devops
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-data-post
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
retryInterval: 1m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux
|
||||||
|
path: ./flux/infrastructure/infra-data/post
|
||||||
|
prune: true
|
||||||
|
force: true
|
||||||
|
wait: true
|
||||||
|
dependsOn:
|
||||||
|
- name: infra-data
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-devops
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
retryInterval: 1m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux
|
||||||
|
path: ./flux/infrastructure/infra-devops
|
||||||
|
prune: true
|
||||||
|
wait: true
|
||||||
|
dependsOn:
|
||||||
|
- name: sources
|
||||||
|
- name: secrets
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-devops-post
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
retryInterval: 1m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux
|
||||||
|
path: ./flux/infrastructure/infra-devops/post
|
||||||
|
prune: true
|
||||||
|
force: true
|
||||||
|
wait: true
|
||||||
|
dependsOn:
|
||||||
|
- name: infra-monitor
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-gitops
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
retryInterval: 1m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux
|
||||||
|
path: ./flux/infrastructure/infra-gitops
|
||||||
|
prune: true
|
||||||
|
wait: true
|
||||||
|
dependsOn:
|
||||||
|
- name: infra-data-post
|
||||||
|
- name: infra-monitor
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-monitor
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
retryInterval: 1m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux
|
||||||
|
path: ./flux/infrastructure/infra-monitor
|
||||||
|
prune: true
|
||||||
|
force: true
|
||||||
|
wait: true
|
||||||
|
dependsOn:
|
||||||
|
- name: infra-data-post
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-net
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
retryInterval: 1m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux
|
||||||
|
path: ./flux/infrastructure/infra-net
|
||||||
|
prune: true
|
||||||
|
wait: true
|
||||||
|
dependsOn:
|
||||||
|
- name: kube-system
|
||||||
|
- name: infra-devops
|
||||||
|
- name: infra-devops-post
|
||||||
|
- name: infra-monitor
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: kube-system
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
retryInterval: 1m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux
|
||||||
|
path: ./flux/infrastructure/kube-system
|
||||||
|
prune: false
|
||||||
|
wait: true
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- sources.yaml
|
||||||
|
- secrets.yaml
|
||||||
|
- kube-system.yaml
|
||||||
|
- infra-devops.yaml
|
||||||
|
- infra-data.yaml
|
||||||
|
- infra-net.yaml
|
||||||
|
- infra-monitor.yaml
|
||||||
|
- infra-gitops.yaml
|
||||||
|
- apps.yaml
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# 密钥管理层 - 通过postBuild从flux-env Secret注入变量
|
||||||
|
# 所有环境流程一致: kubectl create secret generic flux-env -n infra-gitops --from-env-file=.env
|
||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: secrets
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
retryInterval: 1m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux
|
||||||
|
path: ./flux/infrastructure/secrets
|
||||||
|
prune: false
|
||||||
|
wait: true
|
||||||
|
dependsOn:
|
||||||
|
- name: sources
|
||||||
|
postBuild:
|
||||||
|
substituteFrom:
|
||||||
|
- kind: Secret
|
||||||
|
name: flux-env
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: sources
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
retryInterval: 1m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux
|
||||||
|
path: ./flux/infrastructure/sources
|
||||||
|
prune: true
|
||||||
|
wait: true
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- ../base
|
||||||
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: Kustomization
|
||||||
|
name: infra-devops
|
||||||
|
path: patches/infra-devops.yaml
|
||||||
|
- target:
|
||||||
|
kind: Kustomization
|
||||||
|
name: infra-data
|
||||||
|
path: patches/infra-data.yaml
|
||||||
|
- target:
|
||||||
|
kind: Kustomization
|
||||||
|
name: infra-data-post
|
||||||
|
path: patches/infra-data-post.yaml
|
||||||
|
- target:
|
||||||
|
kind: Kustomization
|
||||||
|
name: infra-net
|
||||||
|
path: patches/infra-net.yaml
|
||||||
|
- target:
|
||||||
|
kind: Kustomization
|
||||||
|
name: infra-monitor
|
||||||
|
path: patches/infra-monitor.yaml
|
||||||
|
- target:
|
||||||
|
kind: Kustomization
|
||||||
|
name: infra-gitops
|
||||||
|
path: patches/infra-gitops.yaml
|
||||||
|
- target:
|
||||||
|
kind: Kustomization
|
||||||
|
name: apps
|
||||||
|
path: patches/apps.yaml
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: apps
|
||||||
|
spec:
|
||||||
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: halo
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: halo
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
affinity:
|
||||||
|
podAffinity:
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 100
|
||||||
|
podAffinityTerm:
|
||||||
|
labelSelector:
|
||||||
|
matchLabels:
|
||||||
|
cnpg.io/cluster: cnpg17-cluster-hk
|
||||||
|
role: primary
|
||||||
|
topologyKey: kubernetes.io/hostname
|
||||||
|
namespaceSelector: {}
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: rustdesk
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: rustdesk
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: tcd
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-data-post
|
||||||
|
spec:
|
||||||
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: Cluster
|
||||||
|
name: cnpg17-cluster-hk
|
||||||
|
patch: |
|
||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
name: cnpg17-cluster-hk
|
||||||
|
spec:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "cn-hk"
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 1
|
||||||
|
preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- clawhk
|
||||||
|
- target:
|
||||||
|
kind: Cluster
|
||||||
|
name: cnpg17-cluster-sh
|
||||||
|
patch: |
|
||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
name: cnpg17-cluster-sh
|
||||||
|
spec:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "cn-sh"
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 1
|
||||||
|
preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- homea
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-data
|
||||||
|
spec:
|
||||||
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: cloudnative-pg
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cloudnative-pg
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "cn-sh"
|
||||||
|
tolerations:
|
||||||
|
- key: "node-role.kubernetes.io/control-plane"
|
||||||
|
operator: "Exists"
|
||||||
|
effect: "NoSchedule"
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: cloudnative-pg-plugin-barman
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cloudnative-pg-plugin-barman
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "cn-sh"
|
||||||
|
tolerations:
|
||||||
|
- key: "node-role.kubernetes.io/control-plane"
|
||||||
|
operator: "Exists"
|
||||||
|
effect: "NoSchedule"
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: valkey-cluster-sh
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: valkey-cluster-sh
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
valkey:
|
||||||
|
nodeAffinityPreset:
|
||||||
|
type: hard
|
||||||
|
key: topology.kubernetes.io/region
|
||||||
|
values:
|
||||||
|
- cn-sh
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-devops
|
||||||
|
spec:
|
||||||
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: cert-manager
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cert-manager
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "cn-sh"
|
||||||
|
webhook:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "cn-sh"
|
||||||
|
cainjector:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "cn-sh"
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: cert-manager-webhook-dnspod
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cert-manager-webhook-dnspod
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "cn-sh"
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: reflector
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: reflector
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "cn-sh"
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: velero
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: velero
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "cn-sh"
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 1
|
||||||
|
preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- homeb
|
||||||
|
nodeAgent:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: node-role.kubernetes.io/control-plane
|
||||||
|
operator: NotIn
|
||||||
|
values:
|
||||||
|
- "true"
|
||||||
|
- key: svccontroller.k3s.cattle.io/enablelb
|
||||||
|
operator: NotIn
|
||||||
|
values:
|
||||||
|
- "true"
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-gitops
|
||||||
|
spec:
|
||||||
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: gitea
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: gitea
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
affinity:
|
||||||
|
podAffinity:
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 100
|
||||||
|
podAffinityTerm:
|
||||||
|
labelSelector:
|
||||||
|
matchLabels:
|
||||||
|
cnpg.io/cluster: cnpg17-cluster-sh
|
||||||
|
role: primary
|
||||||
|
app.kubernetes.io/name: redis
|
||||||
|
app.kubernetes.io/component: master
|
||||||
|
topologyKey: kubernetes.io/hostname
|
||||||
|
namespaceSelector: {}
|
||||||
|
nodeAffinity:
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 1
|
||||||
|
preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- homea
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: gitea-actions
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: gitea-actions
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
statefulset:
|
||||||
|
nodeSelector:
|
||||||
|
dev-cm-runner/enabled: "true"
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-monitor
|
||||||
|
spec:
|
||||||
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: loki
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: loki
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
lokiCanary:
|
||||||
|
nodeSelector:
|
||||||
|
svccontroller.k3s.cattle.io/enablelb: "true"
|
||||||
|
resultsCache:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: tce
|
||||||
|
chunksCache:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: tce
|
||||||
|
singleBinary:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: tce
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: loki-promtail
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: loki-promtail
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
nodeSelector:
|
||||||
|
svccontroller.k3s.cattle.io/enablelb: "true"
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: prometheus
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: prometheus
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
prometheusOperator:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: hwa
|
||||||
|
kube-state-metrics:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: hwa
|
||||||
|
grafana:
|
||||||
|
affinity:
|
||||||
|
podAffinity:
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 100
|
||||||
|
podAffinityTerm:
|
||||||
|
labelSelector:
|
||||||
|
matchLabels:
|
||||||
|
cnpg.io/cluster: cnpg17-cluster-sh
|
||||||
|
role: primary
|
||||||
|
topologyKey: kubernetes.io/hostname
|
||||||
|
namespaceSelector: {}
|
||||||
|
persistence:
|
||||||
|
storageClassName: local-path
|
||||||
|
prometheus:
|
||||||
|
prometheusSpec:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: hwa
|
||||||
|
storageSpec:
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: local-path
|
||||||
|
alertmanager:
|
||||||
|
alertmanagerSpec:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: hwa
|
||||||
|
storage:
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: local-path
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: infra-net
|
||||||
|
spec:
|
||||||
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: ingress-nginx
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: ingress-nginx
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
controller:
|
||||||
|
nodeSelector:
|
||||||
|
svccontroller.k3s.cattle.io/enablelb: "true"
|
||||||
|
tolerations:
|
||||||
|
- key: "node-role.kubernetes.io/control-plane"
|
||||||
|
operator: "Exists"
|
||||||
|
effect: "NoSchedule"
|
||||||
|
dnsPolicy: "None"
|
||||||
|
dnsConfig:
|
||||||
|
nameservers:
|
||||||
|
- "169.254.20.10"
|
||||||
|
- "10.43.0.10"
|
||||||
|
maxmindLicenseKey: "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"
|
||||||
|
defaultBackend:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "cn-sh"
|
||||||
|
- "cn-hk"
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: crowdsec
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: crowdsec
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
agent:
|
||||||
|
affinity:
|
||||||
|
podAffinity:
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 100
|
||||||
|
podAffinityTerm:
|
||||||
|
labelSelector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: loki
|
||||||
|
topologyKey: kubernetes.io/hostname
|
||||||
|
namespaceSelector: {}
|
||||||
|
appsec:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 1
|
||||||
|
preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- cn-hk
|
||||||
|
lapi:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 1
|
||||||
|
preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: topology.kubernetes.io/region
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- cn-hk
|
||||||
|
- target:
|
||||||
|
kind: HelmRelease
|
||||||
|
name: tailscale-derp-hk
|
||||||
|
patch: |
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: tailscale-derp-hk
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: tchk
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- ../base
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
apiVersion: fluxcd.controlplane.io/v1
|
||||||
|
kind: FluxInstance
|
||||||
|
metadata:
|
||||||
|
name: flux
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
distribution:
|
||||||
|
version: "2.x"
|
||||||
|
registry: "ghcr.io/fluxcd"
|
||||||
|
artifact: "oci://ghcr.io/controlplaneio-fluxcd/flux-operator-manifests"
|
||||||
|
components:
|
||||||
|
- source-controller
|
||||||
|
- kustomize-controller
|
||||||
|
- helm-controller
|
||||||
|
- notification-controller
|
||||||
|
cluster:
|
||||||
|
type: kubernetes
|
||||||
|
size: small
|
||||||
|
multitenant: false
|
||||||
|
networkPolicy: true
|
||||||
|
domain: "cluster.local"
|
||||||
|
storage:
|
||||||
|
class: "local-path"
|
||||||
|
size: "10Gi"
|
||||||
|
# Git 仓库同步配置 - 请将 url 替换为实际的 deploy 仓库地址
|
||||||
|
sync:
|
||||||
|
kind: GitRepository
|
||||||
|
url: https://git.dev.cm/devcm/deploy.git
|
||||||
|
ref: refs/heads/main
|
||||||
|
path: flux/clusters/dev-cm
|
||||||
|
pullSecret: flux-git-auth
|
||||||
|
kustomize:
|
||||||
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: Deployment
|
||||||
|
patch: |
|
||||||
|
- op: add
|
||||||
|
path: /spec/template/spec/affinity
|
||||||
|
value:
|
||||||
|
nodeAffinity:
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 1
|
||||||
|
preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- homea
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cloudnative-pg-plugin-barman
|
||||||
|
namespace: infra-data
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
dependsOn:
|
||||||
|
- name: cloudnative-pg
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
chart: plugin-barman-cloud
|
||||||
|
version: 0.5.0
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: cloudnative-pg
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cloudnative-pg
|
||||||
|
namespace: infra-data
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
chart: cloudnative-pg
|
||||||
|
version: 0.27.1
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: cloudnative-pg
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
install:
|
||||||
|
crds: CreateReplace
|
||||||
|
upgrade:
|
||||||
|
crds: CreateReplace
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: valkey-cluster-sh
|
||||||
|
namespace: infra-data
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
chart: valkey-cluster
|
||||||
|
version: 3.0.23
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: bitnami
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
values:
|
||||||
|
image:
|
||||||
|
repository: bitnamilegacy/valkey-cluster
|
||||||
|
cluster:
|
||||||
|
nodes: 1
|
||||||
|
replicas: 0
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
- helmrelease-cloudnative-pg.yaml
|
||||||
|
- helmrelease-barman-plugin.yaml
|
||||||
|
- helmrelease-valkey-cluster.yaml
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
metadata:
|
metadata:
|
||||||
name: infra-net
|
name: infra-data
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
name: cnpg17-cluster-hk
|
||||||
|
namespace: infra-data
|
||||||
|
spec:
|
||||||
|
imageName: ghcr.io/cloudnative-pg/postgresql:17.4
|
||||||
|
enableSuperuserAccess: true
|
||||||
|
enablePDB: false
|
||||||
|
instances: 1
|
||||||
|
storage:
|
||||||
|
size: 10Gi
|
||||||
|
postgresql:
|
||||||
|
parameters:
|
||||||
|
archive_timeout: 30min
|
||||||
|
env:
|
||||||
|
- name: AWS_REQUEST_CHECKSUM_CALCULATION
|
||||||
|
value: when_required
|
||||||
|
- name: AWS_RESPONSE_CHECKSUM_VALIDATION
|
||||||
|
value: when_required
|
||||||
|
plugins:
|
||||||
|
- name: barman-cloud.cloudnative-pg.io
|
||||||
|
isWALArchiver: true
|
||||||
|
parameters:
|
||||||
|
barmanObjectName: cnpg17-objectstore-hw
|
||||||
|
serverName: cnpg17-cluster-hk
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: ScheduledBackup
|
||||||
|
metadata:
|
||||||
|
name: cnpg17-cluster-hk-backups
|
||||||
|
namespace: infra-data
|
||||||
|
spec:
|
||||||
|
schedule: "0 0 0 * * *"
|
||||||
|
immediate: true
|
||||||
|
backupOwnerReference: self
|
||||||
|
method: plugin
|
||||||
|
pluginConfiguration:
|
||||||
|
name: barman-cloud.cloudnative-pg.io
|
||||||
|
cluster:
|
||||||
|
name: cnpg17-cluster-hk
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
name: cnpg17-cluster-sh
|
||||||
|
namespace: infra-data
|
||||||
|
spec:
|
||||||
|
imageName: ghcr.io/cloudnative-pg/postgresql:17.4
|
||||||
|
enableSuperuserAccess: true
|
||||||
|
enablePDB: false
|
||||||
|
instances: 1
|
||||||
|
storage:
|
||||||
|
size: 10Gi
|
||||||
|
postgresql:
|
||||||
|
parameters:
|
||||||
|
archive_timeout: 30min
|
||||||
|
env:
|
||||||
|
- name: AWS_REQUEST_CHECKSUM_CALCULATION
|
||||||
|
value: when_required
|
||||||
|
- name: AWS_RESPONSE_CHECKSUM_VALIDATION
|
||||||
|
value: when_required
|
||||||
|
plugins:
|
||||||
|
- name: barman-cloud.cloudnative-pg.io
|
||||||
|
isWALArchiver: true
|
||||||
|
parameters:
|
||||||
|
barmanObjectName: cnpg17-objectstore-hw
|
||||||
|
serverName: cnpg17-cluster-sh
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: ScheduledBackup
|
||||||
|
metadata:
|
||||||
|
name: cnpg17-cluster-sh-backups
|
||||||
|
namespace: infra-data
|
||||||
|
spec:
|
||||||
|
schedule: "0 0 0 * * *"
|
||||||
|
immediate: true
|
||||||
|
backupOwnerReference: self
|
||||||
|
method: plugin
|
||||||
|
pluginConfiguration:
|
||||||
|
name: barman-cloud.cloudnative-pg.io
|
||||||
|
cluster:
|
||||||
|
name: cnpg17-cluster-sh
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
apiVersion: barmancloud.cnpg.io/v1
|
||||||
|
kind: ObjectStore
|
||||||
|
metadata:
|
||||||
|
name: cnpg17-objectstore-hw
|
||||||
|
namespace: infra-data
|
||||||
|
spec:
|
||||||
|
retentionPolicy: "7d"
|
||||||
|
configuration:
|
||||||
|
destinationPath: s3://devcm/cnpg/
|
||||||
|
endpointURL: https://obs.cn-east-3.myhuaweicloud.com
|
||||||
|
s3Credentials:
|
||||||
|
accessKeyId:
|
||||||
|
name: s3-devcm-hw
|
||||||
|
key: ACCESS_KEY_ID
|
||||||
|
secretAccessKey:
|
||||||
|
name: s3-devcm-hw
|
||||||
|
key: ACCESS_SECRET_KEY
|
||||||
|
wal:
|
||||||
|
compression: gzip
|
||||||
|
maxParallel: 8
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- cnpg17-objectstore-hw.yaml
|
||||||
|
- cnpg17-cluster-hk.yaml
|
||||||
|
- cnpg17-cluster-sh.yaml
|
||||||
|
- loadbalancer-hk.yaml
|
||||||
|
- loadbalancer-sh.yaml
|
||||||
|
- reflector-secret-annotations.yaml
|
||||||
+1
-1
@@ -9,6 +9,6 @@ spec:
|
|||||||
role: primary
|
role: primary
|
||||||
ports:
|
ports:
|
||||||
- protocol: TCP
|
- protocol: TCP
|
||||||
port: 65432
|
port: 65431
|
||||||
targetPort: 5432
|
targetPort: 5432
|
||||||
type: LoadBalancer
|
type: LoadBalancer
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# 给CNPG和Valkey自动生成的secrets添加Reflector注解
|
||||||
|
# 通过SSA force合并注解到已有secrets 使其自动复制到消费方命名空间
|
||||||
|
#
|
||||||
|
# cnpg17-cluster-hk-app → apps (halo), infra-net (crowdsec)
|
||||||
|
# cnpg17-cluster-sh-app → infra-gitops (gitea), infra-monitor (grafana)
|
||||||
|
# valkey-cluster-sh → infra-gitops (gitea)
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: cnpg17-cluster-hk-app
|
||||||
|
namespace: infra-data
|
||||||
|
annotations:
|
||||||
|
kustomize.toolkit.fluxcd.io/prune: disabled
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "apps,infra-net"
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "apps,infra-net"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: cnpg17-cluster-sh-app
|
||||||
|
namespace: infra-data
|
||||||
|
annotations:
|
||||||
|
kustomize.toolkit.fluxcd.io/prune: disabled
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "infra-gitops,infra-monitor"
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "infra-gitops,infra-monitor"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: valkey-cluster-sh
|
||||||
|
namespace: infra-data
|
||||||
|
annotations:
|
||||||
|
kustomize.toolkit.fluxcd.io/prune: disabled
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "infra-gitops"
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
|
||||||
|
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "infra-gitops"
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# 安装后需要将clusterIssuer的cnameStrategy策略设置为Follow
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cert-manager-webhook-dnspod
|
||||||
|
namespace: infra-devops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
dependsOn:
|
||||||
|
- name: cert-manager
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
chart: cert-manager-webhook-dnspod
|
||||||
|
version: 1.4.5
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: imroc
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
values:
|
||||||
|
image:
|
||||||
|
tag: "1.5.2"
|
||||||
|
namespace: infra-devops
|
||||||
|
certManager:
|
||||||
|
namespace: infra-devops
|
||||||
|
groupName: cert.dev.cm
|
||||||
|
# 此处关闭 选择手动创建 以支持cnameStrategy
|
||||||
|
clusterIssuer:
|
||||||
|
enabled: false
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cert-manager
|
||||||
|
namespace: infra-devops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
chart: cert-manager
|
||||||
|
version: v1.19.3
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: jetstack
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
install:
|
||||||
|
crds: CreateReplace
|
||||||
|
upgrade:
|
||||||
|
crds: CreateReplace
|
||||||
|
# 首次install时servicemonitor=false(CRD尚不存在)
|
||||||
|
# infra-monitor层部署后通过SSA patch开启
|
||||||
|
values:
|
||||||
|
crds:
|
||||||
|
enabled: true
|
||||||
|
keep: true
|
||||||
|
enableCertificateOwnerRef: true
|
||||||
|
prometheus:
|
||||||
|
enabled: true
|
||||||
|
servicemonitor:
|
||||||
|
enabled: false
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: reflector
|
||||||
|
namespace: infra-devops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
chart: reflector
|
||||||
|
version: 9.1.45
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: emberstack
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
values: {}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: velero
|
||||||
|
namespace: infra-devops
|
||||||
|
spec:
|
||||||
|
interval: 30m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
chart: velero
|
||||||
|
version: 11.3.2
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: vmware-tanzu
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
values:
|
||||||
|
# 此处暂时切换关闭upgradeCRDs操作 待官方修复后再开启
|
||||||
|
upgradeCRDs: false
|
||||||
|
deployNodeAgent: true
|
||||||
|
snapshotsEnabled: false
|
||||||
|
configuration:
|
||||||
|
backupSyncPeriod: 1h0m0s
|
||||||
|
defaultRepoMaintainFrequency: 3h0m0s
|
||||||
|
repositoryMaintenanceJob:
|
||||||
|
repositoryConfigData:
|
||||||
|
global:
|
||||||
|
keepLatestMaintenanceJobs: 1
|
||||||
|
backupStorageLocation:
|
||||||
|
- name: devcm-hw
|
||||||
|
default: true
|
||||||
|
provider: aws
|
||||||
|
bucket: devcm
|
||||||
|
prefix: velero
|
||||||
|
config:
|
||||||
|
region: cn-east-3
|
||||||
|
s3ForcePathStyle: false
|
||||||
|
s3Url: https://obs.cn-east-3.myhuaweicloud.com
|
||||||
|
checksumAlgorithm: ""
|
||||||
|
extraEnvVars:
|
||||||
|
- name: AWS_ACCESS_KEY_ID
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: s3-devcm-hw
|
||||||
|
key: ACCESS_KEY_ID
|
||||||
|
- name: AWS_SECRET_ACCESS_KEY
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: s3-devcm-hw
|
||||||
|
key: ACCESS_SECRET_KEY
|
||||||
|
credentials:
|
||||||
|
useSecret: false
|
||||||
|
initContainers:
|
||||||
|
- name: velero-plugin-for-aws
|
||||||
|
image: velero/velero-plugin-for-aws:v1.13.0
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /target
|
||||||
|
name: plugins
|
||||||
|
nodeAgent:
|
||||||
|
# 控制面板不启用 lb节点不启用
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
- helmrelease-cert-manager.yaml
|
||||||
|
- helmrelease-cert-manager-webhook-dnspod.yaml
|
||||||
|
- helmrelease-reflector.yaml
|
||||||
|
- helmrelease-velero.yaml
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
metadata:
|
metadata:
|
||||||
name: infra-devops
|
name: infra-devops
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
apiVersion: cert-manager.io/v1
|
||||||
|
kind: ClusterIssuer
|
||||||
|
metadata:
|
||||||
|
name: dnspod
|
||||||
|
labels:
|
||||||
|
app: cert-manager-webhook-dnspod
|
||||||
|
spec:
|
||||||
|
acme:
|
||||||
|
server: https://acme-v02.api.letsencrypt.org/directory
|
||||||
|
email: [email protected]
|
||||||
|
privateKeySecretRef:
|
||||||
|
name: cert-manager-webhook-dnspod-letsencrypt
|
||||||
|
solvers:
|
||||||
|
- dns01:
|
||||||
|
cnameStrategy: Follow
|
||||||
|
webhook:
|
||||||
|
groupName: cert.dev.cm
|
||||||
|
solverName: dnspod
|
||||||
|
config:
|
||||||
|
ttl: 600
|
||||||
|
secretIdRef:
|
||||||
|
name: dnspod-secret
|
||||||
|
key: secretId
|
||||||
|
secretKeyRef:
|
||||||
|
name: dnspod-secret
|
||||||
|
key: secretKey
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# 在prometheus-stack部署后 通过SSA patch cert-manager开启ServiceMonitor
|
||||||
|
# cert-manager初始安装时servicemonitor.enabled=false(CRD尚不存在)
|
||||||
|
# infra-monitor层部署时CRD已就绪 此patch合并到已有HelmRelease
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cert-manager
|
||||||
|
namespace: infra-devops
|
||||||
|
annotations:
|
||||||
|
kustomize.toolkit.fluxcd.io/prune: disabled
|
||||||
|
spec:
|
||||||
|
values:
|
||||||
|
prometheus:
|
||||||
|
servicemonitor:
|
||||||
|
enabled: true
|
||||||
|
interval: 300s
|
||||||
|
prometheusInstance: kube-prometheus
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- clusterissuer-dnspod.yaml
|
||||||
|
- helmrelease-cert-manager-patch.yaml
|
||||||
+2
-2
@@ -2,9 +2,9 @@ apiVersion: v1
|
|||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-actions-dind-config
|
name: gitea-actions-dind-config
|
||||||
namespace: infra-devops
|
namespace: infra-gitops
|
||||||
data:
|
data:
|
||||||
daemon.json: |-
|
daemon.json: |-
|
||||||
{
|
{
|
||||||
"mtu": 1280
|
"mtu": 1280
|
||||||
}
|
}
|
||||||
+2
-2
@@ -2,7 +2,7 @@ apiVersion: v1
|
|||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-custom-templates
|
name: gitea-custom-templates
|
||||||
namespace: infra-devops
|
namespace: infra-gitops
|
||||||
data:
|
data:
|
||||||
home.tmpl: |-
|
home.tmpl: |-
|
||||||
{{template "base/head" .}}
|
{{template "base/head" .}}
|
||||||
@@ -28,4 +28,4 @@ data:
|
|||||||
<a class="item extra-links-end" href="https://fillcode.com" target="_blank">Fillcode</a>
|
<a class="item extra-links-end" href="https://fillcode.com" target="_blank">Fillcode</a>
|
||||||
<style>
|
<style>
|
||||||
.extra-links-end ~ a { display:none !important; }
|
.extra-links-end ~ a { display:none !important; }
|
||||||
</style>
|
</style>
|
||||||
+19
-18
@@ -1,18 +1,24 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
kind: HelmChart
|
kind: HelmRelease
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-actions
|
name: gitea-actions
|
||||||
namespace: infra-devops
|
namespace: infra-gitops
|
||||||
spec:
|
spec:
|
||||||
repo: https://dl.gitea.com/charts
|
interval: 30m
|
||||||
chart: actions
|
dependsOn:
|
||||||
targetNamespace: infra-devops
|
- name: gitea
|
||||||
version: 0.0.2
|
chart:
|
||||||
valuesContent: |-
|
spec:
|
||||||
|
chart: actions
|
||||||
|
version: 0.0.2
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: gitea
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
values:
|
||||||
enabled: true
|
enabled: true
|
||||||
statefulset:
|
statefulset:
|
||||||
nodeSelector:
|
|
||||||
dev-cm-runner/enabled: "true"
|
|
||||||
actRunner:
|
actRunner:
|
||||||
config: |
|
config: |
|
||||||
log:
|
log:
|
||||||
@@ -22,8 +28,8 @@ spec:
|
|||||||
container:
|
container:
|
||||||
require_docker: true
|
require_docker: true
|
||||||
docker_timeout: 300s
|
docker_timeout: 300s
|
||||||
# 使用bridge网络模式,解决新建任务临时网络mtu与主机不一致的问题
|
# 使用bridge网络模式,解决新建任务临时网络mtu与主机不一致的问题
|
||||||
network: bridge
|
network: bridge
|
||||||
dind:
|
dind:
|
||||||
# 挂载dind docker配置文件,解决mtu带来的网络问题
|
# 挂载dind docker配置文件,解决mtu带来的网络问题
|
||||||
extraVolumeMounts:
|
extraVolumeMounts:
|
||||||
@@ -36,11 +42,6 @@ spec:
|
|||||||
name: gitea-actions-dind-config
|
name: gitea-actions-dind-config
|
||||||
persistence:
|
persistence:
|
||||||
size: 10Gi
|
size: 10Gi
|
||||||
giteaRootURL: http://gitea-http.infra-devops.svc.cluster.local:3000
|
giteaRootURL: http://gitea-http.infra-gitops.svc.cluster.local:3000
|
||||||
existingSecret: gitea-actions
|
existingSecret: gitea-actions
|
||||||
existingSecretKey: token
|
existingSecretKey: token
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+32
-38
@@ -1,42 +1,26 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
kind: HelmChart
|
kind: HelmRelease
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea
|
name: gitea
|
||||||
namespace: infra-devops
|
namespace: infra-gitops
|
||||||
spec:
|
spec:
|
||||||
repo: https://dl.gitea.com/charts
|
interval: 30m
|
||||||
chart: gitea
|
chart:
|
||||||
targetNamespace: infra-devops
|
spec:
|
||||||
version: 12.3.0
|
chart: gitea
|
||||||
valuesContent: |-
|
version: 12.5.0
|
||||||
affinity:
|
sourceRef:
|
||||||
podAffinity:
|
kind: HelmRepository
|
||||||
preferredDuringSchedulingIgnoredDuringExecution:
|
name: gitea
|
||||||
- weight: 100
|
namespace: infra-gitops
|
||||||
podAffinityTerm:
|
interval: 12h
|
||||||
labelSelector:
|
values:
|
||||||
matchLabels:
|
|
||||||
cnpg.io/cluster: cnpg17-cluster-sh
|
|
||||||
role: primary
|
|
||||||
app.kubernetes.io/name: redis
|
|
||||||
app.kubernetes.io/component: master
|
|
||||||
topologyKey: kubernetes.io/hostname
|
|
||||||
namespaceSelector: {}
|
|
||||||
nodeAffinity:
|
|
||||||
preferredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
- weight: 1
|
|
||||||
preference:
|
|
||||||
matchExpressions:
|
|
||||||
- key: kubernetes.io/hostname
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- homea
|
|
||||||
redis-cluster:
|
redis-cluster:
|
||||||
enabled: false
|
enabled: false
|
||||||
postgresql-ha:
|
postgresql-ha:
|
||||||
enabled: false
|
enabled: false
|
||||||
image:
|
image:
|
||||||
tag: 1.25.3
|
tag: 1.25.5
|
||||||
ingress:
|
ingress:
|
||||||
enabled: true
|
enabled: true
|
||||||
className: nginx
|
className: nginx
|
||||||
@@ -67,17 +51,13 @@ spec:
|
|||||||
HOST: cnpg17-cluster-sh-rw.infra-data:5432
|
HOST: cnpg17-cluster-sh-rw.infra-data:5432
|
||||||
NAME: gitea
|
NAME: gitea
|
||||||
USER: app
|
USER: app
|
||||||
PASSWD: HueUoQx05DM0ICBPu1GrmBvBXE6NO3poKE6yPqokPv3dPpWvWRLAr3RXSpaL3AZd
|
|
||||||
SSL_MODE: disable
|
SSL_MODE: disable
|
||||||
session:
|
session:
|
||||||
PROVIDER: redis
|
PROVIDER: redis
|
||||||
PROVIDER_CONFIG: redis://:[email protected]:6379/0
|
|
||||||
cache:
|
cache:
|
||||||
ADAPTER: redis
|
ADAPTER: redis
|
||||||
HOST: redis://:[email protected]:6379/0?pool_size=100&idle_timeout=180s
|
|
||||||
queue:
|
queue:
|
||||||
TYPE: redis
|
TYPE: redis
|
||||||
CONN_STR: redis://:[email protected]:6379/0
|
|
||||||
repository:
|
repository:
|
||||||
DEFAULT_REPO_UNITS: repo.code,repo.releases,repo.issues,repo.pulls
|
DEFAULT_REPO_UNITS: repo.code,repo.releases,repo.issues,repo.pulls
|
||||||
actions:
|
actions:
|
||||||
@@ -99,6 +79,23 @@ spec:
|
|||||||
ui:
|
ui:
|
||||||
THEMES: gitea-auto, gitea-light, gitea-dark, github-auto, github-light, github-dark, github-soft-dark
|
THEMES: gitea-auto, gitea-light, gitea-dark, github-auto, github-light, github-dark, github-soft-dark
|
||||||
DEFAULT_THEME: github-auto
|
DEFAULT_THEME: github-auto
|
||||||
|
additionalConfigFromEnvs:
|
||||||
|
- name: GITEA__DATABASE__PASSWD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: cnpg17-cluster-sh-app
|
||||||
|
key: password
|
||||||
|
- name: REDIS_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: valkey-cluster-sh
|
||||||
|
key: valkey-password
|
||||||
|
- name: GITEA__SESSION__PROVIDER_CONFIG
|
||||||
|
value: "redis://:$(REDIS_PASSWORD)@valkey-cluster-sh-headless.infra-data:6379/0?pool_size=100&idle_timeout=180s"
|
||||||
|
- name: GITEA__CACHE__HOST
|
||||||
|
value: "redis://:$(REDIS_PASSWORD)@valkey-cluster-sh-headless.infra-data:6379/0?pool_size=100&idle_timeout=180s"
|
||||||
|
- name: GITEA__QUEUE__CONN_STR
|
||||||
|
value: "redis://:$(REDIS_PASSWORD)@valkey-cluster-sh-headless.infra-data:6379/0?pool_size=100&idle_timeout=180s"
|
||||||
valkey-cluster:
|
valkey-cluster:
|
||||||
enabled: false
|
enabled: false
|
||||||
extraVolumes:
|
extraVolumes:
|
||||||
@@ -112,6 +109,3 @@ spec:
|
|||||||
- name: gitea-custom-templates-volume
|
- name: gitea-custom-templates-volume
|
||||||
subPath: extra_links.tmpl
|
subPath: extra_links.tmpl
|
||||||
mountPath: /data/gitea/templates/custom/extra_links.tmpl
|
mountPath: /data/gitea/templates/custom/extra_links.tmpl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+1
-1
@@ -2,7 +2,7 @@ apiVersion: networking.k8s.io/v1
|
|||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-static
|
name: gitea-static
|
||||||
namespace: infra-devops
|
namespace: infra-gitops
|
||||||
annotations:
|
annotations:
|
||||||
nginx.ingress.kubernetes.io/use-regex: "true"
|
nginx.ingress.kubernetes.io/use-regex: "true"
|
||||||
nginx.ingress.kubernetes.io/proxy-buffering: "on"
|
nginx.ingress.kubernetes.io/proxy-buffering: "on"
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- helmrelease-gitea.yaml
|
||||||
|
- helmrelease-gitea-actions.yaml
|
||||||
|
- configmap-templates.yaml
|
||||||
|
- configmap-actions-dind.yaml
|
||||||
|
- ingress-static-gitea.yaml
|
||||||
|
- loadbalancer-ssh.yaml
|
||||||
|
- networkpolicy-gitea.yaml
|
||||||
+2
-2
@@ -2,7 +2,7 @@ apiVersion: v1
|
|||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-ssh-lb
|
name: gitea-ssh-lb
|
||||||
namespace: infra-devops
|
namespace: infra-gitops
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
app.kubernetes.io/name: gitea
|
app.kubernetes.io/name: gitea
|
||||||
@@ -11,4 +11,4 @@ spec:
|
|||||||
- protocol: TCP
|
- protocol: TCP
|
||||||
port: 22
|
port: 22
|
||||||
targetPort: 2222
|
targetPort: 2222
|
||||||
type: LoadBalancer
|
type: LoadBalancer
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
name: allow-gitea
|
||||||
|
namespace: infra-gitops
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: gitea
|
||||||
|
ingress:
|
||||||
|
- {}
|
||||||
|
egress:
|
||||||
|
- {}
|
||||||
|
policyTypes:
|
||||||
|
- Ingress
|
||||||
|
- Egress
|
||||||
+21
-24
@@ -1,32 +1,32 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
kind: HelmChart
|
kind: HelmRelease
|
||||||
metadata:
|
metadata:
|
||||||
name: loki
|
name: loki
|
||||||
namespace: infra-monitor
|
namespace: infra-monitor
|
||||||
spec:
|
spec:
|
||||||
repo: https://grafana.github.io/helm-charts
|
interval: 30m
|
||||||
chart: loki
|
chart:
|
||||||
targetNamespace: infra-monitor
|
spec:
|
||||||
version: 6.49.0
|
chart: loki
|
||||||
valuesContent: |-
|
version: 6.53.0
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: grafana
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
values:
|
||||||
deploymentMode: SingleBinary
|
deploymentMode: SingleBinary
|
||||||
gateway:
|
gateway:
|
||||||
enabled: false
|
enabled: false
|
||||||
lokiCanary:
|
lokiCanary:
|
||||||
nodeSelector:
|
|
||||||
svccontroller.k3s.cattle.io/enablelb: "true"
|
|
||||||
extraArgs:
|
extraArgs:
|
||||||
# 降低测试日志生成条数
|
# 降低测试日志生成条数
|
||||||
- -interval=30s
|
- -interval=30s
|
||||||
- -labelname=service_name
|
- -labelname=service_name
|
||||||
- -labelvalue=loki-canary
|
- -labelvalue=loki-canary
|
||||||
resultsCache:
|
resultsCache:
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: tce
|
|
||||||
allocatedMemory: 1024
|
allocatedMemory: 1024
|
||||||
chunksCache:
|
chunksCache:
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: tce
|
|
||||||
allocatedMemory: 1024
|
allocatedMemory: 1024
|
||||||
loki:
|
loki:
|
||||||
auth_enabled: false
|
auth_enabled: false
|
||||||
@@ -37,24 +37,21 @@ spec:
|
|||||||
max_query_series: 10000
|
max_query_series: 10000
|
||||||
volume_enabled: true
|
volume_enabled: true
|
||||||
storage:
|
storage:
|
||||||
type: 'filesystem'
|
type: "filesystem"
|
||||||
schemaConfig:
|
schemaConfig:
|
||||||
configs:
|
configs:
|
||||||
- from: "2024-01-01"
|
- from: "2024-01-01"
|
||||||
store: tsdb
|
store: tsdb
|
||||||
index:
|
index:
|
||||||
prefix: loki_index_
|
prefix: loki_index_
|
||||||
period: 24h
|
period: 24h
|
||||||
object_store: filesystem
|
object_store: filesystem
|
||||||
schema: v13
|
schema: v13
|
||||||
singleBinary:
|
singleBinary:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: tce
|
|
||||||
read:
|
read:
|
||||||
replicas: 0
|
replicas: 0
|
||||||
backend:
|
backend:
|
||||||
replicas: 0
|
replicas: 0
|
||||||
write:
|
write:
|
||||||
replicas: 0
|
replicas: 0
|
||||||
|
|
||||||
+32
-37
@@ -1,14 +1,24 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
kind: HelmChart
|
kind: HelmRelease
|
||||||
metadata:
|
metadata:
|
||||||
name: prometheus
|
name: prometheus
|
||||||
namespace: infra-monitor
|
namespace: infra-monitor
|
||||||
spec:
|
spec:
|
||||||
repo: https://prometheus-community.github.io/helm-charts
|
interval: 30m
|
||||||
chart: kube-prometheus-stack
|
chart:
|
||||||
targetNamespace: infra-monitor
|
spec:
|
||||||
version: 81.0.0
|
chart: kube-prometheus-stack
|
||||||
valuesContent: |-
|
version: 81.6.5
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: prometheus-community
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
install:
|
||||||
|
crds: CreateReplace
|
||||||
|
upgrade:
|
||||||
|
crds: CreateReplace
|
||||||
|
values:
|
||||||
kubeControllerManager:
|
kubeControllerManager:
|
||||||
enabled: false
|
enabled: false
|
||||||
kubeScheduler:
|
kubeScheduler:
|
||||||
@@ -18,26 +28,11 @@ spec:
|
|||||||
kubeEtcd:
|
kubeEtcd:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
||||||
prometheusOperator:
|
prometheusOperator: {}
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: hwa
|
kube-state-metrics: {}
|
||||||
|
|
||||||
kube-state-metrics:
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: hwa
|
|
||||||
|
|
||||||
grafana:
|
grafana:
|
||||||
affinity:
|
|
||||||
podAffinity:
|
|
||||||
preferredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
- weight: 100
|
|
||||||
podAffinityTerm:
|
|
||||||
labelSelector:
|
|
||||||
matchLabels:
|
|
||||||
cnpg.io/cluster: cnpg17-cluster-sh
|
|
||||||
role: primary
|
|
||||||
topologyKey: kubernetes.io/hostname
|
|
||||||
namespaceSelector: {}
|
|
||||||
ingress:
|
ingress:
|
||||||
enabled: true
|
enabled: true
|
||||||
ingressClassName: nginx
|
ingressClassName: nginx
|
||||||
@@ -54,7 +49,14 @@ spec:
|
|||||||
paths:
|
paths:
|
||||||
- /
|
- /
|
||||||
assertNoLeakedSecrets: false
|
assertNoLeakedSecrets: false
|
||||||
|
envValueFrom:
|
||||||
|
GF_DATABASE_PASSWORD:
|
||||||
|
secretKeyRef:
|
||||||
|
name: cnpg17-cluster-sh-app
|
||||||
|
key: password
|
||||||
grafana.ini:
|
grafana.ini:
|
||||||
|
server:
|
||||||
|
root_url: https://monitor.dev.cm/
|
||||||
public_dashboards:
|
public_dashboards:
|
||||||
enabled: false
|
enabled: false
|
||||||
help:
|
help:
|
||||||
@@ -66,23 +68,19 @@ spec:
|
|||||||
host: cnpg17-cluster-sh-rw.infra-data:5432
|
host: cnpg17-cluster-sh-rw.infra-data:5432
|
||||||
name: grafana
|
name: grafana
|
||||||
user: app
|
user: app
|
||||||
password: HueUoQx05DM0ICBPu1GrmBvBXE6NO3poKE6yPqokPv3dPpWvWRLAr3RXSpaL3AZd
|
password: $__env{GF_DATABASE_PASSWORD}
|
||||||
persistence:
|
persistence:
|
||||||
type: pvc
|
type: pvc
|
||||||
enabled: true
|
enabled: true
|
||||||
storageClassName: local-path
|
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
size: 10Gi
|
size: 10Gi
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
prometheusSpec:
|
prometheusSpec:
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: hwa
|
|
||||||
storageSpec:
|
storageSpec:
|
||||||
volumeClaimTemplate:
|
volumeClaimTemplate:
|
||||||
spec:
|
spec:
|
||||||
storageClassName: local-path
|
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
@@ -100,15 +98,12 @@ spec:
|
|||||||
- monitor.dev.cm
|
- monitor.dev.cm
|
||||||
paths:
|
paths:
|
||||||
- /prometheus
|
- /prometheus
|
||||||
|
|
||||||
alertmanager:
|
alertmanager:
|
||||||
alertmanagerSpec:
|
alertmanagerSpec:
|
||||||
nodeSelector:
|
storage:
|
||||||
kubernetes.io/hostname: hwa
|
|
||||||
storage:
|
|
||||||
volumeClaimTemplate:
|
volumeClaimTemplate:
|
||||||
spec:
|
spec:
|
||||||
storageClassName: local-path
|
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
+18
-10
@@ -1,15 +1,21 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
kind: HelmChart
|
kind: HelmRelease
|
||||||
metadata:
|
metadata:
|
||||||
name: loki-promtail
|
name: loki-promtail
|
||||||
namespace: infra-monitor
|
namespace: infra-monitor
|
||||||
spec:
|
spec:
|
||||||
repo: https://grafana.github.io/helm-charts
|
interval: 30m
|
||||||
chart: promtail
|
dependsOn:
|
||||||
targetNamespace: infra-monitor
|
- name: loki
|
||||||
valuesContent: |-
|
chart:
|
||||||
nodeSelector:
|
spec:
|
||||||
svccontroller.k3s.cattle.io/enablelb: "true"
|
chart: promtail
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: grafana
|
||||||
|
namespace: infra-gitops
|
||||||
|
interval: 12h
|
||||||
|
values:
|
||||||
configmap:
|
configmap:
|
||||||
enabled: true
|
enabled: true
|
||||||
config:
|
config:
|
||||||
@@ -19,10 +25,12 @@ spec:
|
|||||||
snippets:
|
snippets:
|
||||||
extraRelabelConfigs:
|
extraRelabelConfigs:
|
||||||
# 匹配 devcm-log-collecting/enabled 标签 只有为true时才收集日志
|
# 匹配 devcm-log-collecting/enabled 标签 只有为true时才收集日志
|
||||||
- source_labels: [__meta_kubernetes_pod_label_devcm_log_collecting_enabled]
|
- source_labels:
|
||||||
|
[__meta_kubernetes_pod_label_devcm_log_collecting_enabled]
|
||||||
action: keep
|
action: keep
|
||||||
regex: true
|
regex: true
|
||||||
# 匹配 devcm-log-collecting/only-errors标签并只保留stderr流
|
# 匹配 devcm-log-collecting/only-errors标签并只保留stderr流
|
||||||
- source_labels: [__meta_kubernetes_pod_label_devcm_log_collecting_only_errors]
|
- source_labels:
|
||||||
|
[__meta_kubernetes_pod_label_devcm_log_collecting_only_errors]
|
||||||
action: drop
|
action: drop
|
||||||
regex: stdout
|
regex: stdout
|
||||||
某些文件未显示,因为此 diff 中更改的文件太多 显示更多
在新议题中引用
屏蔽一个用户