• nacos集群部署


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

    需要修改两个文件

    1. ---
    2. apiVersion: v1
    3. kind: Service
    4. metadata:
    5. name: nacos-headless
    6. namespace: project-gulimall
    7. labels:
    8. app: nacos-headless
    9. spec:
    10. type: ClusterIP
    11. clusterIP: None
    12. ports:
    13. - port: 8848
    14. name: server
    15. targetPort: 8848
    16. - port: 9848
    17. name: client-rpc
    18. targetPort: 9848
    19. - port: 9849
    20. name: raft-rpc
    21. targetPort: 9849
    22. ## 兼容1.4.x版本的选举端口
    23. - port: 7848
    24. name: old-raft-rpc
    25. targetPort: 7848
    26. selector:
    27. app: nacos
    28. ---
    29. apiVersion: v1
    30. kind: ConfigMap
    31. metadata:
    32. name: nacos-cm
    33. namespace: project-gulimall
    34. data:
    35. mysql.host: "mysql"
    36. mysql.db.name: "nacos_devtest"
    37. mysql.port: "3306"
    38. mysql.user: "nacos"
    39. mysql.password: "nacos"
    40. ---
    41. apiVersion: apps/v1
    42. kind: StatefulSet
    43. metadata:
    44. name: nacos
    45. namespace: project-gulimall
    46. spec:
    47. serviceName: nacos-headless
    48. replicas: 3
    49. template:
    50. metadata:
    51. labels:
    52. app: nacos
    53. annotations:
    54. pod.alpha.kubernetes.io/initialized: "true"
    55. spec:
    56. containers:
    57. - name: nacos
    58. imagePullPolicy: Always
    59. image: nacos/nacos-server:latest
    60. resources:
    61. requests:
    62. memory: "2Gi"
    63. cpu: "500m"
    64. ports:
    65. - containerPort: 8848
    66. name: client
    67. - containerPort: 9848
    68. name: client-rpc
    69. - containerPort: 9849
    70. name: raft-rpc
    71. - containerPort: 7848
    72. name: old-raft-rpc
    73. env:
    74. - name: NACOS_REPLICAS
    75. value: "3"
    76. - name: MYSQL_SERVICE_HOST
    77. valueFrom:
    78. configMapKeyRef:
    79. name: nacos-cm
    80. key: mysql.host
    81. - name: MYSQL_SERVICE_DB_NAME
    82. valueFrom:
    83. configMapKeyRef:
    84. name: nacos-cm
    85. key: mysql.db.name
    86. - name: MYSQL_SERVICE_PORT
    87. valueFrom:
    88. configMapKeyRef:
    89. name: nacos-cm
    90. key: mysql.port
    91. - name: MYSQL_SERVICE_USER
    92. valueFrom:
    93. configMapKeyRef:
    94. name: nacos-cm
    95. key: mysql.user
    96. - name: MYSQL_SERVICE_PASSWORD
    97. valueFrom:
    98. configMapKeyRef:
    99. name: nacos-cm
    100. key: mysql.password
    101. - name: SPRING_DATASOURCE_PLATFORM
    102. value: "mysql"
    103. - name: NACOS_SERVER_PORT
    104. value: "8848"
    105. - name: NACOS_APPLICATION_PORT
    106. value: "8848"
    107. - name: PREFER_HOST_MODE
    108. value: "hostname"
    109. - name: NACOS_SERVERS
    110. 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"
    111. selector:
    112. matchLabels:
    113. app: nacos

    1. apiVersion: v1
    2. kind: ReplicationController
    3. metadata:
    4. name: mysql
    5. namespace: project-gulimall
    6. labels:
    7. name: mysql
    8. spec:
    9. replicas: 1
    10. selector:
    11. name: mysql
    12. template:
    13. metadata:
    14. labels:
    15. name: mysql
    16. spec:
    17. containers:
    18. - name: mysql
    19. image: nacos/nacos-mysql:5.7
    20. ports:
    21. - containerPort: 3306
    22. volumeMounts:
    23. - name: mysql-data
    24. mountPath: /var/lib/mysql
    25. env:
    26. - name: MYSQL_ROOT_PASSWORD
    27. value: "root"
    28. - name: MYSQL_DATABASE
    29. value: "nacos_devtest"
    30. - name: MYSQL_USER
    31. value: "nacos"
    32. - name: MYSQL_PASSWORD
    33. value: "nacos"
    34. volumes:
    35. - name: mysql-data
    36. hostPath:
    37. path: /var/lib/mysql
    38. ---
    39. apiVersion: v1
    40. kind: Service
    41. metadata:
    42. name: mysql
    43. namespace: project-gulimall
    44. labels:
    45. name: mysql
    46. spec:
    47. ports:
    48. - port: 3306
    49. targetPort: 3306
    50. selector:
    51. name: mysql

  • 相关阅读:
    PyCharm搭建Scrapy环境
    如何利用 Seaborn 实现高级统计图表
    Day17:C++ WITH Easyx
    Linux基本指令集合
    Python 面试必看
    智能算法--基于差分进化算法(DE)的神经网络优化UCI数据集
    PMSM中常用的两种坐标变换——Park变换
    在Net6中使用AutoMapper
    机器学习sklearn——day02
    导航url链接中获取参数
  • 原文地址:https://blog.csdn.net/hebian1994/article/details/134486007