nacos官网
https://nacos.io/zh-cn/docs/use-nacos-with-kubernetes.html
Kubernetes Nacos
nacos 集群架构
https://blog.csdn.net/u013716737/article/details/130966482
Nacos高可用集群搭建与使用
nacos链接pg数据库,参考
https://blog.csdn.net/longyuhome/article/details/128397593
Nacos2.2使用PostgreSQL数据源插件存储数据手把手教程
#创建一个nodeport类型的service,用于访问nacos网页
参考:
https://blog.csdn.net/weixin_45093078/article/details/131478526
#创建一个nodeport类型的service,用于访问nacos网页
apiVersion: v1
kind: Service
metadata:name: nacos-server namespace: cloud-nacos # 增加命名空间labels:app: nacosannotations:service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:type: NodePortports:- port: 8848name: servertargetPort: 8848nodePort: 30848selector:app: nacoskubectl create -f nacos-pvc-ceph.yaml
#创建完成后访问nacos,网址:http://172.31.246.31:30848/nacos;账号密码:nacos/nacos
---
apiVersion: v1
kind: Service
metadata:name: nacos-headlesslabels:app: nacos-headless
spec:type: ClusterIPclusterIP: Noneports:- port: 8848name: servertargetPort: 8848- port: 9848name: client-rpctargetPort: 9848- port: 9849name: raft-rpctargetPort: 9849## 兼容1.4.x版本的选举端口- port: 7848name: old-raft-rpctargetPort: 7848selector:app: nacos
---
apiVersion: v1
kind: ConfigMap
metadata:name: nacos-cm
data:mysql.host: "mysql"mysql.db.name: "nacos_devtest"mysql.port: "3306"mysql.user: "nacos"mysql.password: "nacos"
---
apiVersion: apps/v1
kind: StatefulSet
metadata:name: nacos
spec:serviceName: nacos-headlessreplicas: 3template:metadata:labels:app: nacosannotations:pod.alpha.kubernetes.io/initialized: "true"spec:affinity:podAntiAffinity:requiredDuringSchedulingIgnoredDuringExecution:- labelSelector:matchExpressions:- key: "app"operator: Invalues:- nacostopologyKey: "kubernetes.io/hostname"containers:- name: nacosimagePullPolicy: Alwaysimage: nacos/nacos-server:latestresources:requests:memory: "2Gi"cpu: "500m"ports:- containerPort: 8848name: client- containerPort: 9848name: client-rpc- containerPort: 9849name: raft-rpc- containerPort: 7848name: old-raft-rpcenv:- name: NACOS_REPLICASvalue: "3"- name: MYSQL_SERVICE_HOSTvalueFrom:configMapKeyRef:name: nacos-cmkey: mysql.host- name: MYSQL_SERVICE_DB_NAMEvalueFrom:configMapKeyRef:name: nacos-cmkey: mysql.db.name- name: MYSQL_SERVICE_PORTvalueFrom:configMapKeyRef:name: nacos-cmkey: mysql.port- name: MYSQL_SERVICE_USERvalueFrom:configMapKeyRef:name: nacos-cmkey: mysql.user- name: MYSQL_SERVICE_PASSWORDvalueFrom:configMapKeyRef:name: nacos-cmkey: mysql.password- name: SPRING_DATASOURCE_PLATFORMvalue: "mysql"- name: NACOS_SERVER_PORTvalue: "8848"- name: NACOS_APPLICATION_PORTvalue: "8848"- name: PREFER_HOST_MODEvalue: "hostname"- name: NACOS_SERVERSvalue: "nacos-0.nacos-headless.default.svc.cluster.local:8848 nacos-1.nacos-headless.default.svc.cluster.local:8848 nacos-2.nacos-headless.default.svc.cluster.local:8848"selector:matchLabels:app: nacos