k3s k8s 快速部署轻量节点监控方案 beszel

在逛 Reddit 时看到 这篇帖子 发现 beszel 这个熟悉又陌生的名字。看了一下官网发现还支持 kubernetes 的部署,直接使用 daemonset 就可以在所有节点自动部署 agent ,虽然还需要手动在 hub 添加,但已经很方便,用了一下不错。 ...

May 8, 2025 | 1 分钟 | 488 字 | Tianlun Song

k3s-k8s 实现 DevOps 方案横向对比

目前在用 Keel,感觉良好。 主流方案对比 以下是几种可以在 K3s 中实现轻量级 DevOps 解决方案对比: 方案 资源占用 易用性 Web UI 集成能力 配置复杂度 特点 ArgoCD 中等 ★★★★☆ 优秀 原生支持 Git/镜像更新 中等 GitOps 专注,声明式部署 FluxCD 低 ★★★☆☆ 基础(最新版改进) 原生支持 Git/镜像更新 中等 GitOps 专注,自动化程度高 Drone 低 ★★★★☆ 优秀 需配置触发器 低 轻量级,无需 CRD Jenkins X 高 ★★☆☆☆ 良好 丰富 高 功能全面但较重 Tekton 中等 ★★★☆☆ 需安装Dashboard 高度可定制 中高 云原生管道 Keel 极低 ★★★★★ 简单 专注镜像更新 极低 超轻量,专注自动部署 方案详细分析 1. ArgoCD 优势: ...

May 7, 2025 | 2 分钟 | 977 字 | Tianlun Song

k8s 配置访问私有镜像仓库

harbor 私有仓库、aliyun acr 等同理。 创建凭据 以创建 docker-registry-creds 为例,按需调整名称 kubectl create secret docker-registry docker-registry-creds --docker-server="<私有仓库域名>" --docker-email=test@test.com --docker-username='******' --docker-password='******' # 参数解释 # --docker-server 是私有docker仓库全限定域名(FQDN) # --docker-username 是机器人账户的username,需要用单引号引起来。 # --docker-password 是机器人账户生成的token,需要用单引号引起来。 # --docker-email 是docker邮箱(非必须)。 # 这样就成功地将集群中的docker凭据设置为名为docker-registry-creds的secret。 使用凭据 apiVersion: v1 kind: Pod metadata: name: nginx labels: app: nginx spec: containers: - name: nginx image: <私有仓库域名>/kubernetes/nginx:latest ports: - containerPort: 80 imagePullSecrets: - name: docker-registry-creds References Kubernetes配置Secret访问Harbor私有镜像仓库

May 7, 2025 | 1 分钟 | 336 字 | Tianlun Song

Tailscale 自建 DERP 并配置 SSL 完整教程

Tailscale 在很多场景有着广泛应用,k3s 天然有针对它的支持,最近在基于这个方案构建遍布全球的分布式私有网络。官方的 DERP 服务质量并不稳定, 自建后稳定很多,本文记录详细的过程。 ...

April 22, 2025 | 2 分钟 | 819 字 | Tianlun Song

k8s csi-driver-nfs的一个坑

TL;DR 发现 k8s csi 组的社区项目 csi-driver-nfs v4.10 到 v4.11 至少这两个版本存在删除 pv 时会连带将整个根删除的问题。 声明 StorageClass 时虽然支持 subDir ,类似这样: apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: nfs-aliyun-gz provisioner: nfs.csi.k8s.io parameters: share: "/csi" server: "28364f4a1fa-eok75.cn-guangzhou.nas.aliyuncs.com" #server: "172.26.12.20" #subDir: "${pvc.metadata.namespace}/${pvc.metadata.name}" reclaimPolicy: Delete #volumeBindingMode: WaitForFirstConsumer volumeBindingMode: Immediate allowVolumeExpansion: true mountOptions: # - nolock,tcp,noresvport - vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 但如果类似这样使用 subDir 声明路径,同命名空间下的其他 pvc 删除,会导致整个 subDir 根目录都被删除。目前官方 pr 已经修复,但实测还是有问题,有空再研究一下代码,不知道是不是刻意为之。 ...

March 31, 2025 | 1 分钟 | 334 字 | Tianlun Song

k3s 容器 mirror 配置方法

