150 lines
4.0 KiB
YAML
150 lines
4.0 KiB
YAML
###使用自建数据库;使用Ingress发布配置后台###
|
||
---
|
||
apiVersion: v1
|
||
kind: Service
|
||
metadata:
|
||
name: nacos
|
||
labels:
|
||
app: nacos
|
||
spec:
|
||
type: ClusterIP
|
||
selector:
|
||
app: nacos
|
||
ports:
|
||
- port: 8848
|
||
name: server
|
||
targetPort: 8848
|
||
- port: 9848
|
||
name: client-rpc
|
||
targetPort: 9848
|
||
- port: 9849
|
||
name: raft-rpc
|
||
targetPort: 9849
|
||
---
|
||
apiVersion: v1
|
||
kind: ConfigMap
|
||
metadata:
|
||
name: nacos-cm
|
||
data:
|
||
mysql.host: "mysql"
|
||
mysql.db.name: "nacos"
|
||
mysql.port: "3306"
|
||
mysql.user: "root"
|
||
mysql.password: "Admin@2099"
|
||
---
|
||
apiVersion: apps/v1
|
||
kind: StatefulSet
|
||
metadata:
|
||
name: nacos
|
||
spec:
|
||
serviceName: nacos
|
||
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:v2.2.2
|
||
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.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: MYSQL_SERVICE_DB_PARAM
|
||
value: "characterEncoding=utf8&connectTimeout=10000&socketTimeout=30000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true"
|
||
- name: SPRING_DATASOURCE_PLATFORM
|
||
value: "mysql"
|
||
- name: MODE
|
||
value: "cluster"
|
||
- name: NACOS_SERVER_PORT
|
||
value: "8848"
|
||
- name: PREFER_HOST_MODE
|
||
value: "hostname"
|
||
- name: NACOS_SERVERS
|
||
value: "nacos-0.nacos.common.svc.cluster.local:8848 nacos-1.nacos.common.svc.cluster.local:8848 nacos-2.nacos.common.svc.cluster.local:8848"
|
||
- name: NACOS_AUTH_ENABLE
|
||
value: "true"
|
||
- name: NACOS_AUTH_TOKEN
|
||
value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg=="
|
||
- name: NACOS_AUTH_IDENTITY_KEY
|
||
value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg=="
|
||
- name: NACOS_AUTH_IDENTITY_VALUE
|
||
value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg=="
|
||
selector:
|
||
matchLabels:
|
||
selector:
|
||
matchLabels:
|
||
selector:
|
||
matchLabels:
|
||
app: nacos
|
||
|
||
---
|
||
# ------------------- App Ingress ------------------- #
|
||
apiVersion: networking.k8s.io/v1
|
||
kind: Ingress
|
||
metadata:
|
||
name: nacos
|
||
spec:
|
||
rules:
|
||
- host: nacos.beaconfireinc.com
|
||
http:
|
||
paths:
|
||
- path: /nacos
|
||
pathType: Prefix
|
||
backend:
|
||
service:
|
||
name: nacos
|
||
port:
|
||
name: server
|