- 部署文件(将namespace替换成自己的)
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: nacos-cluster
namespace: kp-k8s
labels:
app: nacos-cluster
annotations:
kubesphere.io/alias-name: nacos-cluster
kubesphere.io/creator: admin
spec:
replicas: 3
selector:
matchLabels:
app: nacos-cluster
template:
metadata:
creationTimestamp: null
labels:
app: nacos-cluster
annotations:
kubesphere.io/containerSecrets: ''
spec:
containers:
- name: nacos-cluster
image: 'nacos/nacos-server:1.4.2'
ports:
- name: client
containerPort: 8848
protocol: TCP
env:
- name: NACOS_REPLICAS
value: '3'
- name: MYSQL_SERVICE_HOST
value: testmysql.local.yjzhixue.com
- name: MYSQL_SERVICE_DB_NAME
value: nacos
- name: MYSQL_SERVICE_PORT
value: '3306'
- name: MYSQL_SERVICE_USER
value: root
- name: MYSQL_SERVICE_PASSWORD
value: '213234asedf'
- name: MODE
value: cluster
- name: NACOS_SERVER_PORT
value: '8848'
- name: PREFER_HOST_MODE
value: hostname
- name: NACOS_SERVERS
value: >-
nacos-cluster-0.nacos-headless.kp-k8s.svc.cluster.local:8848
nacos-cluster-1.nacos-headless.kp-k8s.svc.cluster.local:8848
nacos-cluster-2.nacos-headless.kp-k8s.svc.cluster.local:8848
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
serviceAccountName: default
serviceAccount: default
securityContext: {}
affinity: {}
schedulerName: default-scheduler
serviceName: nacos-headless
podManagementPolicy: OrderedReady
updateStrategy:
type: RollingUpdate
rollingUpdate:
partition: 0
revisionHistoryLimit: 10
---
kind: Service
apiVersion: v1
metadata:
name: nacos-headless
namespace: kp-k8s
labels:
app: nacos-cluster
annotations:
kubesphere.io/alias-name: nacos-cluster
kubesphere.io/creator: admin
kubesphere.io/serviceType: statefulservice
spec:
ports:
- name: client
protocol: TCP
port: 8848
targetPort: 8848
selector:
app: nacos-cluster
type: NodePort
sessionAffinity: None
externalTrafficPolicy: Cluster
注意:本文归作者所有,未经作者允许,不得转载