Skip to content
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

Add kubedb catalog #256

Merged
merged 1 commit into from
Aug 3, 2018
Merged
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
23 changes: 23 additions & 0 deletions chart/kubedb-catalog/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
# Helm files
OWNERS
12 changes: 12 additions & 0 deletions chart/kubedb-catalog/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
description: 'KubeDB Catalog by AppsCode - Catalog for database versions'
name: kubedb-catalog
version: 0.8.0
appVersion: 0.8.0
home: https://github.com/kubedb/cli
icon: https://cdn.appscode.com/images/icon/kubedb.png
sources:
- https://github.com/kubedb/cli
maintainers:
- name: appscode
email: [email protected]
20 changes: 20 additions & 0 deletions chart/kubedb-catalog/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "kubedb-catalog.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "kubedb-catalog.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
53 changes: 53 additions & 0 deletions chart/kubedb-catalog/templates/postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
apiVersion: kubedb.com/v1alpha1
kind: PostgresVersion
metadata:
name: "9.6"
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app: "{{ template "kubedb-catalog.name" . }}"
heritage: "{{ .Release.Service }}"
release: "{{ .Release.Name }}"
spec:
db:
image: "{{ .Values.dockerRegistry }}/postgres:9.6"
exporter:
image: "{{ .Values.dockerRegistry }}/operator:0.8.0"
tools:
image: "{{ .Values.dockerRegistry }}/postgres-tools:9.6"

---
apiVersion: kubedb.com/v1alpha1
kind: PostgresVersion
metadata:
name: "9.6.7"
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app: "{{ template "kubedb-catalog.name" . }}"
heritage: "{{ .Release.Service }}"
release: "{{ .Release.Name }}"
spec:
db:
image: "{{ .Values.dockerRegistry }}/postgres:9.6.7"
exporter:
image: "{{ .Values.dockerRegistry }}/operator:0.8.0"
tools:
image: "{{ .Values.dockerRegistry }}/postgres-tools:9.6.7"

---
apiVersion: kubedb.com/v1alpha1
kind: PostgresVersion
metadata:
name: "10.2"
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app: "{{ template "kubedb-catalog.name" . }}"
heritage: "{{ .Release.Service }}"
release: "{{ .Release.Name }}"
spec:
db:
image: "{{ .Values.dockerRegistry }}/postgres:10.2"
exporter:
image: "{{ .Values.dockerRegistry }}/operator:0.8.0"
tools:
image: "{{ .Values.dockerRegistry }}/postgres-tools:10.2"
1 change: 1 addition & 0 deletions chart/kubedb-catalog/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dockerRegistry: "kubedb"
2 changes: 1 addition & 1 deletion docs/concepts/databases/postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ spec:

### spec.version

`spec.version` is a required field specifying the version of PostgreSQL database. Currently, the supported versions are:
`spec.version` is a required field specifying the name of the PostgresVersion crd where the docker images are specified. Currently, the kubedb catalog installs:

- `9.6.7`, `9.6`
- `10.2`
Expand Down
10 changes: 10 additions & 0 deletions docs/guides/postgres/custom-versions/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: PostgreSQL Custom Versions
menu:
docs_0.8.0:
identifier: pg-custom-versions-postgres
name: Custom Versions
parent: pg-postgres-guides
weight: 20
menu_name: docs_0.8.0
---
92 changes: 92 additions & 0 deletions docs/guides/postgres/custom-versions/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
title: Setup Custom PostgresVersions
menu:
docs_0.8.0:
identifier: pg-custom-versions-setup-postgres
name: Overview
parent: pg-custom-versions-postgres
weight: 10
menu_name: docs_0.8.0
section_menu_id: guides
---
> New to KubeDB? Please start [here](/docs/concepts/README.md).

## Setting up Custom PostgresVersions

PostgresVersions are KubeDB crds that define the docker images KubeDB will use when deploying a postgres database.

## Creating a Custom Postgres Database Image for KubeDB

The best way to create a custom image is to build on top of the existing kubedb image.

```docker
FROM kubedb/postgres:10.2

ENV TIMESCALEDB_VERSION 0.9.1

RUN set -ex \
&& apk add --no-cache --virtual .fetch-deps \
ca-certificates \
openssl \
tar \
&& mkdir -p /build/timescaledb \
&& wget -O /timescaledb.tar.gz https://github.com/timescale/timescaledb/archive/$TIMESCALEDB_VERSION.tar.gz \
&& tar -C /build/timescaledb --strip-components 1 -zxf /timescaledb.tar.gz \
&& rm -f /timescaledb.tar.gz \
\
&& apk add --no-cache --virtual .build-deps \
coreutils \
dpkg-dev dpkg \
gcc \
libc-dev \
make \
cmake \
util-linux-dev \
\
&& cd /build/timescaledb \
&& ./bootstrap \
&& cd build && make install \
&& cd ~ \
\
&& apk del .fetch-deps .build-deps \
&& rm -rf /build

RUN sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" /scripts/primary/postgresql.conf
```

