首页 > 其他分享 >Kubernetes(K8S) 安装Nacos,报 No DataSource set

Kubernetes(K8S) 安装Nacos,报 No DataSource set

时间:2022-11-17 11:34:59浏览次数:83  
标签:set name Kubernetes No nacos value 8848 mysql port

原因,数据库为 MySQL 5.7
需要在yaml加上参数

mysql.db.param: "characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&serverTimezone=UTC"

使用 Kubeadm 部署 Kubernetes(K8S) 安装 -- 持久化存储(NFS网络存储)
nacos-nfs.yaml

apiVersion: v1
kind: Service
metadata:
  name: nacos-headless
  namespace: vipsoft-test
  labels:
    app: nacos
  annotations:
    service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
  ports:
    - port: 8848
      name: server
      targetPort: 8848
    - port: 7848
      name: rpc
      targetPort: 7848
  clusterIP: None
  selector:
    app: nacos

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: nacos-cm
  namespace: vipsoft-test
data:
  mysql.host: "数据库IP"
  mysql.db.name: "nacos"
  mysql.port: "3306"
  mysql.user: "root"
  mysql.password: "110"
  mysql.db.param: "characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&serverTimezone=UTC"

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nacos
  namespace: vipsoft-test
spec:
  serviceName: nacos-headless
  replicas: 1
  template:
    metadata:
      labels:
        app: nacos
      annotations:
        pod.alpha.kubernetes.io/initialized: "true"
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: "app"
                    operator: In
                    values:
                      - nacos
              topologyKey: "kubernetes.io/hostname"
      containers:
        - name: nacos
          imagePullPolicy: IfNotPresent
          image: nacos/nacos-server:v2.0.3
          resources:
            requests:
              memory: "1Gi"
              cpu: "500m"
          ports:
            - containerPort: 8848
              name: client-port
            - containerPort: 7848
              name: rpc
          env:
            - name: NACOS_REPLICAS
              value: "1"
            - name: SERVICE_NAME
              value: "nacos-headless"
            - name: DOMAIN_NAME
              value: "cluster.local"
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.namespace
            - 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: MYSQL_SERVICE_DB_PARAM
              valueFrom:
                configMapKeyRef:
                  name: nacos-cm
                  key: mysql.db.param      
            - name: MODE
              value: standalone
            - 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.default.svc.cluster.local:8848'
            - name: SPRING_DATASOURCE_PLATFORM
              value: mysql
          volumeMounts:
            - name: plugindir
              mountPath: /home/nacos/plugins/peer-finder
            - name: datadir
              mountPath: /home/nacos/data
            - name: logdir
              mountPath: /home/nacos/logs
      volumes:
        - name: plugindir
          hostPath:
            path: /nfs/nacos/plugins/peer-finder
        - name: datadir
          hostPath:
            path: /nfs/nacos/data
        - name: logdir
          hostPath:
            path: /nfs/nacos/logs
  selector:
    matchLabels:
      app: nacos

---
apiVersion: v1
kind: Service
metadata:
  namespace: vipsoft-test
  name: service-nacos
  labels:
    app: nacos
spec:
  ports:
    - port: 8848
      targetPort: 8848
      nodePort: 30848
      name: server
    - port: 7848
      targetPort: 7848
      name: rpc
    - port: 9848
      targetPort: 9848
      name: ws
    - port: 9849
      targetPort: 9849
      name: wss
  selector:
    app: nacos
  type: NodePort  

标签:set,name,Kubernetes,No,nacos,value,8848,mysql,port
From: https://www.cnblogs.com/vipsoft/p/16898876.html

相关文章

  • Node基础
    模块化开发实际开发中,一个项目里会有多个js文件,如果用node一个个运行js文件不方便main.jsconstdda=require("./add.js");//.js可以省略letresult=dda(10,20);c......
  • MyISAM与InnoDB的区别
    MyISAM与InnoDB的区别是什么?这是一个常见的面试题,我们要具从不同的角度解读一下。1、 存储结构MyISAM:每个MyISAM在磁盘上存储成三个文件。第一个文件的名字以表的名字开始,......
  • weblogic免密登录使用nohup启动密码无效问题
    目录weblogic免密登录使用nohup启动密码无效问题1、密码重置1.1、使用一下命令可以重置weblogic的密码,注意后面有一个点,前面还有一个空格1.2、将生成的文件DefaultAuthenti......
  • 使用mongodb存储fluentd 事件,报错Mongo::Auth::Unauthorized error="User admin (mech
    一、问题描述 使用fluentd的mongodb插件,将nginx的日志,存储到mongodb数据库中,配置如下: <source>@typetailpath/var/log/nginx/access.logpos_file/var/......
  • Android > Project with path ‘:audiovisualize‘ could not be found in project ‘:
    博主前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住也分享一下给大家,......
  • Could not obtain transaction-synchronized Session for current thread
    一场景我的项目中,发生这个错误是由于我使用springmvc框架,但是在里面新建了一个springboot的camunda(流程)模块。而springmvc使用hibernate,camunda使用jpa的entityManager......
  • git解决.gitignore文件不生效的问题
    原因:第一次提交git的时候.gitignore文件会记录到缓存中,如果有更新不生效的情况可以尝试以下步骤  注意:第一个命令是有那个点的......
  • DevOps 必备的 Kubernetes 安全清单
    Kubernetes是当今许多公司采用的容器编排平台,它的实施需要对其生态系统有一定的了解,以便部署一个准备好用于生产的集群。然而从原则上来说,Kubernetes并不是一个安全的平......
  • vue3的<setup script>中使用異步函數
    由於vue3的setup一般情況下不允許為async,如果要將setup變成async,則要引入異步組件 <Suspense> <template#default> <SwitchMaintenanceUpdate/> </template> </S......
  • NOTE_vanilla+typescript
    E:\song\threejs_learn\vite-project\index.html<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"/><linkrel="icon"type="image/svg+xml"......