zoukankan      html  css  js  c++  java
  • K8s 部署 PostgreSQL

    Config

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: postgres-config
      namespace: postgres
      labels:
        app: postgres
    data:
      POSTGRES_DB: master
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    

    PersistentVolume

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: postgres-pv
    spec:
      capacity:
        storage: 2Gi
      accessModes:
        - ReadWriteOnce
      persistentVolumeReclaimPolicy: Retain
      nfs:
        server: 192.168.11.210
        path: "/nfs/postgre-pv"
    

    StatefulSet

    apiVersion: apps/v1
    kind: StatefulSet
    metadata:
      name: postgres
      namespace: postgres
    spec:
      serviceName: "postgres"
      replicas: 1
      selector:
        matchLabels:
          app: postgres
      template:
        metadata:
          labels:
            app: postgres
        spec:
          containers:
            - name: postgres
              image: postgres:9.5
              envFrom:
                - configMapRef:
                    name: postgres-config
              ports:
                - containerPort: 5432
                  name: postgredb
              volumeMounts:
                - name: postgres-data
                  mountPath: /var/lib/postgresql/data
                  subPath: postgres
      volumeClaimTemplates:
        - metadata:
            name: postgres-data
          spec:
            accessModes: ["ReadWriteOnce"]
            resources:
              requests:
                storage: 2Gi
    

    Service

    apiVersion: v1
    kind: Service
    metadata:
      name: postgres
      namespace: postgres
      labels:
        app: postgres
    spec:
      ports:
        - port: 5432
          name: postgres
      type: LoadBalancer
      selector:
        app: postgres
    

    $ kubectl create ns postgres
    $ kubectl create -f xxxx
    $ kubectl get service -n postgres
    NAME       TYPE           CLUSTER-IP    EXTERNAL-IP      PORT(S)          AGE
    postgres   LoadBalancer   10.43.81.59   192.168.11.210   5432:31919/TCP   40s
    

  • 相关阅读:
    WinMain函数的修饰符WINAPI的含义
    java字节码指令集简介
    vs2010里面的ipch文件和.sdf文件是什么
    java查看class字节码文件
    从汇编看c++的extern关键字
    highcharts系列教程
    highcharts的文档介绍(英文)
    关于firebug中行号和源文件不一致的问题
    ios中的流状态的定义
    highcharts翻译系列
  • 原文地址:https://www.cnblogs.com/lb477/p/14859050.html
Copyright © 2011-2022 走看看