interop-workloads/workloads/ansible/shade/k8s/roles/post/templates/cockroachdb.j2

147 lines
3.7 KiB
Django/Jinja
Executable File

# Claim: This deployment file was originally developed by cockroachdb Lab
#
# For details, please follow the following link:
# https://github.com/cockroachdb/cockroach/tree/master/cloud/kubernetes
#
apiVersion: v1
kind: Service
metadata:
name: cockroachdb-public
labels:
app: cockroachdb
spec:
type: NodePort
ports:
- port: 26257
targetPort: 26257
nodePort: 32257
name: grpc
- port: 8080
targetPort: 8080
nodePort: 32256
name: http
selector:
app: cockroachdb
---
apiVersion: v1
kind: Service
metadata:
name: cockroachdb
labels:
app: cockroachdb
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
prometheus.io/scrape: "true"
prometheus.io/path: "_status/vars"
prometheus.io/port: "8080"
spec:
ports:
- port: 26257
targetPort: 26257
name: grpc
- port: 8080
targetPort: 8080
name: http
clusterIP: None
selector:
app: cockroachdb
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: cockroachdb-budget
labels:
app: cockroachdb
spec:
selector:
matchLabels:
app: cockroachdb
minAvailable: 67%
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: cockroachdb
spec:
serviceName: "cockroachdb"
replicas: {{ app_env.stack_size - 1 }}
template:
metadata:
labels:
app: cockroachdb
annotations:
scheduler.alpha.kubernetes.io/affinity: >
{
"podAntiAffinity": {
"preferredDuringSchedulingIgnoredDuringExecution": [{
"weight": 100,
"labelSelector": {
"matchExpressions": [{
"key": "app",
"operator": "In",
"values": ["cockroachdb"]
}]
},
"topologyKey": "kubernetes.io/hostname"
}]
}
}
pod.alpha.kubernetes.io/init-containers: '[
{
"name": "bootstrap",
"image": "cockroachdb/cockroach-k8s-init",
"imagePullPolicy": "IfNotPresent",
"args": [
"-on-start=/on-start.sh",
"-service=cockroachdb"
],
"env": [
{
"name": "POD_NAMESPACE",
"valueFrom": {
"fieldRef": {
"apiVersion": "v1",
"fieldPath": "metadata.namespace"
}
}
}
],
"volumeMounts": [
{
"name": "datadir",
"mountPath": "/cockroach/cockroach-data"
}
]
}
]'
spec:
containers:
- name: cockroachdb
image: cockroachdb/cockroach
imagePullPolicy: IfNotPresent
ports:
- containerPort: 26257
name: grpc
- containerPort: 8080
name: http
volumeMounts:
- name: datadir
mountPath: /cockroach/cockroach-data
command:
- "/bin/bash"
- "-ecx"
- |
CRARGS=("start" "--logtostderr" "--insecure" "--host" "$(hostname -f)" "--http-host" "0.0.0.0")
if [ ! "$(hostname)" == "cockroachdb-0" ] || \
[ -e "/cockroach/cockroach-data/cluster_exists_marker" ]
then
CRARGS+=("--join" "cockroachdb-public")
fi
exec /cockroach/cockroach ${CRARGS[*]}
terminationGracePeriodSeconds: 60
volumes:
- name: datadir
hostPath:
path: /storage/cockroachdb