k8s-nacos.yaml
k8s-nacos部署相关问题在github上查看nacos-k8s中的介绍如果使用外部mysql需要自己创建数据库和表(在release包中conf下的nacos-mysql.sql并非schema.sql)一、具体的文件如下`—apiVersion: v1kind: Servicemetadata:name: nacos-headlessnamespace: pro-nacoslabels:a
·
k8s-nacos部署相关问题
在github上查看nacos-k8s中的介绍
****如果使用外部mysql需要自己创建数据库和表(在release包中conf下的nacos-mysql.sql并非schema.sql)
如果实在2.2版本 在env中加上
- name: SPRING_DATASOURCE_PLATFORM
value: “mysql”****
分别创建clusterip和nodeport service
apiVersion: v1
kind: Service
metadata:
name: nacos
namespace: pro-nacos
labels:
app: nacos
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
ports:
- protocol: TCP
port: 8848
targetPort: 8848
nodePort: 31248
name: nacos-http
- protocol: TCP
port: 9848
targetPort: 9848
name: raft-rpc
nodePort: 32248
selector:
app: nacos
type: NodePort
---
apiVersion: v1
kind: Service
metadata:
name: nacos-headless
namespace: pro-nacos
labels:
app: nacos-headless
spec:
type: ClusterIP
clusterIP: None
ports:
- port: 8848
name: server
targetPort: 8848
- port: 9848
name: client-rpc
targetPort: 9848
- port: 9849
name: raft-rpc
targetPort: 9849
- port: 7848
name: old-raft-rpc
targetPort: 7848
selector:
app: nacos
创建配置文件
apiVersion: v1
kind: ConfigMap
metadata:
name: nacos-cm
namespace: pro-nacos
data:
mysql.db.host: "10.156.156.13"
mysql.db.name: "nacos_config"
mysql.port: "3306"
mysql.user: "nacos"
mysql.password: "nacos"
部署nacos集群
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nacos
namespace: pro-nacos
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: nacos
imagePullPolicy: Always
image: nacos/nacos-server:latest
resources:
requests:
memory: "2Gi"
cpu: "500m"
ports:
- containerPort: 8848
name: client
- containerPort: 9848
name: client-rpc
- containerPort: 9849
name: raft-rpc
- containerPort: 7848
name: old-raft-rpc
env:
- name: NACOS_REPLICAS
value: "3"
- name: MYSQL_SERVICE_HOST
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.db.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.pro-nacos.svc.cluster.local:8848 nacos-1.nacos-headless.pro-nacos.svc.cluster.local:8848 nacos-2.nacos-headless.pro-nacos.svc.cluster.local:8848"
selector:
matchLabels:
app: nacos
创建ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nacos-web
namespace: nacos
spec:
rules:
- host: nacos-web.nacos-demo.com
http:
paths:
- path: /nacos
backend:
serviceName: nacos
servicePort: 8848
更多推荐
已为社区贡献14条内容
所有评论(0)