diff --git a/File/Shell/inotify-check.sh b/File/Shell/inotify-check.sh new file mode 100644 index 0000000..b60a9a0 --- /dev/null +++ b/File/Shell/inotify-check.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +############################################################################################# +# 用途: 查看当前inotify实例使用情况 +# 作者: 丁辉 +# 编写事件: 2025-12-25 +############################################################################################# + +echo "=== Inotify 实例使用统计 ===" +echo "当前配置限制: $(cat /proc/sys/fs/inotify/max_user_instances)" +echo "" + +# 按用户统计 +sudo find /proc/*/fd -lname anon_inode:inotify 2>/dev/null | \ + cut -d/ -f3 | xargs -I '{}' ps --no-headers -o '%U' -p '{}' | \ + sort | uniq -c | sort -nr | head -20 + +echo "" +echo "=== 推荐值计算 ===" +current_used=$(sudo find /proc/*/fd -lname anon_inode:inotify 2>/dev/null | wc -l) +echo "当前使用: $current_used 个实例" +recommended=$((current_used * 3)) +echo "推荐配置: $recommended (当前使用量的3倍)" +echo "最小安全值: $((current_used * 2))" \ No newline at end of file diff --git a/File/Yaml/rustfs-values-distributed.yaml b/File/Yaml/rustfs-values-distributed.yaml new file mode 100644 index 0000000..876088f --- /dev/null +++ b/File/Yaml/rustfs-values-distributed.yaml @@ -0,0 +1,59 @@ +image: + repository: rustfs/rustfs + tag: latest # 部署时使用镜像的版本 + +storageclass: + name: local-path # 更换为自己的 storageClass 存储 + dataStorageSize: 10Gi + logStorageSize: 5Gi + +replicaCount: 4 # 副本数控制(默认为4, 建议至少4个副本以保证分布式存储的可靠性) +mode: + standalone: + enabled: false # 单节点模式(根据自己需求切换) + distributed: + enabled: true # 多节点模式(根据自己需求切换) + +resources: # Pod 资源限制 + requests: + cpu: 500m + memory: 1Gi + limits: + cpu: 1000m + memory: 2Gi + +secret: + rustfs: + access_key: rustfsadmin + secret_key: rustfsadmin + +service: + type: ClusterIP + endpoint: + port: 9000 + console: + port: 9001 + +nodeSelector: + kubernetes.io/os: linux + rustfs: "true" + +ingress: + enabled: false + className: "nginx" # 指定 ingress 控制器, 不指定则需要集群内存在默认的 ingress 控制器 + nginxAnnotations: + nginx.ingress.kubernetes.io/proxy-body-size: "1024m" # 调整文件上传允许传输大小 + nginx.ingress.kubernetes.io/affinity: cookie + nginx.ingress.kubernetes.io/session-cookie-expires: "3600" + nginx.ingress.kubernetes.io/session-cookie-hash: sha1 + nginx.ingress.kubernetes.io/session-cookie-max-age: "3600" + nginx.ingress.kubernetes.io/session-cookie-name: rustfs + hosts: + - host: rustfs.example.com # 更换为自己的域名 + paths: + - path: / + pathType: Prefix + tls: + - hosts: + - rustfs.example.com # 更换为自己的域名 + secretName: rustfs-tls \ No newline at end of file diff --git a/File/Yaml/rustfs-values-standalone.yaml b/File/Yaml/rustfs-values-standalone.yaml new file mode 100644 index 0000000..4d30cf8 --- /dev/null +++ b/File/Yaml/rustfs-values-standalone.yaml @@ -0,0 +1,55 @@ +image: + repository: rustfs/rustfs + tag: latest # 部署时使用镜像的版本 + +storageclass: + name: local-path # 更换为自己的 storageClass 存储 + dataStorageSize: 10Gi + logStorageSize: 5Gi + +replicaCount: 1 # 副本数控制 +mode: + standalone: + enabled: true # 单节点模式(根据自己需求切换) + distributed: + enabled: false # 多节点模式(根据自己需求切换) + +resources: # Pod 资源限制 + requests: + cpu: 500m + memory: 1Gi + limits: + cpu: 1000m + memory: 2Gi + +secret: + rustfs: + access_key: rustfsadmin + secret_key: rustfsadmin + +service: + type: ClusterIP + endpoint: + port: 9000 + console: + port: 9001 + +ingress: + enabled: true + className: "nginx" # 指定 ingress 控制器, 不指定则需要集群内存在默认的 ingress 控制器 + nginxAnnotations: + nginx.ingress.kubernetes.io/proxy-body-size: "1024m" # 调整文件上传允许传输大小 + nginx.ingress.kubernetes.io/affinity: cookie + nginx.ingress.kubernetes.io/session-cookie-expires: "3600" + nginx.ingress.kubernetes.io/session-cookie-hash: sha1 + nginx.ingress.kubernetes.io/session-cookie-max-age: "3600" + nginx.ingress.kubernetes.io/session-cookie-name: rustfs + hosts: + - host: rustfs.example.com # 更换为自己的域名 + paths: + - path: / + pathType: Prefix + tls: + - hosts: + - rustfs.example.com # 更换为自己的域名 + secretName: rustfs-tls \ No newline at end of file diff --git a/Helm/Helm部署Minio替代品RustFS.md b/Helm/Helm部署Minio替代品RustFS.md new file mode 100644 index 0000000..9e76515 --- /dev/null +++ b/Helm/Helm部署Minio替代品RustFS.md @@ -0,0 +1,94 @@ +> 本文作者:丁辉 + +# Helm部署Minio替代品RustFS + +[官方仓库](https://github.com/rustfs/rustfs/tree/main/helm) + +## 安装 RustFS 集群 + +1. 添加 Helm 仓库 + + ```bash + helm repo add rustfs https://charts.rustfs.com + helm repo update + ``` + +2. 下载 rustfs-values.yaml 文件 + + - 单节点部署 + + [查看文件内容](https://gitee.com/offends/Kubernetes/blob/main/File/Yaml/rustfs-values-standalone.yaml) (根据自己情况修改) + + ```bash + wget https://gitee.com/offends/Kubernetes/raw/main/File/Yaml/rustfs-values-standalone.yaml + ``` + + - 集群部署 + + [查看文件内容](https://gitee.com/offends/Kubernetes/blob/main/File/Yaml/rustfs-values-distributed.yaml) (根据自己情况修改) + + ```bash + wget https://gitee.com/offends/Kubernetes/raw/main/File/Yaml/rustfs-values-distributed.yaml + ``` + + 配置节点标签 + + ```bash + kubectl label node ${node} rustfs="true" + ``` + +3. 安装 RustFS 集群 + + - 单节点部署 + + ```bash + helm install \ + rustfs-cluster rustfs/rustfs \ + --namespace rustfs \ + --create-namespace \ + -f rustfs-values-standalone.yaml + ``` + + - 集群部署 + + ```bash + helm install \ + rustfs-cluster rustfs/rustfs \ + --namespace rustfs \ + --create-namespace \ + -f rustfs-values-distributed.yaml + ``` + +4. 配置 Ingress 证书 + + ```bash + kubectl create secret tls rustfs-tls --key nginx.key --cert nginx.pem -n rustfs + ``` + +5. 访问页面 + + 访问地址:rustfs.example.com + + 账号密码:rustfsadmin/rustfsadmin + +## 卸载 + +1. 卸载 RustFS 集群 + + ```bash + helm uninstall rustfs-cluster -n rustfs + ``` + +2. 删除命名空间 + + ```bash + kubectl delete ns rustfs + ``` + +3. 清理 Pvc 资源(生产环境慎重考虑) + + ```bash + kubectl delete pvc -n rustfs --all + ``` + + \ No newline at end of file diff --git a/Helm/Helm部署Nginx-Ingress.md b/Helm/Helm部署Nginx-Ingress.md index 7b9bca3..866b18b 100644 --- a/Helm/Helm部署Nginx-Ingress.md +++ b/Helm/Helm部署Nginx-Ingress.md @@ -20,6 +20,8 @@ 2. 下载模版文件 + [查看文件内容](https://gitee.com/offends/Kubernetes/blob/main/File/Yaml/ingress-values-hostnetwork.yaml) (根据自己情况修改) + ```bash wget https://gitee.com/offends/Kubernetes/raw/main/File/Yaml/ingress-values-hostnetwork.yaml ``` diff --git a/使用文档/其他/Service实现代理外部服务.md b/使用文档/其他/Service实现代理外部服务.md new file mode 100644 index 0000000..6ae1cad --- /dev/null +++ b/使用文档/其他/Service实现代理外部服务.md @@ -0,0 +1,51 @@ +> 本文作者:丁辉 +> + +# Service实现代理外部服务 + +## 基础环境准备 + +部署一个 Docker Nginx 服务暴露本地 10000 端口 + +```bash +docker run -it --rm --name nginx-demo -p 10000:80 nginx:latest +``` + +## 基于 Endpoints 实现 + +1. 创建 Endpoints,Service + + ```yaml + cat < 本文作者:丁辉 + +# Ingress-Annotations参数记录 + +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + ... + annotations: + # 不限制文件上传大小 + nginx.ingress.kubernetes.io/proxy-body-size: "0" + # 告诉Ingress后端是HTTPS + nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" + # 跳过证书验证(自签名时) + nginx.ingress.kubernetes.io/proxy-ssl-verify: "off" + # cert-manager 自动生成证书参数 + cert-manager.io/cluster-issuer: "letsencrypt-prod" + # 开启金丝雀 + nginx.ingress.kubernetes.io/canary: "true" + # 10%流量到金丝雀 + nginx.ingress.kubernetes.io/canary-weight: "10" +``` diff --git a/网关/Ingress/其他/Ingress代理外部服务Teleport.md b/网关/Ingress/其他/Ingress代理外部服务Teleport.md new file mode 100644 index 0000000..c583e9d --- /dev/null +++ b/网关/Ingress/其他/Ingress代理外部服务Teleport.md @@ -0,0 +1,90 @@ +> 本文作者:丁辉 +> + +# Ingress代理外部服务Teleport + +## 准备 + +修改 Teleport 服务为 HTTP 协议 + +```yaml +proxy_service: + enabled: "yes" + web_listen_addr: 0.0.0.0:9443 + public_addr: teleport.example.com:443 # 对外访问地址 +# 删除如下内容 + # https_keypairs: + # - key_file: + # cert_file: + # https_keypairs_reload_interval: 0s + # acme: {} +``` + +## 开启对外访问 + +1. Endpoints 对接外部 Teleport + + ```yaml + cat < 嫌端口太少?来吧循环起来,截止2025年12月2日官方并没有给出特别好的解决办法,只能一个一个写。循环示例如下 + > - 嫌端口太少?来吧循环起来,截止2025年12月2日官方并没有给出特别好的解决办法,只能一个一个写。循环示例如下 > - > ```bash - > $(for p in $(seq 30000 31000); do echo " - containerPort: $p"; echo " hostPort: $p"; echo " protocol: TCP"; echo " listenAddress: 0.0.0.0"; done) - > ``` + > ```bash + > $(for p in $(seq 30000 31000); do echo " - containerPort: $p"; echo " hostPort: $p"; echo " protocol: TCP"; echo " listenAddress: 0.0.0.0"; done) + > ``` + > + > - 去除控制节点污点允许调度 + > + > ```bash + > kubectl taint nodes cluster1-control-plane node-role.kubernetes.io/control-plane:NoSchedule- + > ``` 3. 创建集群 diff --git a/问题记录/日志报文件数超出系统限制问题.md b/问题记录/日志报文件数超出系统限制问题.md index 1cae87b..9b585d9 100644 --- a/问题记录/日志报文件数超出系统限制问题.md +++ b/问题记录/日志报文件数超出系统限制问题.md @@ -8,6 +8,12 @@ ## 解决方法 +**查看当前值** + +```bash +cat /proc/sys/fs/inotify/max_user_instances +``` + - 临时设置 ```bash @@ -21,6 +27,20 @@ sudo sysctl -p ``` +## 脚本计算推荐值 + +1. 下载脚本 + + ```bash + wget https://gitee.com/offends/Kubernetes/raw/main/File/Shell/inotify-check.sh + ``` + +2. 执行脚本 + + ```bash + bash inotify-check.sh + ``` + ### 参数含义 | 参数 | 说明 | @@ -40,3 +60,10 @@ - 如果你的机器上有大量容器或日志文件: - 默认 `max_user_instances` 太小 → Promtail 会报错 `failed to create fsnotify watcher: too many open files` - 提升到 8192 或更高,可以允许单个用户(比如运行 Promtail 的 `root` 或容器内用户)创建更多 inotify watcher。 + +### 推荐值 + +- **一般桌面用户**:512-1024 +- **开发环境**:1024-2048 +- **运行多容器/监控服务**:2048-8192 +- **服务器/特殊情况**:16384 或更高