TL; DR root@tencent-sh1:~# cat /etc/rancher/k3s/registries.yaml mirrors: "docker.io": endpoint: - "https://harbor.xxx.me" rewrite: "^(.*)": "mirror-dockerhub/$1" "registry.k8s.io": endpoint: - "https://harbor.xxx.me" rewrite: "^(.*)": "mirror-registry-k8s-io/$1" "ghcr.io": endpoint: - "https://harbor.xxx.me" rewrite: "^(.*)": "mirror-registry-ghcr-io/$1" "quay.io": endpoint: - "https://harbor.xxx.me" rewrite: "^(.*)": "mirror-registry-quay-io/$1" 以上是我的配置,在 harbor 中镜像以上镜像源,之后这样 配置即可。 如果没有路径,比如使用 registry 镜像,忽略 rewrite 部分即可。 ...

March 31, 2025 | 1 分钟 | 98 字 | Tianlun Song

k8s 使用 pv-migrate 迁移 pvc

TL;DR 安装 wget https://github.com/utkuozdemir/pv-migrate/releases/download/v1.7.1/pv-migrate_v1.7.1_linux_x86_64.tar.gz tar -xvf pv-migrate_v1.7.1_linux_x86_64.tar.gz mv pv-migrate /usr/local/bin 用法 pv-migrate migrate \ --source-namespace default \ --dest-namespace default \ localpv-vol csi-lvmpv 🚀 Starting migration 💭 Will attempt 3 strategies: mnt2, svc, lbsvc 🚁 Attempting strategy: mnt2 📂 Copying data... 100% |██████████████████████████████| (3.4 GB/s) 📂 Copying data... 0% | | [0s:0s]🧹 Cleaning up 📂 Copying data... 100% |██████████████████████████████| ✨ Cleanup done ✅ Migration succeeded References Migration from Legacy Storage to Latest Storage Solution https://github.com/utkuozdemir/pv-migrate

March 14, 2025 | 1 分钟 | 145 字 | Tianlun Song

k8s 使用 OpenEBS 存储

TL;DR helm repo add openebs https://openebs.github.io/openebs helm repo update # 以默认值安装 helm install openebs --namespace openebs openebs/openebs --create-namespace # 禁用副本存储类型、lvm 本地存储、zfs本地存储,仅保留本地路径存储 helm install openebs --namespace openebs openebs/openebs --set engines.replicated.mayastor.enabled=false --set engines.local.lvm.enabled=false --set engines.local.zfs.enabled=fa lse --create-namespace E0311 06:22:00.794754 111105 round_tripper.go:63] CancelRequest not implemented by *kube.RetryingRoundTripper NAME: openebs LAST DEPLOYED: Tue Mar 11 06:21:28 2025 NAMESPACE: openebs STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: Successfully installed OpenEBS. Check the status by running: kubectl get pods -n openebs The default values will install both Local PV and Replicated PV. However, the Replicated PV will require additional configuration to be fuctional. The Local PV offers non-replicated local storage using 3 different storage backends i.e Hostpath, LVM and ZFS, while the Replicated PV provides one replicated highly-available storage backend i.e Mayastor. For more information, - view the online documentation at https://openebs.io/docs - connect with an active community on our Kubernetes slack channel. - Sign up to Kubernetes slack: https://slack.k8s.io - #openebs channel: https://kubernetes.slack.com/messages/openebs 实际使用需充分阅读官方文档。 ...

March 14, 2025 | 2 分钟 | 739 字 | Tianlun Song

k3s 部署 kube-prometheus-stack 监控栈

TL;DR $ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts $ helm repo update $ helm show values prometheus-community/kube-prometheus-stack $ helm show values prometheus-community/kube-prometheus-stack > values.yaml # Edit values.yaml $ helm install prometheus-community prometheus-community/kube-prometheus-stack --namespace monitoring -f values.yaml --create-namespace # update values.yaml $ helm upgrade --install prometheus-community prometheus-community/kube-prometheus-stack --namespace monitoring -f values.yaml References kube-prometheus-stack 实战指南:使用 kube-prometheus-stack 监控 K3s 集群

March 14, 2025 | 1 分钟 | 64 字 | Tianlun Song

k8s-k3s 标记节点暂时不可用及排空

TL;DR # 标记为不可调度 kubectl cordon NODE # 将运行的pod平滑的赶到其他节点上 kubectl drain NODE # 重新变得可调度 kubectl uncordon NODE References K8S中的cordon、uncordon和drain kubectl cordon

March 14, 2025 | 1 分钟 | 73 字 | Tianlun Song