github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/cloud/kubernetes/v1.7/cockroachdb-statefulset.yaml (about) 1 apiVersion: v1 2 kind: Service 3 metadata: 4 # This service is meant to be used by clients of the database. It exposes a ClusterIP that will 5 # automatically load balance connections to the different database pods. 6 name: cockroachdb-public 7 labels: 8 app: cockroachdb 9 spec: 10 ports: 11 # The main port, served by gRPC, serves Postgres-flavor SQL, internode 12 # traffic and the cli. 13 - port: 26257 14 targetPort: 26257 15 name: grpc 16 # The secondary port serves the UI as well as health and debug endpoints. 17 - port: 8080 18 targetPort: 8080 19 name: http 20 selector: 21 app: cockroachdb 22 --- 23 apiVersion: v1 24 kind: Service 25 metadata: 26 # This service only exists to create DNS entries for each pod in the stateful 27 # set such that they can resolve each other's IP addresses. It does not 28 # create a load-balanced ClusterIP and should not be used directly by clients 29 # in most circumstances. 30 name: cockroachdb 31 labels: 32 app: cockroachdb 33 annotations: 34 # This is needed to make the peer-finder work properly and to help avoid 35 # edge cases where instance 0 comes up after losing its data and needs to 36 # decide whether it should create a new cluster or try to join an existing 37 # one. If it creates a new cluster when it should have joined an existing 38 # one, we'd end up with two separate clusters listening at the same service 39 # endpoint, which would be very bad. 40 service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" 41 # Enable automatic monitoring of all instances when Prometheus is running in the cluster. 42 prometheus.io/scrape: "true" 43 prometheus.io/path: "_status/vars" 44 prometheus.io/port: "8080" 45 spec: 46 ports: 47 - port: 26257 48 targetPort: 26257 49 name: grpc 50 - port: 8080 51 targetPort: 8080 52 name: http 53 clusterIP: None 54 selector: 55 app: cockroachdb 56 --- 57 apiVersion: policy/v1beta1 58 kind: PodDisruptionBudget 59 metadata: 60 name: cockroachdb-budget 61 labels: 62 app: cockroachdb 63 spec: 64 selector: 65 matchLabels: 66 app: cockroachdb 67 maxUnavailable: 1 68 --- 69 apiVersion: apps/v1beta1 70 kind: StatefulSet 71 metadata: 72 name: cockroachdb 73 spec: 74 serviceName: "cockroachdb" 75 replicas: 3 76 template: 77 metadata: 78 labels: 79 app: cockroachdb 80 spec: 81 affinity: 82 podAntiAffinity: 83 preferredDuringSchedulingIgnoredDuringExecution: 84 - weight: 100 85 podAffinityTerm: 86 labelSelector: 87 matchExpressions: 88 - key: app 89 operator: In 90 values: 91 - cockroachdb 92 topologyKey: kubernetes.io/hostname 93 containers: 94 - name: cockroachdb 95 image: cockroachdb/cockroach:v20.1.1 96 imagePullPolicy: IfNotPresent 97 ports: 98 - containerPort: 26257 99 name: grpc 100 - containerPort: 8080 101 name: http 102 volumeMounts: 103 - name: datadir 104 mountPath: /cockroach/cockroach-data 105 env: 106 - name: COCKROACH_CHANNEL 107 value: kubernetes-insecure 108 command: 109 - "/bin/bash" 110 - "-ecx" 111 # The use of qualified `hostname -f` is crucial: 112 # Other nodes aren't able to look up the unqualified hostname. 113 - "exec /cockroach/cockroach start --logtostderr --insecure --advertise-host $(hostname -f) --http-addr 0.0.0.0 --join cockroachdb-0.cockroachdb,cockroachdb-1.cockroachdb,cockroachdb-2.cockroachdb --cache 25% --max-sql-memory 25%" 114 # No pre-stop hook is required, a SIGTERM plus some time is all that's 115 # needed for graceful shutdown of a node. 116 terminationGracePeriodSeconds: 60 117 volumes: 118 - name: datadir 119 persistentVolumeClaim: 120 claimName: datadir 121 updateStrategy: 122 type: RollingUpdate 123 volumeClaimTemplates: 124 - metadata: 125 name: datadir 126 spec: 127 accessModes: 128 - "ReadWriteOnce" 129 resources: 130 requests: 131 storage: 100Gi