Skip to content

Commit

Permalink
Create RBAC roles during installation (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha authored Jul 7, 2017
1 parent 920d083 commit e3a18bb
Show file tree
Hide file tree
Showing 57 changed files with 436 additions and 3,539 deletions.
2 changes: 1 addition & 1 deletion docs/describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Status: Running
No volumes.

StatefulSet:
Name: postgres-demo-pg
Name: postgres-demo
Replicas: 1 current / 1 desired
CreationTimestamp: Mon, 05 Jun 2017 10:10:14 +0600
Pods Status: 1 Running / 0 Waiting / 0 Succeeded / 0 Failed
Expand Down
8 changes: 4 additions & 4 deletions docs/edit.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ $ kubedb edit pg postgres-demo
# Add following under Spec to configure periodic backups
# backupSchedule:
# cronExpression: "@every 6h"
# bucketName: "bucket-name"
# storageSecret:
# secretName: "secret-name"
# storageSecretName: "secret-name"
# gcs:
# bucket: "bucket-name"

postgres "postgres-demo" edited
```
Expand Down Expand Up @@ -43,6 +43,6 @@ Elastic:
* _spec.nodeSelector_
* _spec.init_

For DormantDatabase, _spec.origin_ can't be edited using `kbuedb edit`
For DormantDatabase, _spec.origin_ can't be edited using `kubedb edit`

To learn about various options of `edit` command, please visit [here](/docs/reference/kubedb_edit.md).
10 changes: 6 additions & 4 deletions docs/elastic.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ As `spec.storage` fields are set, StatefulSet will be created with dynamically p
```bash
$ kubectl get pvc --selector='kubedb.com/kind=Elastic,kubedb.com/name=elasticsearch-db'
NAME STATUS VOLUME CAPACITY ACCESSMODES AGE
data-elasticsearch-db-pg-0 Bound pvc-a1a95954-4a75-11e7-8b69-12f236046fba 10Gi RWO 2m
NAME STATUS VOLUME CAPACITY ACCESSMODES AGE
data-elasticsearch-db-0 Bound pvc-a1a95954-4a75-11e7-8b69-12f236046fba 10Gi RWO 2m
```


### Database Initialization
Elasticsearch databases can be created from a previously takes Snapshot. To initialize from prior snapshot, set the `spec.init.snapshotSource` section when creating an Elastic object.
Elasticsearch databases can be created from a previously takes Snapshot.
To initialize from prior snapshot, set the `spec.init.snapshotSource` section when creating an Elastic object.

In this case, SnapshotSource must have following information:
1. `namespace:` Namespace of Snapshot object
Expand All @@ -95,4 +96,5 @@ spec:
name: "snapshot-xyz"
```

In the above example, Elasticsearch database will be initialized from Snapshot `snapshot-xyz` in `default` namespace. Here, KubeDB operator will launch a Job to initialize Elasticsearch once StatefulSet pods are running.
In the above example, Elasticsearch database will be initialized from Snapshot `snapshot-xyz` in `default`
namespace. Here, KubeDB operator will launch a Job to initialize Elasticsearch once StatefulSet pods are running.
6 changes: 3 additions & 3 deletions docs/examples/elastic/elastic-with-scheduled-backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ spec:
replicas: 1
backupSchedule:
cronExpression: "@every 6h"
bucketName: "bucket-for-snapshot"
storageSecret:
secretName: "secret-for-bucket"
storageSecretName: "secret-for-bucket"
gcs:
bucket: "bucket-for-snapshot"
12 changes: 12 additions & 0 deletions docs/examples/elastic/snapshot-local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: kubedb.com/v1alpha1
kind: Snapshot
metadata:
name: snapshot-xyz
labels:
kubedb.com/kind: Elastic
spec:
databaseName: elasticsearch-db
local:
path: /repo
volumeSource:
emptyDir: {}
6 changes: 3 additions & 3 deletions docs/examples/elastic/snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ metadata:
kubedb.com/kind: Elastic
spec:
databaseName: elasticsearch-db
bucketName: "bucket-for-snapshot"
storageSecret:
secretName: "secret-for-bucket"
storageSecretName: "secret-for-bucket"
gcs:
bucket: "bucket-for-snapshot"
6 changes: 3 additions & 3 deletions docs/examples/postgres/postgres-with-scheduled-backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ spec:
version: 9.5
backupSchedule:
cronExpression: "@every 6h"
bucketName: "bucket-for-snapshot"
storageSecret:
secretName: "secret-for-bucket"
storageSecretName: "secret-for-bucket"
gcs:
bucket: "bucket-for-snapshot"
12 changes: 12 additions & 0 deletions docs/examples/postgres/snapshot-local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: kubedb.com/v1alpha1
kind: Snapshot
metadata:
name: snapshot-xyz
labels:
kubedb.com/kind: Postgres
spec:
databaseName: postgres-db
local:
path: /repo
volumeSource:
emptyDir: {}
6 changes: 3 additions & 3 deletions docs/examples/postgres/snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ metadata:
kubedb.com/kind: Postgres
spec:
databaseName: postgres-db
bucketName: "bucket-for-snapshot"
storageSecret:
secretName: "secret-for-bucket"
storageSecretName: "secret-for-bucket"
gcs:
bucket: "bucket-for-snapshot"
1 change: 0 additions & 1 deletion docs/examples/snapshot/gcs/gcs-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ spec:
databaseName: postgres-db
storageSecretName: gcs-secret
gcs:
location: /repo
bucket: bucket-for-snapshot
5 changes: 2 additions & 3 deletions docs/examples/snapshot/local/local-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
apiVersion: kubedb.com/v1alpha1
kind: Snapshot
metadata:
name: snapshot-xyz
name: local-snapshot
labels:
kubedb.com/kind: Postgres
spec:
databaseName: postgres-db
local:
path: /repo
volume:
volumeSource:
emptyDir: {}
name: repo
8 changes: 4 additions & 4 deletions docs/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ pg/postgres-dev 9.5 Running 3h
pg/postgres-prod 9.5 Running 3h
pg/postgres-qa 9.5 Running 3h
NAME DATABASE BUCKET STATUS AGE
snap/postgres-demo-20170605-073557 pg/postgres-demo bucket-name Succeeded 9m
snap/snapshot-20170505-1147 pg/postgres-demo bucket-name Succeeded 1h
snap/snapshot-xyz es/elasticsearch-demo bucket-name Succeeded 5m
NAME DATABASE BUCKET STATUS AGE
snap/postgres-demo-20170605-073557 pg/postgres-demo gs:bucket-name Succeeded 9m
snap/snapshot-20170505-1147 pg/postgres-demo gs:bucket-name Succeeded 1h
snap/snapshot-xyz es/elasticsearch-demo local:/directory Succeeded 5m
```

Flag `--output=wide` is used to print additional information.
Expand Down
4 changes: 2 additions & 2 deletions docs/postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ As `spec.storage` fields are set, StatefulSet will be created with dynamically p
```sh
$ kubectl get pvc --selector='kubedb.com/kind=Postgres,kubedb.com/name=postgres-db'
NAME STATUS VOLUME CAPACITY ACCESSMODES AGE
data-postgres-db-pg-0 Bound pvc-a1a95954-4a75-11e7-8b69-12f236046fba 10Gi RWO 2m
NAME STATUS VOLUME CAPACITY ACCESSMODES AGE
data-postgres-db-0 Bound pvc-a1a95954-4a75-11e7-8b69-12f236046fba 10Gi RWO 2m
```


Expand Down
10 changes: 5 additions & 5 deletions docs/reference/kubedb_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ kubedb init [flags]
### Options

```
-h, --help help for init
--operator-namespace string Name of namespace where operator will be deployed. (default "kube-system")
--operator-service-account string Service account name used to run operator (default "default")
--upgrade If present, Upgrade operator to use provided version
--version string Operator version (default "0.2.0")
-h, --help help for init
--operator-namespace string Name of namespace where operator will be deployed. (default "kube-system")
--rbac If true, uses RBAC with operator and database objects
--upgrade If present, Upgrade operator to use provided version
--version string Operator version (default "0.2.0")
```

### Options inherited from parent commands
Expand Down
38 changes: 19 additions & 19 deletions docs/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# Snapshots

## What is Snapshot
A `Snapshot` is a Kubernetes `Third Party Object` (TPR). It provides declarative configuration for database snapshots in a Kubernetes native way. You only need to describe the desired backup operations in a Snapshot object, and the KubeDB operator will launch a Job to perform backup operation.
A `Snapshot` is a Kubernetes `Third Party Object` (TPR). It provides declarative configuration for database snapshots in a Kubernetes native way.
You only need to describe the desired backup operations in a Snapshot object, and the KubeDB operator will launch a Job to perform backup operation.

## Snapshot Spec
As with all other Kubernetes objects, a Snapshot needs `apiVersion`, `kind`, and `metadata` fields. The metadata field must contain a label with `kubedb.com/kind` key.
As with all other Kubernetes objects, a Snapshot needs `apiVersion`, `kind`, and `metadata` fields.
The metadata field must contain a label with `kubedb.com/kind` key.
The valid values for this label are `Postgres` or `Elastic`. It also needs a `.spec` section. Below is an example Snapshot object.

```yaml
Expand All @@ -17,7 +19,7 @@ metadata:
labels:
kubedb.com/kind: Postgres|Elastic
spec:
databaseName: postgres-db
databaseName: database-name
storageSecretName: s3-secret
s3:
endpoint: 's3.amazonaws.com'
Expand All @@ -32,11 +34,11 @@ The `.spec` section supports the following different cloud providers to store sn
`Local` backend refers to a local path inside snapshot job container. Any Kubernetes supported [persistent volume](https://kubernetes.io/docs/concepts/storage/volumes/) can be used here. Some examples are: `emptyDir` for testing, NFS, Ceph, GlusterFS, etc.
To configure this backend, no secret is needed. Following parameters are available for `Local` backend.

| Parameter | Description |
|---------------------|-----------------------------------------------------------------------------------------|
| `spec.databaseName` | `Required`. Name of database |
| `spec.local.path` | `Required`. Path where this volume will be mounted in the job container. Example: /repo |
| `spec.local.volume` | `Required`. Any Kubernetes volume |
| Parameter | Description |
|---------------------------|-----------------------------------------------------------------------------------------|
| `spec.databaseName` | `Required`. Name of database |
| `spec.local.path` | `Required`. Path where this volume will be mounted in the job container. Example: /repo |
| `spec.local.volumeSource` | `Required`. Any Kubernetes [volume](https://kubernetes.io/docs/concepts/storage/volumes/#types-of-volumes) |

```sh
$ kubectl create -f ./docs/examples/snapshot/local/local-snapshot.yaml
Expand All @@ -60,12 +62,10 @@ spec:
databaseName: postgres-db
local:
path: /repo
volume:
volumeSource:
emptyDir: {}
name: repo
```
### AWS S3
KubeDB supports AWS S3 service or [Minio](https://minio.io/) servers as snapshot storage backend. To configure this backend, following secret keys are needed:
Expand Down Expand Up @@ -108,8 +108,8 @@ Now, you can create a Snapshot tpr using this secret. Following parameters are a
| `spec.databaseName` | `Required`. Name of database |
| `spec.storageSecretName` | `Required`. Name of storage secret |
| `spec.s3.endpoint` | `Required`. For S3, use `s3.amazonaws.com`. If your bucket is in a different location, S3 server (s3.amazonaws.com) will redirect snapshot to the correct endpoint. For an S3-compatible server that is not Amazon (like Minio), or is only available via HTTP, you can specify the endpoint like this: `http://server:port`. |
| `spec.s3.region` | `Required`. Name of AWS region |
| `spec.s3.bucket` | `Required`. Name of Bucket |
| `spec.s3.prefix` | `Optional`. Path prefix in Bucket |

```sh
$ kubectl create -f ./docs/examples/snapshot/s3/s3-snapshot.yaml
Expand Down Expand Up @@ -181,8 +181,8 @@ Now, you can create a Snapshot tpr using this secret. Following parameters are a
|--------------------------|---------------------------------------------------------------------------------|
| `spec.databaseName` | `Required`. Name of database |
| `spec.storageSecretName` | `Required`. Name of storage secret |
| `spec.gcs.location` | `Required`. Name of Google Cloud region. |
| `spec.gcs.bucket` | `Required`. Name of Bucket |
| `spec.gcs.prefix` | `Optional`. Path prefix in Bucket |

```sh
$ kubectl create -f ./docs/examples/snapshot/gcs/gcs-snapshot.yaml
Expand All @@ -207,11 +207,9 @@ spec:
databaseName: postgres-db
storageSecretName: gcs-secret
gcs:
location: /repo
bucket: bucket-for-snapshot
```


### Microsoft Azure Storage
KubeDB supports Microsoft Azure Storage as snapshot storage backend. To configure this backend, following secret keys are needed:

Expand Down Expand Up @@ -254,6 +252,7 @@ Now, you can create a Snapshot tpr using this secret. Following parameters are a
| `spec.databaseName` | `Required`. Name of database |
| `spec.storageSecretName` | `Required`. Name of storage secret |
| `spec.azure.container` | `Required`. Name of Storage container |
| `spec.azure.prefix` | `Optional`. Path prefix in container |

```sh
$ kubectl create -f ./docs/examples/snapshot/azure/azure-snapshot.yaml
Expand Down Expand Up @@ -352,6 +351,7 @@ Now, you can create a Snapshot tpr using this secret. Following parameters are a
| `spec.databaseName` | `Required`. Name of database |
| `spec.storageSecretName` | `Required`. Name of storage secret |
| `spec.swift.container` | `Required`. Name of Storage container |
| `spec.swift.prefix` | `Optional`. Path prefix in container |

```sh
$ kubectl create -f ./docs/examples/snapshot/swift/swift-snapshot.yaml
Expand Down Expand Up @@ -405,13 +405,14 @@ Use `kubedb get` to check snap0shot status.
```sh
$ kubedb get snap snapshot-xyz -o wide
NAME DATABASE BUCKET STATUS AGE
snapshot-xyz es/elasticsearch-db snapshot Succeeded 24m
NAME DATABASE BUCKET STATUS AGE
snapshot-xyz es/elasticsearch-db s3:snapshot Succeeded 24m
```


## Schedule Backups
Scheduled backups are supported for all types of databases. To schedule backups, add the following `BackupScheduleSpec` in `spec` of a database tpr. All snapshot storage backends are supported for scheduled backup.
Scheduled backups are supported for all types of databases. To schedule backups, add the following `BackupScheduleSpec` in `spec` of a database tpr.
All snapshot storage backends are supported for scheduled backup.

```yaml
spec:
Expand All @@ -420,7 +421,6 @@ spec:
storageSecretName: "secret-for-bucket"
s3:
endpoint: 's3.amazonaws.com'
region: us-east-1
bucket: kubedb-qa
```

Expand Down
Loading

0 comments on commit e3a18bb

Please sign in to comment.