当前位置: 首页 > article >正文

nacos集群部署

GitHub - nacos-group/nacos-k8s: This project contains a Nacos Docker image meant to facilitate the deployment of Nacos on Kubernetes using StatefulSets.

需要修改两个文件

---
apiVersion: v1
kind: Service
metadata:
  name: nacos-headless
  namespace: project-gulimall
  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
    ## 兼容1.4.x版本的选举端口
    - port: 7848
      name: old-raft-rpc
      targetPort: 7848
  selector:
    app: nacos
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: nacos-cm
  namespace: project-gulimall
data:
  mysql.host: "mysql"
  mysql.db.name: "nacos_devtest"
  mysql.port: "3306"
  mysql.user: "nacos"
  mysql.password: "nacos"
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nacos
  namespace: project-gulimall
spec:
  serviceName: nacos-headless
  replicas: 3
  template:
    metadata:
      labels:
        app: nacos
      annotations:
        pod.alpha.kubernetes.io/initialized: "true"
    spec:
      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.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: SPRING_DATASOURCE_PLATFORM
              value: "mysql"
            - name: NACOS_SERVER_PORT
              value: "8848"
            - name: NACOS_APPLICATION_PORT
              value: "8848"
            - name: PREFER_HOST_MODE
              value: "hostname"
            - name: NACOS_SERVERS
              value: "nacos-0.nacos-headless.project-gulimall.svc.cluster.local:8848 nacos-1.nacos-headless.project-gulimall.svc.cluster.local:8848 nacos-2.nacos-headless.project-gulimall.svc.cluster.local:8848"
  selector:
    matchLabels:
      app: nacos

apiVersion: v1
kind: ReplicationController
metadata:
  name: mysql
  namespace: project-gulimall
  labels:
    name: mysql
spec:
  replicas: 1
  selector:
    name: mysql
  template:
    metadata:
      labels:
        name: mysql
    spec:
      containers:
      - name: mysql
        image: nacos/nacos-mysql:5.7
        ports:
        - containerPort: 3306
        volumeMounts:
        - name: mysql-data
          mountPath: /var/lib/mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "root"
        - name: MYSQL_DATABASE
          value: "nacos_devtest"
        - name: MYSQL_USER
          value: "nacos"
        - name: MYSQL_PASSWORD
          value: "nacos"
      volumes:
      - name: mysql-data
        hostPath:
          path: /var/lib/mysql
---
apiVersion: v1
kind: Service
metadata:
  name: mysql
  namespace: project-gulimall
  labels:
    name: mysql
spec:
  ports:
  - port: 3306
    targetPort: 3306
  selector:
    name: mysql


http://www.kler.cn/a/133177.html

相关文章:

  • hive alter table add columns 是否使用 cascade 的方案
  • 电子电气架构 --- 传统刷写流程怎么用在SOC上就不适用呢?
  • STM32 学习笔记-----STM32 的启动过程
  • 部署Apache Doris
  • 【安全科普】NUMA防火墙诞生记
  • 《Probing the 3D Awareness of Visual Foundation Models》论文解析——多视图一致性
  • 在VS Code中使用VIM
  • OSI网络模型与TCP/IP协议
  • 蓝桥杯每日一题2023.11.16
  • 春秋云境靶场CVE-2022-28512漏洞复现(sql手工注入)
  • 定时获取公网ip并发送邮件提醒
  • 【备忘】websocket学习之挖坑埋自己
  • conda从4.12升级到最新版23.9 自动升级失败 手动升级方法
  • mac苹果电脑需要安装杀毒软件吗?
  • Windows Server 2012 R2系统服务器远程桌面服务多用户登录配置分享
  • 要做好解决方案工程师,这些核心技能是必须要掌握的。
  • iceoryx(冰羚)-通信中间件解析
  • C++二分查找算法:查找和最小的 K 对数字
  • (七)什么是Vite——vite优劣势、命令
  • fopen/fwrite/fread 对UNICODE字符写入的总结
  • 【XTDrone Ubuntu20.04】XTDrone+ Ubuntu20.04 + PX4安装
  • 论文阅读:Auto White-Balance Correction for Mixed-Illuminant Scenes
  • SpringBoot学习笔记-创建个人中心页面(下)
  • 大数据-之LibrA数据库系统告警处理(ALM-12051 磁盘Inode使用率超过阈值)
  • MongoDB分片集群搭建
  • Axelar、J.P.Morgan Onyx、Apollo 完成概念验证,向跨区块链自动化投资领域探索