k8s-中间件部署-Nacos

一、Nacos

二、MySQL配置

1、nacos-mysql.sql

2、application.properties 配置

三、k8s部署

1、k8s容器文件路径

k8s容器文件路径.png

2、挂载配置路径
挂载配置路径.png

3、注意

  • 由于容器/home/nacos/conf中有多个文件,所以如果直接挂载/home/nacos/conf目录就会覆盖容器中的所有文件。为了实现按需配置就必须要执行子路径

四、配置依赖的MySQL容器

由于Nacos使用了MySQL配置,所以在启动Nacos容器的时候必须要保证MySQL容器已经启动完成

1、配置init容器

使用init容器来检验MySQL容器是否启动成功

image.png
image.png
  • 命令
sh,-c,until nslookup mysql-svc; do echo waiting for mydb; sleep 2; done
  • yaml
kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: nacos-svc-v1
  namespace: yygh
  labels:
    app: nacos-svc
    version: v1
  annotations:
    kubesphere.io/creator: raven-work-wang
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nacos-svc
      version: v1
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nacos-svc
        version: v1
      annotations:
        cni.projectcalico.org/ipv4pools: '["default-ipv4-ippool"]'
        kubesphere.io/restartedAt: '2022-04-02T06:03:02.185Z'
        logging.kubesphere.io/logsidecar-config: '{}'
    spec:
      volumes:
        - name: host-time
          hostPath:
            path: /etc/localtime
            type: ''
        - name: volume-1w0qgd
          configMap:
            name: nacos-config
            defaultMode: 420
      initContainers:
        - name: container-mo0skl
          image: 'busybox:latest'
          command:
            - sh
            - '-c'
            - until nslookup mysql-svc; do echo waiting for mydb; sleep 2; done
          ports:
            - name: http-8081
              containerPort: 8081
              protocol: TCP
          resources: {}
          volumeMounts:
            - name: host-time
              readOnly: true
              mountPath: /etc/localtime
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      containers:
        - name: container-0up3y8
          image: 'nacos/nacos-server:v2.0.4'
          ports:
            - name: http-8848
              containerPort: 8848
              protocol: TCP
          resources:
            limits:
              cpu: 500m
              memory: 1000Mi
          volumeMounts:
            - name: host-time
              readOnly: true
              mountPath: /etc/localtime
            - name: volume-1w0qgd
              readOnly: true
              mountPath: /home/nacos/conf/application.properties
              subPath: application.properties
          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-svc
  podManagementPolicy: OrderedReady
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      partition: 0
  revisionHistoryLimit: 10

image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容