feat(k8s): 一键部署脚本 + 跨云适配 + 云相关清单拆分到 examples
新增 kubernetes/install.sh(一条命令部署): - 云平台识别:读节点 providerID,识别 TKE / EKS / ACK / CCE / GKE / AKS / K3s / 自建 - StorageClass 三级探测:显式 STORAGE_CLASS → is-default-class 注解 → 集群唯一 SC - 自建集群兜底:无任何 SC 时自动创建静态 local PV (hostPath + DirectoryOrCreate + nodeAffinity + WaitForFirstConsumer + Retain) - Secret 幂等生成:已存在则跳过,绝不覆盖(避免密钥轮换导致历史凭证无法解密) - 失败分类诊断:ImagePullBackOff / CreateContainerConfigError / PVC Pending 按云给出对应仓库格式与推荐 SC 名 - 环境变量:WITH_NODEPORT / STORAGE_CLASS / LOCAL_STORAGE / NODE_NAME / PV_PATH / PV_SIZE 云相关清单拆到 kubernetes/examples/: - ingress.yaml(阿里云 alb)、ingress-tke.yaml(腾讯云 qcloud)、secret.example.yaml - 原因:留在根目录会导致 kubectl apply -f kubernetes/ 时 ingress 同名互相覆盖, 且 secret.example.yaml 的占位符会把真实密钥顶掉 README 重写: - 全部用法速查 + 环境变量一览 - 自建 K8s 存储方案选型(local PV / local-path-provisioner / OpenEBS / Longhorn / NFS) - hostPath 数据运维:定位、热备份、跨节点迁移、卸载保留、常见坑
This commit is contained in:
1 parent
9f7c522157
commit
9a46a955d4
5 files changed
+704
-26
No files matched your search
@@ -0,0 +1,33 @@
|
||||
# 腾讯云 TKE 专用 Ingress 模板
|
||||
#
|
||||
# 与官方 ingress.yaml 的区别:
|
||||
# 官方用 alb(阿里云)→ TKE 不支持
|
||||
# TKE 用 ingressClassName: qcloud,且后端 Service 必须是 NodePort 类型
|
||||
#
|
||||
# 使用前:
|
||||
# 1) 先创建 NodePort Service:kubectl apply -f kubernetes/service-nodeport.yaml
|
||||
# 2) 把下面 host 改成你要用的域名
|
||||
# 3) kubectl apply -f kubernetes/ingress-tke.yaml
|
||||
# 4) 在腾讯云控制台/DNS 把该域名解析到 CLB 的公网 IP
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: opsx-loki
|
||||
namespace: log
|
||||
annotations:
|
||||
# CLB 健康检查(可选,TKE 默认会用 TCP 检查)
|
||||
cloud.tencent.com/health-check-path: /api/v1/health
|
||||
cloud.tencent.com/health-check-interval: "10"
|
||||
spec:
|
||||
ingressClassName: qcloud
|
||||
rules:
|
||||
- host: loki.astx.club # ← 改成你的域名
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: opsx-loki-nodeport # ← 必须是 NodePort 类型 Service
|
||||
port:
|
||||
number: 8080
|
||||
@@ -0,0 +1,24 @@
|
||||
# 可选:通过集群 Ingress 暴露平台 UI。
|
||||
# 阿里云 ACK 用 ALB IngressClass;腾讯 TKE 用 qcloud;华为 CCE 用 nginx/cce。
|
||||
# 若继续走外部 WAF 回源到 Service,则不需要本文件。
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: opsx-loki
|
||||
namespace: log
|
||||
annotations:
|
||||
# 阿里云 ALB 示例;其他云改成对应 ingressClass
|
||||
alb.ingress.kubernetes.io/healthcheck-path: /api/v1/health
|
||||
spec:
|
||||
ingressClassName: alb
|
||||
rules:
|
||||
- host: opsx-loki.91ai.io
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: opsx-loki
|
||||
port:
|
||||
number: 8080
|
||||
@@ -0,0 +1,14 @@
|
||||
# 只做模板:不要提交真实密钥。
|
||||
# 推荐直接用命令创建(避免密钥落盘到 Git):
|
||||
# kubectl -n log create secret generic opsxloki-secrets \
|
||||
# --from-literal=JWT_SECRET="$(openssl rand -hex 32)" \
|
||||
# --from-literal=ENCRYPTION_KEY="$(openssl rand -hex 32)"
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: opsxloki-secrets
|
||||
namespace: log
|
||||
type: Opaque
|
||||
stringData:
|
||||
JWT_SECRET: "REPLACE_WITH_32_BYTES_HEX"
|
||||
ENCRYPTION_KEY: "REPLACE_WITH_32_BYTES_HEX"
|
||||
Reference in new issue
Block a user