以下是一个示例的 Kubernetes YAML 文件,用于部署 Nacos 2.2.1 集群:

---
apiVersion: v1
kind: Namespace
metadata:
  name: nacos

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nacos
  namespace: nacos
spec:
  serviceName: nacos
  replicas: 3
  selector:
    matchLabels:
      app: nacos
  template:
    metadata:
      labels:
        app: nacos
    spec:
      containers:
        - name: nacos
          image: nacos/nacos-server:2.2.1
          ports:
            - containerPort: 8848
          env:
            - name: MODE
              value: 'cluster'
          volumeMounts:
            - name: nacos-data
              mountPath: /home/nacos/data
          resources:
            limits:
              cpu: '0.5'
              memory: '512Mi'
            requests:
              cpu: '0.2'
              memory: '256Mi'
      volumes:
        - name: nacos-data
          emptyDir: {}

---

apiVersion: v1
kind: Service
metadata:
  name: nacos
  namespace: nacos
spec:
  selector:
    app: nacos
  ports:
    - name: http
      port: 8848
      protocol: TCP
      targetPort: 8848
  clusterIP: None

---

apiVersion: v1
kind: Service
metadata:
  name: nacos-headless
  namespace: nacos
spec:
  selector:
    app: nacos
  ports:
    - name: http
      port: 8848
      protocol: TCP
      targetPort: 8848
  clusterIP: None
  publishNotReadyAddresses: true

请注意,此示例假定您已经使用kubectl配置了 Kubernetes 集群,并且拥有足够的权限来创建命名空间、部署 StatefulSet 和 Service 等资源。

Kubernetes 部署 Nacos 2.2.1 集群 YAML 示例

原文地址: https://www.cveoy.top/t/topic/qqqI 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录