惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
J
Java Code Geeks
D
DataBreaches.Net
B
Blog RSS Feed
D
Docker
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
F
Fortinet All Blogs
Y
Y Combinator Blog
A
About on SuperTechFans
V
V2EX
罗磊的独立博客
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
Last Week in AI
Last Week in AI
S
SegmentFault 最新的问题
月光博客
月光博客
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
阮一峰的网络日志
阮一峰的网络日志

博客园 - cn2025

K8s -sentinel-dashboard【nacos版本】集 20260815 kubeSphere【ks-controller-manager-webhook-cert】证书 20260814 K8s - 安装部署redis集群-哨兵sentinels集(支持从K8s外部访问)20260812 k8s-deployment发布测试(pv-pvc-deployment-service) 20260810 K8s - 安装部署Kafka、Zookeeper集群教程(支持从K8s外部访问)20260808 k8s-关机及启动脚本工具 【kubeSphere发布ruoyi-pro前端】工具脚本20260731 【k8s】 etcd服务端及客户端版本及快照【定时】备份 20260730 harbor【https启用】及k8节点部证书20260728 kube-flannel.yml k8s集群-安装helm 【kubeShpere】 官网 20260710 kubesphere-KDP 工具脚本【kubeSphere发布ruoyi-pro前端】20260720 HbuilderX 内置终端转为 gitBash 20260720 kubeSphere发布ruoyi-pro后端-用到脚本 kubeSphere发布ruoyi-web前端 20260711 kubeSphere发布ruoyi-pro后端 k8s集群-kubeShpere 20260710 安装Helm 20260710 k8s-portainer docker 镜像查询 k8集群一键重置 docker run OceanBase spring ai alibaba doc AI2.0 【多模态】 20260615 世界只有一个墨脱 AI2.0 【Mcp-client】 20260611 AI2.0 【Mcp-server】 20260611 GoLand 配Go SDK AI2.0 【redis向量-Rag】 问答顾问器QuestionAnswerAdvisor 20260608
K8s -nacos集 20260813
2026cn · 2026-08-13 · via 博客园 - cn2025

一、k8s节点及nacos库

master:192.168.91.166

node2:192.168.91.167

node3:192.168.91.168

image

K8s 集群:1 主 2 节点(k8s-master:192.168.91.166、node2:167、node3:168)
Nacos 镜像:swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nacos/nacos-server:latest
Nacos 库存:192.168.91.165  ry-config   

image


二、创建nacos集群

1、创建命名空间

 kubectl create namespace nacos-cluster

 2、创建nocos  PV

 2.1、 创建本地PV存储

##创建本地PV存储
kubectl apply -f nacos-pv.yaml

####查看 kubectl get pv

image

image

 2.2、 nacos-pv.yaml内容

apiVersion: v1
kind: PersistentVolume
metadata:
name: nacos-data-pv-0
spec:
storageClassName: local-path
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/nacos/data0
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: nacos-data-pv-1
spec:
storageClassName: local-path
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/nacos/data1
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: nacos-data-pv-2
spec:
storageClassName: local-path
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/nacos/data2
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: nacos-log-pv-0
spec:
storageClassName: local-path
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/nacos/log0
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: nacos-log-pv-1
spec:
storageClassName: local-path
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/nacos/log1
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: nacos-log-pv-2
spec:
storageClassName: local-path
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/nacos/log2

3、创建nocos  StatefulSet

nacos-cluster.yaml(无头 Service + StatefulSet 集群核心)

 3.1、 创建本地StatefulSet

##创建本地StatefulSet
kubectl apply -f nacos-cluster.yaml

####查看 kubectl get pvc,pod,svc -n  nacos-cluster

kubectl get pvc,pod ,svc -n  nacos-cluster

image

image

image

image

 3.2、 nacos-cluster.yaml内容


# 无头服务:集群内部节点通信专用
apiVersion: v1
kind: Service
metadata:
name: nacos-headless
namespace: nacos-cluster
labels:
app: nacos
spec:
selector:
app: nacos
ports:
- port: 8848
name: http
targetPort: 8848
- port: 9848
name: rpc
targetPort: 9848
- port: 7848
name: raft
targetPort: 7848
clusterIP: None

---
# 有状态副本集
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nacos
namespace: nacos-cluster
spec:
replicas: 3
selector:
matchLabels:
app: nacos
serviceName: nacos-headless
template:
metadata:
labels:
app: nacos
spec:
containers:
- name: nacos
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nacos/nacos-server:latest
ports:
- containerPort: 8848
name: http
- containerPort: 9848
name: rpc
- containerPort: 7848
name: raft
env:
# 开启集群模式
- name: MODE
value: "cluster"
# 集群节点完整域名(适配nacos-cluster命名空间)
- name: NACOS_SERVERS
value: "nacos-0.nacos-headless.nacos-cluster.svc.cluster.local:8848,nacos-1.nacos-headless.nacos-cluster.svc.cluster.local:8848,nacos-2.nacos-headless.nacos-cluster.svc.cluster.local:8848"
# MySQL连接配置
- name: SPRING_DATASOURCE_PLATFORM
value: "mysql"
- name: MYSQL_SERVICE_HOST
value: "192.168.91.165"
- name: MYSQL_SERVICE_PORT
value: "3306"
- name: MYSQL_SERVICE_DB_NAME
value: "ry-config"
- name: MYSQL_SERVICE_USER
value: "root"
- name: MYSQL_SERVICE_PASSWORD
value: "root"
# 时区
- name: TZ
value: "Asia/Shanghai"
# 资源配额
resources:
requests:
cpu: 500m
memory: 512Mi
limits:
cpu: 1000m
memory: 1Gi
# 存储挂载
volumeMounts:
- name: nacos-data
mountPath: /home/nacos/plugins/raft/data
- name: nacos-logs
mountPath: /home/nacos/logs
# PVC自动生成模板
volumeClaimTemplates:
- metadata:
name: nacos-data
namespace: nacos-cluster
spec:
storageClassName: local-path
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
- metadata:
name: nacos-logs
namespace: nacos-cluster
spec:
storageClassName: local-path
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi

4、创建nocos  service

nacos-service.yaml(NodePort 外网访问入口)

 4.1、 创建service(NodePort 外网访问入口)

##创建本地service
kubectl apply -f nacos-service.yaml

####查看 kubectl get svc -n  nacos-cluster

kubectl get svc -n  nacos-cluster

image

image

 4.2、 nacos-service.yaml内容

apiVersion: v1
kind: Service
metadata:
name: nacos-nodeport
namespace: nacos-cluster
spec:
selector:
app: nacos
type: NodePort
ports:
- port: 8848
targetPort: 8848
nodePort: 30848 ##对外端口
name: web

5、nocos地址

http://192.168.91.168:30085/nacos/

image