github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/applications/cockroachdb/cockroachdb-manifest.yaml (about)

     1  ---
     2  apiVersion: v1
     3  kind: Namespace
     4  metadata:
     5    name: cockroachdb-system
     6    labels:
     7      app.kubernetes.io/name: cockroachdb
     8      app.kubernetes.io/instance: my-cockroachdb
     9  ---
    10  # Source: cockroachdb/templates/poddisruptionbudget.yaml
    11  kind: PodDisruptionBudget
    12  apiVersion: policy/v1beta1
    13  metadata:
    14    name: my-cockroachdb-budget
    15    namespace: "cockroachdb-system"
    16    labels:
    17      app.kubernetes.io/name: cockroachdb
    18      app.kubernetes.io/instance: "my-cockroachdb"
    19      app.kubernetes.io/managed-by: "Helm"
    20  spec:
    21    selector:
    22      matchLabels:
    23        app.kubernetes.io/name: cockroachdb
    24        app.kubernetes.io/instance: "my-cockroachdb"
    25        app.kubernetes.io/component: cockroachdb
    26    maxUnavailable: 1
    27  ---
    28  # Source: cockroachdb/templates/service.discovery.yaml
    29  # This service only exists to create DNS entries for each pod in
    30  # the StatefulSet such that they can resolve each other's IP addresses.
    31  # It does not create a load-balanced ClusterIP and should not be used directly
    32  # by clients in most circumstances.
    33  kind: Service
    34  apiVersion: v1
    35  metadata:
    36    name: my-cockroachdb
    37    namespace: "cockroachdb-system"
    38    labels:
    39      app.kubernetes.io/name: cockroachdb
    40      app.kubernetes.io/instance: "my-cockroachdb"
    41      app.kubernetes.io/managed-by: "Helm"
    42      app.kubernetes.io/component: cockroachdb
    43    annotations:
    44      # Use this annotation in addition to the actual field below because the
    45      # annotation will stop being respected soon, but the field is broken in
    46      # some versions of Kubernetes:
    47      # https://github.com/kubernetes/kubernetes/issues/58662
    48      service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
    49      # Enable automatic monitoring of all instances when Prometheus is running
    50      # in the cluster.
    51      prometheus.io/scrape: "true"
    52      prometheus.io/path: _status/vars
    53      prometheus.io/port: "8080"
    54  spec:
    55    clusterIP: None
    56    # We want all Pods in the StatefulSet to have their addresses published for
    57    # the sake of the other CockroachDB Pods even before they're ready, since they
    58    # have to be able to talk to each other in order to become ready.
    59    publishNotReadyAddresses: true
    60    ports:
    61      # The main port, served by gRPC, serves Postgres-flavor SQL, inter-node
    62      # traffic and the CLI.
    63      - name: "grpc"
    64        port: 26257
    65        targetPort: grpc
    66      # The secondary port serves the UI as well as health and debug endpoints.
    67      - name: "http"
    68        port: 8080
    69        targetPort: http
    70    selector:
    71      app.kubernetes.io/name: cockroachdb
    72      app.kubernetes.io/instance: "my-cockroachdb"
    73      app.kubernetes.io/component: cockroachdb
    74  ---
    75  # Source: cockroachdb/templates/service.public.yaml
    76  # This Service is meant to be used by clients of the database.
    77  # It exposes a ClusterIP that will automatically load balance connections
    78  # to the different database Pods.
    79  kind: Service
    80  apiVersion: v1
    81  metadata:
    82    name: my-cockroachdb-public
    83    namespace: "cockroachdb-system"
    84    labels:
    85      app.kubernetes.io/name: cockroachdb
    86      app.kubernetes.io/instance: "my-cockroachdb"
    87      app.kubernetes.io/managed-by: "Helm"
    88      app.kubernetes.io/component: cockroachdb
    89  spec:
    90    type: "ClusterIP"
    91    ports:
    92      # The main port, served by gRPC, serves Postgres-flavor SQL, inter-node
    93      # traffic and the CLI.
    94      - name: "grpc"
    95        port: 26257
    96        targetPort: grpc
    97      # The secondary port serves the UI as well as health and debug endpoints.
    98      - name: "http"
    99        port: 8080
   100        targetPort: http
   101    selector:
   102      app.kubernetes.io/name: cockroachdb
   103      app.kubernetes.io/instance: "my-cockroachdb"
   104      app.kubernetes.io/component: cockroachdb
   105  ---
   106  # Source: cockroachdb/templates/statefulset.yaml
   107  kind: StatefulSet
   108  apiVersion: apps/v1
   109  metadata:
   110    name: my-cockroachdb
   111    namespace: "cockroachdb-system"
   112    labels:
   113      app.kubernetes.io/name: cockroachdb
   114      app.kubernetes.io/instance: "my-cockroachdb"
   115      app.kubernetes.io/managed-by: "Helm"
   116      app.kubernetes.io/component: cockroachdb
   117  spec:
   118    serviceName: my-cockroachdb
   119    replicas: 3
   120    updateStrategy:
   121      type: RollingUpdate
   122    podManagementPolicy: "Parallel"
   123    selector:
   124      matchLabels:
   125        app.kubernetes.io/name: cockroachdb
   126        app.kubernetes.io/instance: "my-cockroachdb"
   127        app.kubernetes.io/component: cockroachdb
   128    template:
   129      metadata:
   130        labels:
   131          app.kubernetes.io/name: cockroachdb
   132          app.kubernetes.io/instance: "my-cockroachdb"
   133          app.kubernetes.io/component: cockroachdb
   134      spec:
   135        affinity:
   136          podAntiAffinity:
   137            preferredDuringSchedulingIgnoredDuringExecution:
   138              - weight: 100
   139                podAffinityTerm:
   140                  topologyKey: kubernetes.io/hostname
   141                  labelSelector:
   142                    matchLabels:
   143                      app.kubernetes.io/name: cockroachdb
   144                      app.kubernetes.io/instance: "my-cockroachdb"
   145                      app.kubernetes.io/component: cockroachdb
   146        topologySpreadConstraints:
   147          - labelSelector:
   148              matchLabels:
   149                app.kubernetes.io/name: cockroachdb
   150                app.kubernetes.io/instance: "my-cockroachdb"
   151                app.kubernetes.io/component: cockroachdb
   152            maxSkew: 1
   153            topologyKey: topology.kubernetes.io/zone
   154            whenUnsatisfiable: ScheduleAnyway
   155        # No pre-stop hook is required, a SIGTERM plus some time is all that's
   156        # needed for graceful shutdown of a node.
   157        terminationGracePeriodSeconds: 60
   158        containers:
   159          - name: db
   160            image: "cockroachdb/cockroach:v21.1.7"
   161            imagePullPolicy: "IfNotPresent"
   162            args:
   163              - shell
   164              - -ecx
   165              # The use of qualified `hostname -f` is crucial:
   166              # Other nodes aren't able to look up the unqualified hostname.
   167              #
   168              # `--join` CLI flag is hardcoded to exactly 3 Pods, because:
   169              # 1. Having `--join` value depending on `statefulset.replicas`
   170              #    will trigger undesired restart of existing Pods when
   171              #    StatefulSet is scaled up/down. We want to scale without
   172              #    restarting existing Pods.
   173              # 2. At least one Pod in `--join` is enough to successfully
   174              #    join CockroachDB cluster and gossip with all other existing
   175              #    Pods, even if there are 3 or more Pods.
   176              # 3. It's harmless for `--join` to have 3 Pods even for 1-Pod
   177              #    clusters, while it gives us opportunity to scale up even if
   178              #    some Pods of existing cluster are down (for whatever reason).
   179              # See details explained here:
   180              # https://github.com/helm/charts/pull/18993#issuecomment-558795102
   181              - >-
   182                exec /cockroach/cockroach
   183                start --join=${STATEFULSET_NAME}-0.${STATEFULSET_FQDN}:26257,${STATEFULSET_NAME}-1.${STATEFULSET_FQDN}:26257,${STATEFULSET_NAME}-2.${STATEFULSET_FQDN}:26257
   184                --advertise-host=$(hostname).${STATEFULSET_FQDN}
   185                --logtostderr=INFO
   186                --insecure
   187                --http-port=8080
   188                --port=26257
   189                --cache=25%
   190                --max-sql-memory=25%
   191            env:
   192              - name: STATEFULSET_NAME
   193                value: my-cockroachdb
   194              - name: STATEFULSET_FQDN
   195                value: my-cockroachdb.cockroachdb-system.svc.cluster.local
   196              - name: COCKROACH_CHANNEL
   197                value: kubernetes-helm
   198            ports:
   199              - name: grpc
   200                containerPort: 26257
   201                protocol: TCP
   202              - name: http
   203                containerPort: 8080
   204                protocol: TCP
   205            volumeMounts:
   206              - name: datadir
   207                mountPath: /cockroach/cockroach-data/
   208            livenessProbe:
   209              httpGet:
   210                path: /health
   211                port: http
   212              initialDelaySeconds: 30
   213              periodSeconds: 5
   214            readinessProbe:
   215              httpGet:
   216                path: /health?ready=1
   217                port: http
   218              initialDelaySeconds: 10
   219              periodSeconds: 5
   220              failureThreshold: 2
   221        volumes:
   222          - name: datadir
   223            persistentVolumeClaim:
   224              claimName: datadir
   225    volumeClaimTemplates:
   226      - metadata:
   227          name: datadir
   228          labels:
   229            app.kubernetes.io/name: cockroachdb
   230            app.kubernetes.io/instance: "my-cockroachdb"
   231        spec:
   232          accessModes: [ "ReadWriteOnce" ]
   233          storageClassName: local-hostpath
   234          resources:
   235            requests:
   236              storage: "80Gi"