k8s部署 nacos 集群
官网连接参考https://nacos.io/zh-cn/docs/quick-start.html直接上yaml文件cat <<END> nacos.yamlapiVersion: v1kind: Servicemetadata:name: nacos-headlessnamespace: zhihui-hrlabels:app: nacos-headlessspec:type
·
- 官网连接参考
https://nacos.io/zh-cn/docs/quick-start.html
直接上yaml文件
cat <<END> nacos.yaml
apiVersion: v1
kind: Service
metadata:
name: nacos-headless
namespace: zhihui-hr
labels:
app: nacos-headless
spec:
type: ClusterIP
clusterIP: None
ports:
- port: 8848
name: server
targetPort: 8848
- port: 7848
name: rpc
targetPort: 7848
clusterIP: None
selector:
app: nacos
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nacos-cm
namespace: zhihui-hr
data:
mysql.host: "10.0.3.5"
mysql.db.name: "nacos"
mysql.port: "3306"
mysql.user: "nacos"
mysql.password: "123c4"
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nacos
namespace: zhihui-hr
spec:
serviceName: nacos-headless
replicas: 3
template:
metadata:
labels:
app: nacos
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- nacos
topologyKey: "kubernetes.io/hostname"
containers:
- name: k8snacos
imagePullPolicy: Always
#image: nacos/nacos-server:latest
image: ccr.ccs.tencentyun.com/libary/mylbary:nacos
resources:
limits:
cpu: "6000m"
memory: "4Gi"
requests:
memory: "1Gi"
cpu: "500m"
ports:
- containerPort: 8848
name: client
- containerPort: 7848
name: rpc
env:
- name: NACOS_REPLICAS
value: "3"
- name: MYSQL_SERVICE_HOST
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.host
- name: MYSQL_SERVICE_DB_NAME
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.db.name
- name: MYSQL_SERVICE_PORT
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.port
- name: MYSQL_SERVICE_USER
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.user
- name: MYSQL_SERVICE_PASSWORD
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.password
- name: MODE
value: "cluster"
- name: NACOS_SERVER_PORT
value: "8848"
- name: PREFER_HOST_MODE
value: "hostname"
- name: NACOS_SERVERS
value: "nacos-0.nacos-headless.zhihui-hr.svc.cluster.local:8848 nacos-1.nacos-headless.zhihui-hr.svc.cluster.local:8848 nacos-2.nacos-headless.zhihui-hr.svc.cluster.local:8848"
selector:
matchLabels:
app: nacos
---
# ------------------- App Ingress ------------------- #
#apiVersion: extensions/v1beta1
#kind: Ingress
#metadata:
# name: nacos-headless
# namespace: default
#
#spec:
# rules:
# - host: nacos-web.nacos-demo.com
# http:
# paths:
# - path: /
# backend:
# serviceName: nacos-headless
# servicePort: server
END
- svc
apiVersion: v1
kind: Service
metadata:
name: nacos-svc
namespace: zhihui-hr
labels:
app: nacos-headless
spec:
type: NodePort
ports:
- port: 8848
name: server
targetPort: 8848
nodePort: 31113
- port: 7848
name: rpc
targetPort: 7848
selector:
app: nacos
- dns解析必须全部一致
更多推荐
已为社区贡献82条内容
所有评论(0)