Skip to content

Add CockroachDB to the repository #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions repository/cockroachdb/operator/operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: kudo.dev/v1beta1
name: "CockroachDB"
version: "0.1.0"
kudoVersion: 0.8.0
kubernetesVersion: 1.13.0
appVersion: 19.2.1
maintainers:
- name: liwei
email: "[email protected]"
url: "https://www.cockroachlabs.com/"
tasks:
- name: svc
kind: Apply
spec:
resources:
- services.yaml
- name: poddisruptionbudget
kind: Apply
spec:
resources:
- poddisruptionbudget.yaml
- name: sts
kind: Apply
spec:
resources:
- statefulset.yaml
- name: init
kind: Apply
spec:
resources:
- job.yaml
plans:
deploy:
strategy: parallel
phases:
- name: base
strategy: serial
steps:
- name: svc
tasks:
- svc
- name: poddisruptionbudget
tasks:
- poddisruptionbudget
- name: sts
tasks:
- sts
- name: init
strategy: serial
steps:
- name: init
tasks:
- init
46 changes: 46 additions & 0 deletions repository/cockroachdb/operator/params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: kudo.dev/v1beta1
parameters:
- name: namespace
default: default
- name: serviceAccountName
default: cockroachdb
- name: clusterRoleName
default: cockroachdb
- name: roleName
default: cockroachdb
- name: serviceName
default: cockroachdb
- name: grpcPort
default: 26257
- name: httpPort
default: 8080
- name: grpcPortDNSSuffix
default: grpc
- name: httpPortDNSSuffix
default: http
- name: publicServiceName
default: cockroachdb-public
- name: publicGrpcPort
default: 26257
- name: publicHttpPort
default: 8080
- name: publicGrpcPortDNSSuffix
default: grpc
- name: publicHttpPortDNSSuffix
default: http
- name: requestCPU
default: 0.1
- name: requestMemory
default: 1Gi
- name: limitCPU
default: 0.2
- name: limitMemory
default: 1Gi
- name: initImageVersion
default: 0.4
- name: imageVersion
default: v19.2.1
- name: storageClassName
default: default
- name: storageSize
default: 1Gi
20 changes: 20 additions & 0 deletions repository/cockroachdb/operator/templates/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: batch/v1
kind: Job
metadata:
name: cluster-init
namespace: {{ .Params.namespace }}
labels:
app: cockroachdb
spec:
template:
spec:
containers:
- name: cluster-init
image: cockroachdb/cockroach:{{ .Params.imageVersion }}
imagePullPolicy: IfNotPresent
command:
- "/cockroach/cockroach"
- "init"
- "--insecure"
- "--host=cockroachdb-0.cockroachdb"
restartPolicy: OnFailure
12 changes: 12 additions & 0 deletions repository/cockroachdb/operator/templates/poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: cockroachdb-budget
namespace: {{ .Params.namespace }}
labels:
app: cockroachdb
spec:
selector:
matchLabels:
app: cockroachdb
maxUnavailable: 1
42 changes: 42 additions & 0 deletions repository/cockroachdb/operator/templates/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Params.publicServiceName }}
namespace: {{ .Params.namespace }}
labels:
app: cockroachdb
spec:
ports:
- port: {{ .Params.grpcPort }}
targetPort: 26257
name: {{ .Params.grpcPortDNSSuffix }}
- port: {{ .Params.httpPort }}
targetPort: 8080
name: {{ .Params.httpPortDNSSuffix }}
selector:
app: cockroachdb
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Params.serviceName }}
namespace: {{ .Params.namespace }}
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: {{ .Params.publicGrpcPort }}
targetPort: 26257
name: {{ .Params.publicGrpcPortDNSSuffix }}
- port: {{ .Params.publicHttpPort }}
targetPort: 8080
name: {{ .Params.publicHttpPortDNSSuffix }}
publishNotReadyAddresses: true
clusterIP: None
selector:
app: cockroachdb
94 changes: 94 additions & 0 deletions repository/cockroachdb/operator/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: cockroachdb
namespace: {{ .Params.namespace }}
labels:
app: cockroachdb
spec:
serviceName: {{ .Params.serviceName }}
replicas: 3
selector:
matchLabels:
app: cockroachdb
template:
metadata:
labels:
app: cockroachdb
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- cockroachdb
topologyKey: kubernetes.io/hostname
containers:
- name: cockroachdb
image: cockroachdb/cockroach:{{ .Params.imageVersion }}
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: {{ .Params.requestCPU }}
memory: {{ .Params.requestMemory }}
limits:
cpu: {{ .Params.limitCPU }}
memory: {{ .Params.limitMemory }}
ports:
- containerPort: 26257
name: grpc
- containerPort: 8080
name: http
livenessProbe:
httpGet:
path: '/health'
port: http
initialDelaySeconds: 30
periodSeconds: 5
readinessProbe:
httpGet:
path: '/health?ready=1'
port: http
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 2
volumeMounts:
- name: datadir
mountPath: /cockroach/cockroach-data
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: COCKROACH_CHANNEL
value: kubernetes-insecure
command:
- '/bin/bash'
- '-ecx'
- 'exec /cockroach/cockroach start --logtostderr --insecure --advertise-host $(echo $POD_NAME).cockroachdb --http-addr 0.0.0.0 --join cockroachdb-0.cockroachdb,cockroachdb-1.cockroachdb,cockroachdb-2.cockroachdb --cache 25% --max-sql-memory 25%'
terminationGracePeriodSeconds: 60
volumes:
- name: datadir
persistentVolumeClaim:
claimName: datadir
podManagementPolicy: Parallel
updateStrategy:
type: RollingUpdate
volumeClaimTemplates:
- metadata:
name: datadir
spec:
{{ if ne .Params.storageClassName "default" }}
storageClassName: {{ .Params.storageClassName }}
{{ end }}
accessModes:
- 'ReadWriteOnce'
resources:
requests:
storage: {{ .Params.storageSize }}