From there we would define a PostgresVersion that contains this new image. Lets say we tagged it as `myco/postgres:timescale-0.9.1`

```yaml
apiVersion: kubedb.com/v1alpha1
kind: PostgresVersion
metadata:
name: timescale-0.9.1
spec:
version: 10.2
db:
image: "myco/postgres:timescale-0.9.1"
exporter:
image: "kubedb/operator:0.8.0"
tools:
image: "kubedb/postgres-tools:10.2"
```

Once we add this PostgresVersion we can use it in a new Postgres like:

```yaml
apiVersion: kubedb.com/v1alpha1
kind: Postgres
metadata:
name: timescale-postgres
namespace: demo
spec:
version: "timescale-0.9.1" # points to the name of our custom PostgresVersion
doNotPause: true
storage:
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi
```
3 changes: 2 additions & 1 deletion docs/guides/postgres/quickstart/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ spec:

Here,

- `spec.version` is the version of PostgreSQL database. In this tutorial, a PostgreSQL 9.6 database is created.
- `spec.version` is name of the PostgresVersion crd where the docker images are specified. In this tutorial, a PostgreSQL 9.6 database is created.
- `spec.doNotPause` prevents users from deleting this object if admission webhook is enabled.
- `spec.storage` specifies the StorageClass of PVC dynamically allocated to store data for this database. This storage spec will be passed to the StatefulSet created by KubeDB operator to run database pods. You can specify any StorageClass available in your cluster with appropriate resource requests. Since release 0.8.0, a storage spec is required for MySQL.

Expand Down Expand Up @@ -376,6 +376,7 @@ $ kubectl delete ns demo
- Learn how to [schedule backup](/docs/guides/postgres/snapshot/scheduled_backup.md) of PostgreSQL database.
- Learn about initializing [PostgreSQL with Script](/docs/guides/postgres/initialization/script_source.md).
- Learn about initializing [PostgreSQL from KubeDB Snapshot](/docs/guides/postgres/initialization/snapshot_source.md).
- Learn about [custom PostgresVersions](/docs/guides/postgres/custom-versions/setup.md).
- Want to setup PostgreSQL cluster? Check how to [configure Highly Available PostgreSQL Cluster](/docs/guides/postgres/clustering/ha_cluster.md)
- Monitor your PostgreSQL database with KubeDB using [built-in Prometheus](/docs/guides/postgres/monitoring/using-builtin-prometheus.md).
- Monitor your PostgreSQL database with KubeDB using [CoreOS Prometheus Operator](/docs/guides/postgres/monitoring/using-coreos-prometheus-operator.md).
Expand Down
11 changes: 11 additions & 0 deletions docs/setup/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ options:
--enable-mutating-webhook enable/disable mutating webhooks for KubeDB CRDs
--enable-status-subresource If enabled, uses status sub resource for crds
--enable-analytics send usage events to Google Analytics (default: true)
--enable-catalog If enabled, installs kubedb database version catalog (default: true)
--uninstall uninstall KubeDB
--purge purges KubeDB crd objects and crds
```
Expand Down Expand Up @@ -106,6 +107,13 @@ $ curl -fsSL https://raw.githubusercontent.com/kubedb/cli/0.8.0/hack/deploy/kube

KubeDB 0.9.0 or later releases can use status sub resource for CustomResourceDefintions. This is enabled by default for Kubernetes 1.11.0 or later releases. To disable this feature, pass the `--enable-status-subresource=false` flag.

KubeDB 0.9.0 or later installs a catalog of database versions. To disable this pass the `--enable-catalog=false` flag.

```console
$ curl -fsSL https://raw.githubusercontent.com/kubedb/cli/0.8.0/hack/deploy/kubedb.sh \
| bash -s -- --enable-catalog=false [--rbac]
```

</div>
<div class="tab-pane fade" id="helm" role="tabpanel" aria-labelledby="helm-tab">

Expand Down Expand Up @@ -134,6 +142,9 @@ $ helm install appscode/kubedb --name kubedb-operator --version 0.8.0 \
--set apiserver.enableValidatingWebhook=true \
--set apiserver.enableMutatingWebhook=true \
--set apiserver.enableStatusSubresource=true

# KubeDB catalog of database versions
$ helm install appscode/kubedb-catalog --name kubedb-catalog
```

To install `onessl`, run the following commands:
Expand Down
44 changes: 44 additions & 0 deletions hack/deploy/kubedb-catalog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
apiVersion: kubedb.com/v1alpha1
kind: PostgresVersion
metadata:
name: "9.6"
labels:
app: kubedb
spec:
db:
image: "${KUBEDB_DOCKER_REGISTRY}/postgres:9.6"
exporter:
image: "${KUBEDB_DOCKER_REGISTRY}/operator:0.8.0"
tools:
image: "${KUBEDB_DOCKER_REGISTRY}/postgres-tools:9.6"

---
apiVersion: kubedb.com/v1alpha1
kind: PostgresVersion
metadata:
name: "9.6.7"
labels:
app: kubedb
spec:
db:
image: "${KUBEDB_DOCKER_REGISTRY}/postgres:9.6.7"
exporter:
image: "${KUBEDB_DOCKER_REGISTRY}/operator:0.8.0"
tools:
image: "${KUBEDB_DOCKER_REGISTRY}/postgres-tools:9.6.7"

---
apiVersion: kubedb.com/v1alpha1
kind: PostgresVersion
metadata:
name: "10.2"
labels:
app: kubedb
spec:
db:
image: "${KUBEDB_DOCKER_REGISTRY}/postgres:10.2"
exporter:
image: "${KUBEDB_DOCKER_REGISTRY}/operator:0.8.0"
tools:
image: "${KUBEDB_DOCKER_REGISTRY}/postgres-tools:10.2"
16 changes: 16 additions & 0 deletions hack/deploy/kubedb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export KUBEDB_ENABLE_RBAC=true
export KUBEDB_RUN_ON_MASTER=0
export KUBEDB_ENABLE_VALIDATING_WEBHOOK=false
export KUBEDB_ENABLE_MUTATING_WEBHOOK=false
export KUBEDB_ENABLE_CATALOG=true
export KUBEDB_DOCKER_REGISTRY=kubedb
export KUBEDB_OPERATOR_TAG=0.8.0
export KUBEDB_OPERATOR_NAME=operator
Expand Down Expand Up @@ -144,6 +145,7 @@ show_help() {
echo " --enable-mutating-webhook enable/disable mutating webhooks for KubeDB CRDs"
echo " --enable-status-subresource If enabled, uses status sub resource for KubeDB crds"
echo " --enable-analytics send usage events to Google Analytics (default: true)"
echo " --enable-catalog If enabled, installs kubedb database version catalog (default: true)"
echo " --operator-name specify which kubedb operator to deploy (default: operator)"
echo " --uninstall uninstall KubeDB"
echo " --purge purges KubeDB crd objects and crds"
Expand Down Expand Up @@ -206,6 +208,13 @@ while test $# -gt 0; do
fi
shift
;;
--enable-catalog*)
shift
val=$(echo $1 | sed -e 's/^[^=]*=//g')
if [ "$val" = "false" ]; then
export KUBEDB_ENABLE_CATALOG=false
fi
;;
--rbac*)
val=$(echo $1 | sed -e 's/^[^=]*=//g')
if [ "$val" = "false" ]; then
Expand Down Expand Up @@ -254,6 +263,8 @@ if [ "$KUBEDB_UNINSTALL" -eq 1 ]; then
kubectl delete rolebindings -l app=kubedb --namespace $KUBEDB_NAMESPACE
kubectl delete role -l app=kubedb --namespace $KUBEDB_NAMESPACE

kubectl delete postgresversion -l app=kubedb

echo "waiting for kubedb operator pod to stop running"
for (( ; ; )); do
pods=($(kubectl get pods --all-namespaces -l app=kubedb -o jsonpath='{range .items[*]}{.metadata.name} {end}'))
Expand Down Expand Up @@ -378,5 +389,10 @@ if [ "$KUBEDB_OPERATOR_NAME" = "operator" ]; then
done
fi

if [ "$KUBEDB_ENABLE_CATALOG" = true ]; then
echo "adding kubedb catalog"
${SCRIPT_LOCATION}hack/deploy/kubedb-catalog.yaml | $ONESSL envsubst | kubectl apply -f -
fi

echo
echo "Successfully installed KubeDB operator in $KUBEDB_NAMESPACE namespace!"