apiVersion: v1
kind: ConfigMap
metadata:
name: nacos-mysql
namespace: public-service
data:
mysql.db.name: nacos
mysql.user: nacos
mysql.port: "3306"
---
apiVersion: v1
kind: Secret
metadata:
name: nacos-mysql
namespace: public-service
data:
user.nacos.password: N2VEN3JJRW5zN1Y= # 用户密码以1234567为例
apiVersion: v1
kind: Service
metadata:
name: nacos-headless
namespace: default
labels:
app: nacos
version: v1
spec:
publishNotReadyAddresses: true
ports:
- port: 8848
name: server
targetPort: 8848
- port: 9848
name: client-rpc
targetPort: 9848
- port: 9849
name: raft-rpc
targetPort: 9849
## 兼容1.4.x版本的选举端
- port: 7848
name: old-raft-rpc
targetPort: 7848
clusterIP: None
selector:
app: nacos
version: v1
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nacos
namespace: public-service
labels:
app: nacos
component: nacos
version: v1
spec:
podManagementPolicy: Parallel
serviceName: nacos-headless
replicas: 3
template:
metadata:
labels:
app: nacos
component: nacos
version: v1
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec: # 可选配置反亲和
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- nacos
topologyKey: "kubernetes.io/hostname"
initContainers:
- name: peer-finder-plugin-install
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nacos/nacos-peer-finder-plugin:1.1
imagePullPolicy: Always
volumeMounts:
- mountPath: /home/nacos/plugins/peer-finder
name: nacos-storage
subPath: peer-finder
containers:
- name: nacos
imagePullPolicy: IfNotPresent
image: docker.io/nacos/nacos-server:2.0.2
resources:
requests:
memory: "2Gi"
cpu: "500m"
ports:
- containerPort: 8848
name: client-port
- containerPort: 9848
name: client-rpc
- containerPort: 9849
name: raft-rpc
- containerPort: 7848
name: old-raft-rpc
env:
- name: NACOS_REPLICAS
value: "3"
- name: SERVICE_NAME
value: "nacos-headless"
- name: DOMAIN_NAME
value: "cluster.local"
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: MYSQL_SERVICE_HOST # mysql 地址
value: shiye-ali-public.rwlb.rds.aliyuncs.com
- name: MYSQL_SERVICE_DB_NAME # mysql database名称
valueFrom:
configMapKeyRef:
name: nacos-mysql
key: mysql.db.name
- name: MYSQL_SERVICE_PORT # mysql 端口
valueFrom:
configMapKeyRef:
name: nacos-mysql
key: mysql.port
- name: MYSQL_SERVICE_USER # 数据库用户名
valueFrom:
configMapKeyRef:
name: nacos-mysql
key: mysql.user
- name: MYSQL_SERVICE_PASSWORD # 数据库用户密码
valueFrom:
secretKeyRef:
name: nacos-mysql
key: user.nacos.password
- name: SPRING_DATASOURCE_PLATFORM # 数据库类型,只支持mysql或embedded(嵌入式数据库)
value: "mysql"
- name: NACOS_SERVER_PORT #
value: "8848"
- name: NACOS_APPLICATION_PORT # 指定nacos 运行端口
value: "8848"
- name: PREFER_HOST_MODE # nacos 支持ip还是域名模式,可选ip或hostname(默认ip),k8s statefulset使用集群内域名固定pod地址,此处选hostname
value: "hostname"
volumeMounts:
- name: nacos-storage
mountPath: /home/nacos/plugins/peer-finder
subPath: peer-finder
- name: nacos-storage
mountPath: /home/nacos/data
subPath: data
- name: nacos-storage
mountPath: /home/nacos/logs
subPath: logs
volumeClaimTemplates:
- metadata:
name: nacos-storage
spec:
accessModes: [ "ReadWriteMany" ]
resources:
requests:
storage: 2Gi
storageClassName: nfs-storage
selector:
matchLabels:
app: nacos
component: nacos
version: v1
apiVersion: v1
kind: Service
metadata:
name: nacos
namespace: public-service
labels:
app: nacos
component: nacos
spec:
ports:
- name: server
protocol: TCP
port: 8848
targetPort: server
- name: rpc
protocol: TCP
port: 7848
targetPort: rpc
- name: new-rpc
protocol: TCP
port: 9848
targetPort: new-rpc
selector:
app: nacos
component: nacos
type: ClusterIP
nacos
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 服务启动时一直抛出异常信息:Nacos serialize for class [com.alibaba.naco...
- nacos服务中心能正常使用,但是加入配置中心时出现了下面问题!!!测试了一番,虽然一直在持续报错,但是服务和配置...
- nacos[https://so.csdn.net/so/search?q=nacos&spm=1001.2101...
- 3.1 服务发现数据模型 Nacos在经过阿里内部多年生产经验后提炼出的数据模型,则是一种服务-集群-实例的三层模...
- 背景 公司使用nacos-discovery作为服务注册和服务发现,使用nacos-conf作为配置中心,通信的方...