比较提交

17 次代码提交

修改 53 个文件,包含 317 行新增143 行删除
+7 -1
查看文件
@@ -6,9 +6,15 @@ S3_ACCESS_SECRET_KEY=placeholder
DNSPOD_SECRET_ID=placeholder DNSPOD_SECRET_ID=placeholder
DNSPOD_SECRET_KEY=placeholder DNSPOD_SECRET_KEY=placeholder
# Gitea Actions Runner TokenGitea 启动后在 admin → Runners 生成) # Gitea Actions Runner TokenGitea 启动后在 admin → Runners 生成,参见 flux/README.md “部署后手工步骤”
GITEA_ACTIONS_TOKEN=placeholder GITEA_ACTIONS_TOKEN=placeholder
# Flux Operator Web OIDC 凭据(Gitea 启动后创建 OAuth2 应用获取,Redirect URI: https://cd.dev.cm/oauth2/callback # Flux Operator Web OIDC 凭据(Gitea 启动后创建 OAuth2 应用获取,Redirect URI: https://cd.dev.cm/oauth2/callback
FLUX_WEB_OIDC_CLIENT_ID=placeholder FLUX_WEB_OIDC_CLIENT_ID=placeholder
FLUX_WEB_OIDC_CLIENT_SECRET=placeholder FLUX_WEB_OIDC_CLIENT_SECRET=placeholder
# Infra Net 凭据
NET_MAXMIND_LICENSE_KEY=placeholder
NET_CROWDSEC_BOUNCER_API_KEY=placeholder
NET_TURNSTILE_SITE_KEY=placeholder
NET_TURNSTILE_SECRET_KEY=placeholder
-11
查看文件
@@ -7,14 +7,3 @@
#### 应用相关 #### 应用相关
参见 [flux/README.md](flux/README.md) 参见 [flux/README.md](flux/README.md)
`
ssh-keygen -t ed25519 -C "flux" -f ./flux-git-auth -N ""
ssh-keyscan github.com > ./known_hosts
kubectl -n infra-gitops create secret generic flux-git-auth \
--from-file=identity=./flux-git-auth \
--from-file=identity.pub=./flux-git-auth.pub \
--from-file=known_hosts=./known_hosts
`
+65 -18
查看文件
@@ -5,30 +5,64 @@
``` ```
flux/ flux/
├── clusters/ ├── clusters/
── dev-cm/ # 集群级别编排 ── base/ # 基础集群编排,仅部署 infrastructure
├── kustomization.yaml # 资源列表 ├── kustomization.yaml # infrastructure 资源列表
├── sources.yaml # HelmRepository 源 ├── sources.yaml # infrastructure HelmRepository 源
├── kube-system.yaml # CoreDNS / NodeLocalDNS ├── kube-system.yaml # CoreDNS / NodeLocalDNS
├── infra-devops.yaml # cert-manager / reflector / velero ├── infra-devops.yaml # cert-manager / reflector / velero
├── infra-data.yaml # CNPG / Valkey ├── infra-data.yaml # CNPG / Valkey
├── infra-monitor.yaml # Loki / Prometheus (+ post: Promtail) ├── infra-monitor.yaml # Loki / Prometheus (+ post: Promtail)
├── infra-net.yaml # Nginx / CrowdSec / Tailscale ├── infra-net.yaml # Nginx / CrowdSec / Tailscale
── infra-gitops.yaml # Gitea (+ post: Gitea Actions / Flux Web) ── infra-gitops.yaml # Gitea (+ post: Gitea Actions / Flux Web)
└── apps.yaml # Halo / RustDesk / Fillcode / SinceAI └── dev-cm/ # dev-cm 集群 overlay,额外部署 apps
│ ├── kustomization.yaml # 引入 base,并追加 apps / app 依赖层
│ ├── apps-sources.yaml # app HelmRepository 源
│ ├── apps-secrets.yaml # apps namespace 与 app 专属 Secret
│ ├── apps.yaml # Halo / RustDesk / Fillcode / SinceAI
│ └── apps-post.yaml # CDN Ingress(依赖 apps
├── infrastructure/ ├── infrastructure/
│ ├── sources/ # 所有 HelmRepository 定义 │ ├── sources/ # 所有 HelmRepository 定义
│ ├── kube-system/ # CoreDNS 自定义 + NodeLocalDNS │ ├── kube-system/ # CoreDNS 自定义 + NodeLocalDNS
│ ├── infra-devops/ # cert-manager, webhook-dnspod, reflector, velero │ ├── infra-devops/ # cert-manager, webhook-dnspod, reflector, velero
│ │ └── post/ # ClusterIssuer + cert-manager ServiceMonitor values
│ ├── infra-data/ # CNPG operator, Barman, Valkey │ ├── infra-data/ # CNPG operator, Barman, Valkey
│ │ ├── post-1/ # PG Cluster / ObjectStore / databases / LB │ │ ├── post-1/ # PG Cluster / ObjectStore / databases / LB
│ │ └── post-2/ # Reflector secret annotations │ │ └── post-2/ # Reflector secret annotations
│ ├── infra-net/ # ingress-nginx, CrowdSec, Tailscale DERP, 证书 │ ├── infra-net/ # ingress-nginx, CrowdSec, Tailscale DERP, 证书
│ │ └── post/ # CDN Ingress(依赖 apps,打破循环)
│ ├── infra-monitor/ # Loki, Prometheus+Grafana │ ├── infra-monitor/ # Loki, Prometheus+Grafana
│ │ └── post/ # Promtail(依赖 infra-net,打破循环) │ │ └── post/ # Promtail(依赖 infra-net,打破循环)
│ └── infra-gitops/ # Gitea │ └── infra-gitops/ # Gitea
│ └── post/ # Gitea Actions + flux-operator WebOIDC/Ingress │ └── post/ # Gitea Actions + flux-operator WebOIDC/Ingress
└── apps/ # Halo, RustDesk, Whoami, 证书, Ingress └── apps/
├── sources/ # app HelmRepository 定义
├── secrets/ # apps namespace 与 app 专属 Secret
├── post/ # CDN Ingress(依赖 apps,且引用部分 infra 服务)
├── helmrelease-halo.yaml # Halo
├── helmrelease-rustdesk.yaml # RustDesk
└── ... # app 证书与 Ingress
```
## 前置准备
需要提前生成git访问凭证
```shell
ssh-keygen -t ed25519 -C "flux" -f ./flux-git-auth -N ""
ssh-keyscan github.com > ./known_hosts
kubectl -n infra-gitops create secret generic flux-git-auth \
--from-file=identity=./flux-git-auth \
--from-file=identity.pub=./flux-git-auth.pub \
--from-file=known_hosts=./known_hosts
```
然后将 `flux-git-auth.pub` 文件内容添加到远端仓库中
应用flux实例 后续将自动开启部署流程
```shell
kubectl apply -f flux/flux-instance.yaml
``` ```
## 部署顺序 ## 部署顺序
@@ -38,20 +72,31 @@ sources → secrets → kube-system → infra-devops → infra-data → infra-da
→ infra-monitor → infra-net → infra-devops-post → infra-monitor → infra-net → infra-devops-post
→ infra-monitor-post (Promtail) → infra-monitor-post (Promtail)
→ infra-gitops → infra-gitops
→ apps apps-sources → apps-secrets → apps
infra-net-post (CDN Ingress) apps-post (CDN Ingress)
→ infra-gitops-post (suspend=true,需手工凭据) → infra-gitops-post (suspend=true,需手工凭据)
``` ```
Kustomization 间通过 `dependsOn` + `wait: true` 串行等待,避免顺序错乱。 `clusters/base` 只包含到 `infra-gitops-post` 为止的 infrastructure 部署;`apps-sources``apps-secrets``apps``apps-post` 只在 `clusters/dev-cm` 中声明。Kustomization 间通过 `dependsOn` + `wait: true` 串行等待,避免顺序错乱。
## 部署后手工步骤(infra-gitops-post ## 部署后手工步骤(infra-gitops-post
`infra-gitops-post` 默认 `suspend: true`,因为它依赖两类只能在 Gitea 启动后获取的凭据: `infra-gitops-post` 在 base 层硬编码 `spec.suspend: true` 默认暂停,因为它依赖两类只能在 Gitea 启动后获取的凭据:
1. **Flux Operator Web 的 OIDC 客户端** 1. **Flux Operator Web 的 OIDC 客户端**
2. **Gitea Actions Runner Token** 2. **Gitea Actions Runner Token**
凭据就绪、`flux-env` Secret 重新注入后,可以先用 `flux resume kustomization infra-gitops-post -n infra-gitops` 手工放行。
注意:**手工 `resume` 只会修改集群里的 live 对象,不会改 Git 中的期望状态。** 由于 base 层仍然声明了 `spec.suspend: true`,当上层 `Kustomization` 重新协调(如 30 分钟周期、Git 变更、手工 reconcile)时,它会再次把 `infra-gitops-post` 改回暂停。
如果希望恢复后保持开启,需要把 Git 中的期望状态也改掉,例如在环境 overlay(如 `clusters/dev-cm/infra-gitops-post.yaml`)中覆盖:
```yaml
spec:
suspend: false
```
步骤: 步骤:
1. 浏览器访问 `https://git.dev.cm`,首个注册账号自动成为 admin。 1. 浏览器访问 `https://git.dev.cm`,首个注册账号自动成为 admin。
@@ -61,7 +106,7 @@ Kustomization 间通过 `dependsOn` + `wait: true` 串行等待,避免顺序
- 记录 Client ID 与 Client Secret。 - 记录 Client ID 与 Client Secret。
3. **生成 Runner Token** 3. **生成 Runner Token**
- Site Administration → Actions → Runners → Create new Runner → 复制 registration token。 - Site Administration → Actions → Runners → Create new Runner → 复制 registration token。
4. 更新 `k3s/.env` 4. 更新 `.env`
``` ```
FLUX_WEB_OIDC_CLIENT_ID=<step 2 client id> FLUX_WEB_OIDC_CLIENT_ID=<step 2 client id>
@@ -73,7 +118,7 @@ Kustomization 间通过 `dependsOn` + `wait: true` 串行等待,避免顺序
```bash ```bash
kubectl -n infra-gitops create secret generic flux-env \ kubectl -n infra-gitops create secret generic flux-env \
--from-env-file=k3s/.env \ --from-env-file=.env \
--dry-run=client -o yaml | kubectl apply -f - --dry-run=client -o yaml | kubectl apply -f -
flux reconcile kustomization secrets -n infra-gitops flux reconcile kustomization secrets -n infra-gitops
@@ -91,5 +136,7 @@ Kustomization 间通过 `dependsOn` + `wait: true` 串行等待,避免顺序
## 为何拆出 \*-post 层? ## 为何拆出 \*-post 层?
- **`infra-devops-post`**cert-manager 首次安装时不能依赖 `ServiceMonitor` CRD;post 层只在监控栈就绪后下发 `ClusterIssuer` 与可选 values ConfigMap,避免多个 Kustomization 共同管理同一个 HelmRelease。
- **`infra-monitor-post` (Promtail)**Promtail 依赖至少一个带 `devcm-log-collecting/enabled` 标签的 Podingress-nginx);而 `infra-net` 又依赖 `infra-monitor` 的 CRD。Promtail 放到 post 层并 `dependsOn: infra-net`,打破循环。 - **`infra-monitor-post` (Promtail)**Promtail 依赖至少一个带 `devcm-log-collecting/enabled` 标签的 Podingress-nginx);而 `infra-net` 又依赖 `infra-monitor` 的 CRD。Promtail 放到 post 层并 `dependsOn: infra-net`,打破循环。
- **`apps-post` (CDN Ingress)**CDN Ingress 会引用 `apps`、`infra-gitops`、`infra-monitor` 中的服务,因此不属于 base;只在 `dev-cm` 中声明,并依赖对应服务层。
- **`infra-gitops-post` (Gitea Actions + Flux Web)**:凭据必须在 Gitea 启动后手工创建;放在 post 层并默认 suspend,避免阻塞 bootstrap。 - **`infra-gitops-post` (Gitea Actions + Flux Web)**:凭据必须在 Gitea 启动后手工创建;放在 post 层并默认 suspend,避免阻塞 bootstrap。
+2 -2
查看文件
@@ -18,14 +18,14 @@ spec:
values: values:
image: image:
repository: halohub/halo-pro repository: halohub/halo-pro
tag: 2.24.0 tag: 2.24.2
service: service:
type: ClusterIP type: ClusterIP
ingress: ingress:
enabled: true enabled: true
ingressClassName: nginx ingressClassName: nginx
annotations: annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "50m" nginx.ingress.kubernetes.io/proxy-body-size: "100m"
nginx.ingress.kubernetes.io/configuration-snippet: | nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header Accept-Encoding ""; proxy_set_header Accept-Encoding "";
subs_filter_types text/html; subs_filter_types text/html;
+4 -4
查看文件
@@ -4,8 +4,8 @@ metadata:
name: halo-static name: halo-static
namespace: apps namespace: apps
annotations: annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/proxy-buffering: "on" nginx.ingress.kubernetes.io/proxy-buffering: "on"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/configuration-snippet: | nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_cache cache; proxy_cache cache;
proxy_cache_valid 200 302 7d; proxy_cache_valid 200 302 7d;
@@ -17,9 +17,6 @@ metadata:
add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-Status $upstream_cache_status;
spec: spec:
ingressClassName: nginx ingressClassName: nginx
tls:
- hosts:
- dev.cm
rules: rules:
- host: dev.cm - host: dev.cm
http: http:
@@ -31,3 +28,6 @@ spec:
name: halo name: halo
port: port:
number: 80 number: 80
tls:
- hosts:
- dev.cm
-1
查看文件
@@ -4,7 +4,6 @@ metadata:
name: sinceai-shop name: sinceai-shop
namespace: apps namespace: apps
annotations: annotations:
# 302 跳转到https://sinceai.taobao.com/
nginx.ingress.kubernetes.io/configuration-snippet: | nginx.ingress.kubernetes.io/configuration-snippet: |
rewrite ^/(.*)$ https://sinceai.taobao.com/$1? permanent; rewrite ^/(.*)$ https://sinceai.taobao.com/$1? permanent;
spec: spec:
-1
查看文件
@@ -1,7 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- namespace.yaml
- certificate-fillcode-com.yaml - certificate-fillcode-com.yaml
- certificate-sinceai-com.yaml - certificate-sinceai-com.yaml
- helmrelease-halo.yaml - helmrelease-halo.yaml
+4
查看文件
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespaces.yaml
+21
查看文件
@@ -0,0 +1,21 @@
# whoami
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: cowboysysop
namespace: infra-gitops
spec:
interval: 168h
timeout: 5m
url: https://cowboysysop.github.io/charts/
---
# halo
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: halo
namespace: infra-gitops
spec:
interval: 168h
timeout: 5m
url: https://halo-sigs.github.io/charts/
+4
查看文件
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- helm-repositories.yaml
+3
查看文件
@@ -24,6 +24,9 @@ metadata:
name: infra-gitops-post name: infra-gitops-post
namespace: infra-gitops namespace: infra-gitops
spec: spec:
# 默认暂停:post 层依赖 Gitea 启动后才能获取的 OIDC / Runner Token 凭据。
# 凭据就绪并写入 flux-env Secret 后,使用 `flux resume kustomization infra-gitops-post -n infra-gitops` 放行。
suspend: true
interval: 30m interval: 30m
timeout: 15m timeout: 15m
retryInterval: 1m retryInterval: 1m
-19
查看文件
@@ -18,22 +18,3 @@ spec:
- name: infra-devops - name: infra-devops
- name: infra-devops-post - name: infra-devops-post
- name: infra-monitor - name: infra-monitor
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: infra-net-post
namespace: infra-gitops
spec:
interval: 30m
timeout: 15m
retryInterval: 1m
sourceRef:
kind: GitRepository
name: flux
path: ./flux/infrastructure/infra-net/post
prune: true
wait: true
dependsOn:
- name: apps
-1
查看文件
@@ -9,4 +9,3 @@ resources:
- infra-net.yaml - infra-net.yaml
- infra-monitor.yaml - infra-monitor.yaml
- infra-gitops.yaml - infra-gitops.yaml
- apps.yaml
@@ -1,7 +1,7 @@
apiVersion: kustomize.toolkit.fluxcd.io/v1 apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
metadata: metadata:
name: apps name: apps-post
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 30m interval: 30m
@@ -10,9 +10,11 @@ spec:
sourceRef: sourceRef:
kind: GitRepository kind: GitRepository
name: flux name: flux
path: ./flux/apps path: ./flux/apps/post
prune: true prune: true
wait: true
dependsOn: dependsOn:
- name: infra-data-post-2
- name: infra-net - name: infra-net
- name: infra-gitops - name: infra-gitops
- name: infra-monitor
- name: apps
+21
查看文件
@@ -0,0 +1,21 @@
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: apps-secrets
namespace: infra-gitops
spec:
interval: 30m
timeout: 15m
retryInterval: 1m
sourceRef:
kind: GitRepository
name: flux
path: ./flux/apps/secrets
prune: false
wait: true
dependsOn:
- name: apps-sources
postBuild:
substituteFrom:
- kind: Secret
name: flux-env
+17
查看文件
@@ -0,0 +1,17 @@
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: apps-sources
namespace: infra-gitops
spec:
interval: 30m
timeout: 15m
retryInterval: 1m
sourceRef:
kind: GitRepository
name: flux
path: ./flux/apps/sources
prune: true
wait: true
dependsOn:
- name: sources
@@ -2,7 +2,21 @@ apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization kind: Kustomization
metadata: metadata:
name: apps name: apps
namespace: infra-gitops
spec: spec:
interval: 30m
timeout: 15m
retryInterval: 1m
sourceRef:
kind: GitRepository
name: flux
path: ./flux/apps
prune: true
dependsOn:
- name: apps-sources
- name: apps-secrets
- name: infra-data-post-2
- name: infra-net
patches: patches:
- target: - target:
kind: HelmRelease kind: HelmRelease
@@ -23,7 +23,7 @@ spec:
isWALArchiver: true isWALArchiver: true
parameters: parameters:
barmanObjectName: cnpg17-objectstore-hw barmanObjectName: cnpg17-objectstore-hw
serverName: cnpg17-cluster-hk-a serverName: cnpg17-cluster-hk
--- ---
apiVersion: postgresql.cnpg.io/v1 apiVersion: postgresql.cnpg.io/v1
@@ -23,7 +23,7 @@ spec:
isWALArchiver: true isWALArchiver: true
parameters: parameters:
barmanObjectName: cnpg17-objectstore-hw barmanObjectName: cnpg17-objectstore-hw
serverName: cnpg17-cluster-sh-a serverName: cnpg17-cluster-sh
--- ---
apiVersion: postgresql.cnpg.io/v1 apiVersion: postgresql.cnpg.io/v1
@@ -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
@@ -1,7 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ../../../infrastructure/infra-data/post-1/cnpg17-objectstore-hw.yaml - cnpg17-objectstore-hw.yaml
- cnpg17-cluster-hk.yaml - cnpg17-cluster-hk.yaml
- cnpg17-cluster-sh.yaml - cnpg17-cluster-sh.yaml
- databases.yaml - databases.yaml
@@ -3,7 +3,7 @@ kind: Kustomization
metadata: metadata:
name: infra-data-post-1 name: infra-data-post-1
spec: spec:
path: ./flux/clusters/dev-cm/infra-data-post-1 path: ./flux/clusters/dev-cm/infra-data/post-1
patches: patches:
- target: - target:
kind: Cluster kind: Cluster
@@ -3,4 +3,4 @@ kind: Kustomization
metadata: metadata:
name: infra-data-post-2 name: infra-data-post-2
spec: spec:
path: ./flux/clusters/dev-cm/infra-data-post-2 path: ./flux/clusters/dev-cm/infra-data/post-2
@@ -20,9 +20,9 @@ metadata:
kustomize.toolkit.fluxcd.io/prune: disabled kustomize.toolkit.fluxcd.io/prune: disabled
kustomize.toolkit.fluxcd.io/ssa: Merge kustomize.toolkit.fluxcd.io/ssa: Merge
reflector.v1.k8s.emberstack.com/reflection-allowed: "true" 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-allowed-namespaces: "apps,infra-gitops,infra-monitor"
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true" reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "infra-gitops,infra-monitor" reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "apps,infra-gitops,infra-monitor"
--- ---
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
@@ -33,6 +33,6 @@ metadata:
kustomize.toolkit.fluxcd.io/prune: disabled kustomize.toolkit.fluxcd.io/prune: disabled
kustomize.toolkit.fluxcd.io/ssa: Merge kustomize.toolkit.fluxcd.io/ssa: Merge
reflector.v1.k8s.emberstack.com/reflection-allowed: "true" reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "infra-gitops" reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "apps,infra-gitops"
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true" reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "infra-gitops" reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "apps,infra-gitops"
@@ -3,6 +3,7 @@ kind: Kustomization
metadata: metadata:
name: infra-gitops-post name: infra-gitops-post
spec: spec:
suspend: false
patches: patches:
- target: - target:
kind: HelmRelease kind: HelmRelease
@@ -26,7 +26,6 @@ spec:
nameservers: nameservers:
- "169.254.20.10" - "169.254.20.10"
- "10.43.0.10" - "10.43.0.10"
maxmindLicenseKey: "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"
defaultBackend: defaultBackend:
affinity: affinity:
nodeAffinity: nodeAffinity:
+13 -13
查看文件
@@ -2,15 +2,19 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ../base - ../base
- apps-sources.yaml
- apps-secrets.yaml
- apps.yaml
- apps-post.yaml
patches: patches:
- target: - target:
kind: Kustomization kind: Kustomization
name: kube-system name: kube-system
path: patches/kube-system.yaml path: kube-system.yaml
- target: - target:
kind: Kustomization kind: Kustomization
name: infra-devops name: infra-devops
path: patches/infra-devops.yaml path: infra-devops.yaml
- target: - target:
kind: Kustomization kind: Kustomization
name: infra-data name: infra-data
@@ -18,32 +22,28 @@ patches:
- target: - target:
kind: Kustomization kind: Kustomization
name: infra-data-post-1 name: infra-data-post-1
path: infra-data-post-1/patch.yaml path: infra-data/post-1/patch.yaml
- target: - target:
kind: Kustomization kind: Kustomization
name: infra-data-post-2 name: infra-data-post-2
path: infra-data-post-2/patch.yaml path: infra-data/post-2/patch.yaml
- target: - target:
kind: Kustomization kind: Kustomization
name: infra-net name: infra-net
path: patches/infra-net.yaml path: infra-net.yaml
- target: - target:
kind: Kustomization kind: Kustomization
name: infra-monitor name: infra-monitor
path: patches/infra-monitor.yaml path: infra-monitor.yaml
- target: - target:
kind: Kustomization kind: Kustomization
name: infra-monitor-post name: infra-monitor-post
path: patches/infra-monitor-post.yaml path: infra-monitor-post.yaml
- target: - target:
kind: Kustomization kind: Kustomization
name: infra-gitops name: infra-gitops
path: patches/infra-gitops.yaml path: infra-gitops.yaml
- target: - target:
kind: Kustomization kind: Kustomization
name: infra-gitops-post name: infra-gitops-post
path: patches/infra-gitops-post.yaml path: infra-gitops-post.yaml
- target:
kind: Kustomization
name: apps
path: patches/apps.yaml
+19 -1
查看文件
@@ -5,7 +5,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
distribution: distribution:
version: "2.x" version: "2.8.5"
registry: "ghcr.io/fluxcd" registry: "ghcr.io/fluxcd"
artifact: "oci://ghcr.io/controlplaneio-fluxcd/flux-operator-manifests" artifact: "oci://ghcr.io/controlplaneio-fluxcd/flux-operator-manifests"
components: components:
@@ -31,8 +31,26 @@ spec:
name: flux name: flux
kustomize: kustomize:
patches: patches:
# source-controller 需要良好的国际网络环境,优先调度到网络较好的节点上
- target: - target:
kind: Deployment kind: Deployment
name: (source-controller)
patch: |
- op: add
path: /spec/template/spec/affinity
value:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
preference:
matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- clawjp
- target:
kind: Deployment
name: (helm-controller|kustomize-controller|notification-controller)
patch: | patch: |
- op: add - op: add
path: /spec/template/spec/affinity path: /spec/template/spec/affinity
@@ -7,9 +7,9 @@ metadata:
kustomize.toolkit.fluxcd.io/prune: disabled kustomize.toolkit.fluxcd.io/prune: disabled
kustomize.toolkit.fluxcd.io/ssa: Merge kustomize.toolkit.fluxcd.io/ssa: Merge
reflector.v1.k8s.emberstack.com/reflection-allowed: "true" reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "apps,infra-net,infra-gitops,infra-monitor" reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "infra-net,infra-gitops,infra-monitor"
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true" reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "apps,infra-net,infra-gitops,infra-monitor" reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "infra-net,infra-gitops,infra-monitor"
--- ---
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
@@ -18,6 +18,17 @@ spec:
name: imroc name: imroc
namespace: infra-gitops namespace: infra-gitops
interval: 12h interval: 12h
# 启用漂移检测,集群中资源被误删时 Flux 会自动重建
driftDetection:
mode: enabled
# 升级失败或资源被删除时,允许卸载后重装以恢复
install:
remediation:
retries: 3
upgrade:
remediation:
retries: 3
remediateLastFailure: true
values: values:
image: image:
tag: "1.5.2" tag: "1.5.2"
@@ -6,6 +6,11 @@ metadata:
spec: spec:
interval: 30m interval: 30m
timeout: 15m timeout: 15m
valuesFrom:
- kind: ConfigMap
name: cert-manager-runtime-values
valuesKey: values.yaml
optional: true
chart: chart:
spec: spec:
chart: cert-manager chart: cert-manager
@@ -19,8 +24,8 @@ spec:
crds: CreateReplace crds: CreateReplace
upgrade: upgrade:
crds: CreateReplace crds: CreateReplace
# 首次install时servicemonitor=false(CRD尚不存在) # 首次 install 时 ServiceMonitor CRD 尚不存在,保持 chart 默认值 false。
# infra-monitor层部署后通过SSA patch开启 # infra-devops-post 在 CRD 就绪后通过可选 valuesFrom 开启 ServiceMonitor。
values: values:
crds: crds:
enabled: true enabled: true
@@ -28,5 +33,3 @@ spec:
enableCertificateOwnerRef: true enableCertificateOwnerRef: true
prometheus: prometheus:
enabled: true enabled: true
servicemonitor:
enabled: false
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cert-manager-runtime-values
namespace: infra-devops
labels:
reconcile.fluxcd.io/watch: Enabled
data:
values.yaml: |
prometheus:
servicemonitor:
enabled: true
interval: 300s
prometheusInstance: kube-prometheus
@@ -1,24 +0,0 @@
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: cert-manager
namespace: infra-devops
annotations:
kustomize.toolkit.fluxcd.io/prune: disabled
spec:
interval: 30m
chart:
spec:
chart: cert-manager
version: v1.19.3
sourceRef:
kind: HelmRepository
name: jetstack
namespace: infra-gitops
interval: 12h
values:
prometheus:
servicemonitor:
enabled: true
interval: 300s
prometheusInstance: kube-prometheus
@@ -2,4 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- clusterissuer-dnspod.yaml - clusterissuer-dnspod.yaml
- helmrelease-cert-manager-patch.yaml - configmap-cert-manager-runtime-values.yaml
@@ -9,7 +9,7 @@ spec:
chart: chart:
spec: spec:
chart: gitea chart: gitea
version: 12.5.0 version: 12.6.0
sourceRef: sourceRef:
kind: HelmRepository kind: HelmRepository
name: gitea name: gitea
@@ -21,7 +21,7 @@ spec:
postgresql-ha: postgresql-ha:
enabled: false enabled: false
image: image:
tag: 1.25.5 tag: 1.26.2
ingress: ingress:
enabled: true enabled: true
className: nginx className: nginx
@@ -15,6 +15,10 @@ spec:
name: ingress-nginx name: ingress-nginx
namespace: infra-gitops namespace: infra-gitops
interval: 12h interval: 12h
valuesFrom:
- kind: Secret
name: infra-net-env
valuesKey: ingress-nginx-values.yaml
values: values:
fullnameOverride: ingress-nginx fullnameOverride: ingress-nginx
controller: controller:
@@ -125,8 +129,6 @@ spec:
# crowdsec插件配置 # crowdsec插件配置
plugins: "crowdsec" plugins: "crowdsec"
lua-shared-dicts: "crowdsec_cache: 50m" lua-shared-dicts: "crowdsec_cache: 50m"
# 启用geoip2模块
maxmindLicenseKey: ""
extraArgs: extraArgs:
default-ssl-certificate: "infra-net/dev-cm-crt" default-ssl-certificate: "infra-net/dev-cm-crt"
# crowdsec插件配置 # crowdsec插件配置
@@ -140,7 +142,10 @@ spec:
- name: API_URL - name: API_URL
value: "http://crowdsec-service.infra-net.svc.cluster.local:8080" value: "http://crowdsec-service.infra-net.svc.cluster.local:8080"
- name: API_KEY - name: API_KEY
value: "ImxBThnyiNm224V5DHYPY63KPAcyJ+WF0rm18Gr4M80" valueFrom:
secretKeyRef:
name: infra-net-env
key: NET_CROWDSEC_BOUNCER_API_KEY
- name: BOUNCER_CONFIG - name: BOUNCER_CONFIG
value: "/crowdsec/crowdsec-bouncer.conf" value: "/crowdsec/crowdsec-bouncer.conf"
- name: MODE - name: MODE
@@ -154,9 +159,15 @@ spec:
- name: CAPTCHA_PROVIDER - name: CAPTCHA_PROVIDER
value: "turnstile" value: "turnstile"
- name: SITE_KEY - name: SITE_KEY
value: "0x4AAAAAAAxJ2RPNWzn2LCc-" valueFrom:
secretKeyRef:
name: infra-net-env
key: NET_TURNSTILE_SITE_KEY
- name: SECRET_KEY - name: SECRET_KEY
value: "0x4AAAAAAAxJ2dwFOaNg5ae3c6wYTmWH0bU" valueFrom:
secretKeyRef:
name: infra-net-env
key: NET_TURNSTILE_SECRET_KEY
- name: CAPTCHA_TEMPLATE_PATH - name: CAPTCHA_TEMPLATE_PATH
value: /etc/nginx/static/captcha.html value: /etc/nginx/static/captcha.html
command: ['/bin/sh', '-c'] command: ['/bin/sh', '-c']
@@ -0,0 +1,16 @@
# Infra Net 凭据
# 变量来源: flux-env Secret (通过postBuild.substituteFrom注入)
apiVersion: v1
kind: Secret
metadata:
name: infra-net-env
namespace: infra-net
type: Opaque
stringData:
NET_MAXMIND_LICENSE_KEY: "${NET_MAXMIND_LICENSE_KEY}"
NET_CROWDSEC_BOUNCER_API_KEY: "${NET_CROWDSEC_BOUNCER_API_KEY}"
NET_TURNSTILE_SITE_KEY: "${NET_TURNSTILE_SITE_KEY}"
NET_TURNSTILE_SECRET_KEY: "${NET_TURNSTILE_SECRET_KEY}"
ingress-nginx-values.yaml: |
controller:
maxmindLicenseKey: "${NET_MAXMIND_LICENSE_KEY}"
@@ -5,3 +5,4 @@ resources:
- s3-devcm-hw.yaml - s3-devcm-hw.yaml
- dnspod-secret.yaml - dnspod-secret.yaml
- gitea-actions.yaml - gitea-actions.yaml
- infra-net.yaml
@@ -14,3 +14,8 @@ apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
name: infra-gitops name: infra-gitops
---
apiVersion: v1
kind: Namespace
metadata:
name: infra-net
@@ -6,6 +6,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
url: https://charts.jetstack.io url: https://charts.jetstack.io
--- ---
# cert-manager-webhook-dnspod (OCI) # cert-manager-webhook-dnspod (OCI)
@@ -16,6 +17,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
url: https://imroc.github.io/cert-manager-webhook-dnspod url: https://imroc.github.io/cert-manager-webhook-dnspod
--- ---
# reflector # reflector
@@ -26,6 +28,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
url: https://emberstack.github.io/helm-charts url: https://emberstack.github.io/helm-charts
--- ---
# velero # velero
@@ -36,6 +39,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
url: https://vmware-tanzu.github.io/helm-charts url: https://vmware-tanzu.github.io/helm-charts
--- ---
# cloudnative-pg, plugin-barman-cloud # cloudnative-pg, plugin-barman-cloud
@@ -46,6 +50,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
url: https://cloudnative-pg.github.io/charts url: https://cloudnative-pg.github.io/charts
--- ---
# valkey-cluster (OCI) # valkey-cluster (OCI)
@@ -56,6 +61,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
type: oci type: oci
url: oci://docker.m.daocloud.io/bitnamicharts url: oci://docker.m.daocloud.io/bitnamicharts
--- ---
@@ -67,6 +73,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
url: https://kubernetes.github.io/ingress-nginx url: https://kubernetes.github.io/ingress-nginx
--- ---
# crowdsec # crowdsec
@@ -77,6 +84,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
url: https://crowdsecurity.github.io/helm-charts url: https://crowdsecurity.github.io/helm-charts
--- ---
# tailscale-derp, rustdesk-server # tailscale-derp, rustdesk-server
@@ -87,6 +95,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
url: https://devcm-repo.github.io/helm-charts url: https://devcm-repo.github.io/helm-charts
--- ---
# loki, promtail # loki, promtail
@@ -97,6 +106,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
url: https://grafana.github.io/helm-charts url: https://grafana.github.io/helm-charts
--- ---
# kube-prometheus-stack # kube-prometheus-stack
@@ -107,6 +117,7 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
url: https://prometheus-community.github.io/helm-charts url: https://prometheus-community.github.io/helm-charts
--- ---
# gitea, gitea-actions # gitea, gitea-actions
@@ -117,24 +128,6 @@ metadata:
namespace: infra-gitops namespace: infra-gitops
spec: spec:
interval: 168h interval: 168h
timeout: 5m
url: https://dl.gitea.com/charts url: https://dl.gitea.com/charts
--- ---
# whoami
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: cowboysysop
namespace: infra-gitops
spec:
interval: 168h
url: https://cowboysysop.github.io/charts/
---
# halo
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: halo
namespace: infra-gitops
spec:
interval: 168h
url: https://halo-sigs.github.io/charts/
+1 -1
查看文件
@@ -6,7 +6,7 @@ metadata:
spec: spec:
chart: oci://ghcr.io/controlplaneio-fluxcd/charts/flux-operator chart: oci://ghcr.io/controlplaneio-fluxcd/charts/flux-operator
targetNamespace: infra-gitops targetNamespace: infra-gitops
version: 0.46.0 version: 0.48.0
valuesContent: |- valuesContent: |-
affinity: affinity:
nodeAffinity: nodeAffinity: