diff --git a/herddb-docker/src/main/kubernetes/samples/bookkeeper/1_bookkeeper.configmap.yaml b/herddb-docker/src/main/kubernetes/samples/bookkeeper/1_bookkeeper.configmap.yaml new file mode 100644 index 000000000..df62cbed1 --- /dev/null +++ b/herddb-docker/src/main/kubernetes/samples/bookkeeper/1_bookkeeper.configmap.yaml @@ -0,0 +1,14 @@ +## from https://raw.githubusercontent.com/apache/bookkeeper/master/deploy/kubernetes/gke/bookkeeper.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: bookie-config +data: + BK_BOOKIE_EXTRA_OPTS: "\"-Xms1g -Xmx1g -XX:MaxDirectMemorySize=1g -XX:+UseG1GC -XX:MaxGCPauseMillis=10 -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+AggressiveOpts -XX:+DoEscapeAnalysis -XX:ParallelGCThreads=32 -XX:ConcGCThreads=32 -XX:G1NewSizePercent=50 -XX:+DisableExplicitGC -XX:-ResizePLAB\"" + BK_bookiePort: "3181" + BK_journalDirectory: "/bookkeeper/data/journal" + BK_ledgerDirectories: "/bookkeeper/data/ledgers" + BK_indexDirectories: "/bookkeeper/data/ledgers" + BK_zkServers: zookeeper + # TODO: Issue 458: https://github.com/apache/bookkeeper/issues/458 + #BK_statsProviderClass: org.apache.bookkeeper.stats.prometheus.PrometheusMetricsProvider diff --git a/herddb-docker/src/main/kubernetes/samples/bookkeeper/2_bookkeeper.daemonset.yaml b/herddb-docker/src/main/kubernetes/samples/bookkeeper/2_bookkeeper.daemonset.yaml new file mode 100644 index 000000000..a7b0358f9 --- /dev/null +++ b/herddb-docker/src/main/kubernetes/samples/bookkeeper/2_bookkeeper.daemonset.yaml @@ -0,0 +1,66 @@ +## from https://raw.githubusercontent.com/apache/bookkeeper/master/deploy/kubernetes/gke/bookkeeper.yaml + +## BookKeeper servers need to access the local disks and the pods +## cannot be moved across different nodes. +## For this reason, we run BK as a daemon set, one for each node in the +## cluster, unless restricted by label selectors +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + name: bookie + labels: + app: bookkeeper + component: bookie +spec: + template: + metadata: + labels: + app: bookkeeper + component: bookie + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "8000" + + spec: + containers: + - name: bookie + image: apache/bookkeeper:latest + resources: + requests: + memory: "3Gi" + cpu: "1000m" + limits: + memory: "5Gi" + cpu: "2000m" + command: [ "/bin/bash", "/opt/bookkeeper/entrypoint.sh" ] + args: ["/opt/bookkeeper/bin/bookkeeper", "bookie"] + ports: + - name: client + containerPort: 3181 + # we are using `status.hostIP` for the bookie's advertised address. export 3181 as the hostPort, + # so that the containers are able to access the host port + hostPort: 3181 + envFrom: + - configMapRef: + name: bookie-config + env: + - name: BK_advertisedAddress + valueFrom: + fieldRef: + fieldPath: status.hostIP + + + volumeMounts: + - name: journal-disk + mountPath: /bookkeeper/data/journal + - name: ledgers-disk + mountPath: /bookkeeper/data/ledgers + + volumes: + # Mount local disks + - name: journal-disk + hostPath: + path: /mnt/disks/ssd0 + - name: ledgers-disk + hostPath: + path: /mnt/disks/ssd1 diff --git a/herddb-docker/src/main/kubernetes/samples/bookkeeper/3_bookkeeper.service.yaml b/herddb-docker/src/main/kubernetes/samples/bookkeeper/3_bookkeeper.service.yaml new file mode 100644 index 000000000..1e96e7859 --- /dev/null +++ b/herddb-docker/src/main/kubernetes/samples/bookkeeper/3_bookkeeper.service.yaml @@ -0,0 +1,22 @@ +## from https://raw.githubusercontent.com/apache/bookkeeper/master/deploy/kubernetes/gke/bookkeeper.yaml + +## +## Define the Bookie headless service +## In practice, in this case, it is only useful to have a view of +## all the bookie pods that are present +## +apiVersion: v1 +kind: Service +metadata: + name: bookie + labels: + app: bookkeeper + component: bookie +spec: + ports: + - port: 3181 + name: server + clusterIP: None + selector: + app: bookkeeper + component: bookie diff --git a/herddb-docker/src/main/kubernetes/samples/bookkeeper/4_bookkeeper.deployment.yaml b/herddb-docker/src/main/kubernetes/samples/bookkeeper/4_bookkeeper.deployment.yaml new file mode 100644 index 000000000..2ab56cc80 --- /dev/null +++ b/herddb-docker/src/main/kubernetes/samples/bookkeeper/4_bookkeeper.deployment.yaml @@ -0,0 +1,27 @@ +## from https://raw.githubusercontent.com/apache/bookkeeper/master/deploy/kubernetes/gke/bookkeeper.yaml + +## +## Run BookKeeper auto-recovery from a different set of containers +## Auto-Recovery makes sure to restore the replication factor when any bookie +## crashes and it's not recovering on its own. +## +apiVersion: apps/v1beta1 +kind: Deployment +metadata: + name: bookie-autorecovery +spec: + replicas: 2 + template: + metadata: + labels: + app: bookkeeper + component: bookkeeper-replication + spec: + containers: + - name: replication-worker + image: apache/bookkeeper:latest + command: [ "/bin/bash", "/opt/bookkeeper/entrypoint.sh" ] + args: ["/opt/bookkeeper/bin/bookkeeper", "autorecovery"] + envFrom: + - configMapRef: + name: bookie-config diff --git a/herddb-docker/src/main/kubernetes/samples/herddb/1_herddb.configmap.yaml b/herddb-docker/src/main/kubernetes/samples/herddb/1_herddb.configmap.yaml new file mode 100644 index 000000000..a48d7a530 --- /dev/null +++ b/herddb-docker/src/main/kubernetes/samples/herddb/1_herddb.configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: herddb-config +data: + herddb_env_http_enable: 'true' + # customize at need diff --git a/herddb-docker/src/main/kubernetes/samples/herddb/2_herddb.persistentvolume.yaml b/herddb-docker/src/main/kubernetes/samples/herddb/2_herddb.persistentvolume.yaml new file mode 100644 index 000000000..d71907815 --- /dev/null +++ b/herddb-docker/src/main/kubernetes/samples/herddb/2_herddb.persistentvolume.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: herddb-pv-volume + labels: + type: local +spec: + # customize by need/k8s env + storageClassName: manual + capacity: + storage: 10Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/tmp/minikube/herddb" diff --git a/herddb-docker/src/main/kubernetes/samples/herddb/3_herddb.persistentvolumeclaim.yaml b/herddb-docker/src/main/kubernetes/samples/herddb/3_herddb.persistentvolumeclaim.yaml new file mode 100644 index 000000000..0b732eeb7 --- /dev/null +++ b/herddb-docker/src/main/kubernetes/samples/herddb/3_herddb.persistentvolumeclaim.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: herddb-pv-claim +spec: + storageClassName: manual + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 3Gi diff --git a/herddb-docker/src/main/kubernetes/samples/herddb/4_herddb.deployment.yaml b/herddb-docker/src/main/kubernetes/samples/herddb/4_herddb.deployment.yaml new file mode 100644 index 000000000..5ac7e3e97 --- /dev/null +++ b/herddb-docker/src/main/kubernetes/samples/herddb/4_herddb.deployment.yaml @@ -0,0 +1,46 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: herddb +spec: + selector: + matchLabels: + app: herddb + replicas: 1 + template: + metadata: + labels: + app: herddb + spec: + containers: + - envFrom: + - configMapRef: + name: herddb-config + image: 'herddb/herddb-server:latest' + imagePullPolicy: IfNotPresent + name: herddb + ports: + - containerPort: 9485 + name: http + - containerPort: 7000 + name: database + readinessProbe: + httpGet: + path: /metrics + port: 9485 + initialDelaySeconds: 3 + periodSeconds: 3 + livenessProbe: + httpGet: + path: /metrics + port: 9485 + initialDelaySeconds: 3 + periodSeconds: 3 + volumeMounts: + - mountPath: /data + name: herddb-data + restartPolicy: Always + volumes: + - name: herddb-data + persistentVolumeClaim: + claimName: herddb-pv-claim diff --git a/herddb-docker/src/main/kubernetes/samples/herddb/5_herddb.service.yaml b/herddb-docker/src/main/kubernetes/samples/herddb/5_herddb.service.yaml new file mode 100644 index 000000000..b8f589519 --- /dev/null +++ b/herddb-docker/src/main/kubernetes/samples/herddb/5_herddb.service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: herddb-service +spec: + selector: + app: herddb + ports: + - protocol: TCP + port: 80 + targetPort: 9485