k8s部署nacos

kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: nacos-v1
  namespace: health-examination-api
  labels:
    app: nacos
    version: v1
  annotations:
    kubesphere.io/creator: project-admin
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nacos
      version: v1
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nacos
        version: v1
      annotations:
        kubesphere.io/restartedAt: '2021-06-08T07:35:59.555Z'
        logging.kubesphere.io/logsidecar-config: '{}'
    spec:
      containers:
        - name: nacos-v1
          image: 'nacos/nacos-server:1.3.1'
          ports:
            - name: tcp-8848
              containerPort: 8848
              protocol: TCP
          env:
            - name: JVM_XMS
              value: 512m
            - name: JVM_XMX
              value: 512m
            - name: JVM_XMN
              value: 200m
            - name: NACOS_REPLICAS
              value: '2'
            - name: MYSQL_SERVICE_DB_NAME
              valueFrom:
                configMapKeyRef:
                  name: nacos-config
                  key: mysql.db.name
            - name: MYSQL_SERVICE_HOST
              valueFrom:
                configMapKeyRef:
                  name: nacos-config
                  key: mysql.db.host
            - name: MYSQL_SERVICE_PORT
              valueFrom:
                configMapKeyRef:
                  name: nacos-config
                  key: mysql.db.port
            - name: MYSQL_SERVICE_USER
              valueFrom:
                configMapKeyRef:
                  name: nacos-config
                  key: mysql.user
            - name: MYSQL_SERVICE_PASSWORD
              value: ONEhealth!@#
            - name: SPRING_DATASOURCE_PLATFORM
              value: mysql
            - name: NACOS_SERVER_PORT
              value: '8848'
            - name: PREFER_HOST_MODE
              value: hostname
            - name: NACOS_SERVERS
              value: >-
                nacos-v1-0.nacos.health-examination-api.svc.cluster.local:8848
                nacos-v1-1.nacos.health-examination-api.svc.cluster.local:8848
          resources:
            limits:
              cpu: 500m
              memory: 500Mi
          volumeMounts:
            - name: nacos-pvc
              mountPath: /home/nacos/data
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: default
      serviceAccount: default
      securityContext: {}
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app: nacos
                    version: v1
                topologyKey: kubernetes.io/hostname
      schedulerName: default-scheduler
  volumeClaimTemplates:
    - kind: PersistentVolumeClaim
      apiVersion: v1
      metadata:
        name: nacos-pvc
        namespace: health-examination-api
        creationTimestamp: null
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 5Gi
        storageClassName: local
        volumeMode: Filesystem
      status:
        phase: Pending
  serviceName: nacos
  podManagementPolicy: OrderedReady
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      partition: 0
  revisionHistoryLimit: 10


---


kind: Service
apiVersion: v1
metadata:
  name: nacos
  namespace: health-examination-api
  labels:
    app: nacos
    version: v1
  annotations:
    kubesphere.io/creator: project-admin
    kubesphere.io/serviceType: statefulservice
spec:
  ports:
    - name: tcp-8848
      protocol: TCP
      port: 8848
      targetPort: 8848
  selector:
    app: nacos
  clusterIP: None
  type: ClusterIP
  sessionAffinity: None

---

kind: ConfigMap
apiVersion: v1
metadata:
  name: nacos-config
  namespace: health-examination-api
  annotations:
    kubesphere.io/creator: project-admin
data:
  mysql.db.host: '127.0.0.1'
  mysql.db.name: nacos_config
  mysql.db.port: '3306'
  mysql.password: root
  mysql.user: root

---

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: nacos-pvc-nacos-v1-1
  namespace: health-examination-api
  labels:
    app: nacos
    version: v1
  annotations:
    pv.kubernetes.io/bind-completed: 'yes'
    pv.kubernetes.io/bound-by-controller: 'yes'
    volume.beta.kubernetes.io/storage-provisioner: openebs.io/local
    volume.kubernetes.io/selected-node: node1
  finalizers:
    - kubernetes.io/pvc-protection
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
  volumeName: pvc-2625f416-92a8-4ae2-9eee-21f536c600fc
  storageClassName: local
  volumeMode: Filesystem




 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值