nacos-deploy.yaml
基于nfs
--- apiVersion: v1 kind: Service metadata: name: nacos-headless namespace: test labels: app: nacos-headless spec: type: ClusterIP ports: - port: 8848 name: server targetPort: 8848 - port: 9848 name: client-rpc targetPort: 9848 selector: app: nacos --- apiVersion: v1 kind: ConfigMap metadata: name: nacos-cm namespace: test data: mysql.host: "svc-mysql" mysql.db.name: "nacos_config" mysql.port: "13306" mysql.user: "root" mysql.password: "1314521" --- apiVersion: apps/v1 kind: StatefulSet metadata: name: nacos namespace: 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: Always image: nacos/nacos-server:v2.2.3 resources: requests: memory: "1Gi" cpu: "500m" ports: - containerPort: 8848 name: client - containerPort: 9848 name: client-rpc env: - name: NACOS_REPLICAS value: "1" - 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 value: "characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC" - 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.default.svc.cluster.local:8848" volumeMounts: - name: nacos-data mountPath: /home/nacos/data subPath: data volumes: - name: nacos-data persistentVolumeClaim: claimName: nacos-data-pvc selector: matchLabels: app: nacos --- apiVersion: v1 kind: PersistentVolume metadata: name: nacos-data-pv namespace: test spec: capacity: storage: 512Mi accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain storageClassName: nacos-data-nfs nfs: path: /data/nfs/nacos server: 192.168.137.100 --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: nacos-data-pvc namespace: test spec: accessModes: - ReadWriteMany resources: requests: storage: 512Mi storageClassName: nacos-data-nfs
ingress-nacos.yaml
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: nacos-ingress namespace: test spec: rules: - host: nacostest.demo.com http: paths: - path: / backend: serviceName: nacos-headless servicePort: 8848
标签:name,nacos,value,mysql,k8s,data,metadata From: https://www.cnblogs.com/cgpei/p/17956435