Skip to content

Commit

Permalink
Update StatefulSet doc (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
Md. Emruz Hossain authored and tamalsaha committed Apr 20, 2018
1 parent d5a461b commit 1f71dae
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 41 deletions.
32 changes: 13 additions & 19 deletions docs/examples/workloads/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,20 @@ spec:
spec:
serviceAccountName: statefulset-demo
containers:
- command:
- image: busybox
name: busybox
imagePullPolicy: IfNotPresent
command:
- sleep
- "3600"
image: busybox
imagePullPolicy: IfNotPresent
name: busybox
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /source/data
name: source-data
- args:
- image: appscode/stash:0.7.0-rc.3
name: stash
imagePullPolicy: IfNotPresent
args:
- backup
- --restic-name=statefulset-restic
- --workload-kind=Statefulset
Expand All @@ -116,12 +117,7 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
image: appscode/stash:0.7.0-rc.3
imagePullPolicy: IfNotPresent
name: stash
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /tmp
name: stash-scratchdir
Expand All @@ -132,12 +128,14 @@ spec:
readOnly: true
- mountPath: /safe/data
name: stash-local
restartPolicy: Always
volumes:
volumes:
- gitRepo:
repository: https://github.com/appscode/stash-data.git
name: source-data
- hostPath:
path: /data/stash-test/restic-repo
type: ""
name: stash-local
- emptyDir: {}
name: stash-scratchdir
- downwardAPI:
Expand All @@ -147,8 +145,4 @@ spec:
apiVersion: v1
fieldPath: metadata.labels
path: labels
name: stash-podinfo
- hostPath:
path: /data/stash-test/restic-repo
type: ""
name: stash-local
name: stash-podinfo
35 changes: 15 additions & 20 deletions docs/guides/workloads.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ To backup a ReplicationController, create a Restic with matching selectors. You
To backup a DaemonSet, create a Restic with matching selectors. You can find a full working demo in [examples folder](/docs/examples/workloads/daemonset.yaml). This example shows how Stash can be used to backup host paths on all nodes of a cluster. First run a DaemonSet without nodeSelectors. This DaemonSet acts as a vector for Restic sidecar and mounts host paths that are to be backed up. In this example, we use a `busybox` container for this. Now, create a Restic that has a matching selector. This Restic also `spec.volumeMounts` the said host path and points to the host path in `spec.fileGroups`.

## StatefulSets
Kubernetes does not support updating StatefulSet after they are created. It is recomanded to use initializer for StatefulSets. For details see [here](/docs/initializer.md).
Otherwise you need to add Stash sidecar container to your StatefulSet manually. You can see the relevant portions of a working example below:
Kubernetes does not support adding sidecar to a StatefulSet after it is created. It is recommended to enable **mutating webhook** by providing `--enable-mutating-webhook` flag while installing stash. To know more about how to provide various flag while installing stash see [here](/docs/setup/install.md#customizing-installer).

If you don't want to enable **mutating webhook** then you have to add Stash sidecar container to your StatefulSet manually. You can see the relevant portions of a working example below:

```yaml
apiVersion: apps/v1beta1
Expand All @@ -53,19 +54,20 @@ spec:
spec:
serviceAccountName: statefulset-demo
containers:
- command:
- image: busybox
name: busybox
imagePullPolicy: IfNotPresent
command:
- sleep
- "3600"
image: busybox
imagePullPolicy: IfNotPresent
name: busybox
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /source/data
name: source-data
- args:
- image: appscode/stash:0.7.0-rc.3
name: stash
imagePullPolicy: IfNotPresent
args:
- backup
- --restic-name=statefulset-restic
- --workload-kind=Statefulset
Expand All @@ -83,12 +85,7 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
image: appscode/stash:0.7.0-rc.3
imagePullPolicy: IfNotPresent
name: stash
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /tmp
name: stash-scratchdir
Expand All @@ -99,12 +96,14 @@ spec:
readOnly: true
- mountPath: /safe/data
name: stash-local
restartPolicy: Always
volumes:
volumes:
- gitRepo:
repository: https://github.com/appscode/stash-data.git
name: source-data
- hostPath:
path: /data/stash-test/restic-repo
type: ""
name: stash-local
- emptyDir: {}
name: stash-scratchdir
- downwardAPI:
Expand All @@ -115,10 +114,6 @@ spec:
fieldPath: metadata.labels
path: labels
name: stash-podinfo
- hostPath:
path: /data/stash-test/restic-repo
type: ""
name: stash-local
```
You can find the full working demo in [examples folder](/docs/examples/workloads/statefulset.yaml). The section you should change for your own StatefulSet are:
Expand Down
3 changes: 1 addition & 2 deletions docs/setup/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,12 @@ $ curl -fsSL https://raw.githubusercontent.com/appscode/stash/0.7.0-rc.3/hack/de
| bash -s -- --docker-registry=MY_REGISTRY [--image-pull-secret=SECRET_NAME] [--rbac]
```

Stash implements [validating admission webhooks](https://kubernetes.io/docs/admin/admission-controllers/#validatingadmissionwebhook-alpha-in-18-beta-in-19) to validate Stash CRDs and mutating webhooks for Kubernetes workload types. This is helpful when you create `Restic` before creating workload objects. This allows stash operator to initialize the target workloads by adding sidecar or, init-container before workload-pods are created. Thus stash operator does not need to delete workload pods for applying changes. This is particularly helpful for workload kind `StatefulSet`, since Kubernetes does not adding sidecar / init containers to StatefulSets after they are created. This is enabled by default for Kubernetes 1.9.0 or later releases. To disable this feature, pass the `--enable-validating-webhook=false` and `--enable-mutating-webhook=false` flag respectively.
Stash implements [validating admission webhooks](https://kubernetes.io/docs/admin/admission-controllers/#validatingadmissionwebhook-alpha-in-18-beta-in-19) to validate Stash CRDs and **mutating webhooks** for Kubernetes workload types. This is helpful when you create `Restic` before creating workload objects. This allows stash operator to initialize the target workloads by adding sidecar or, init-container before workload-pods are created. Thus stash operator does not need to delete workload pods for applying changes. This is particularly helpful for workload kind `StatefulSet`, since Kubernetes does not support adding sidecar / init containers to StatefulSets after they are created. This is enabled by default for Kubernetes 1.9.0 or later releases. To disable this feature, pass the `--enable-validating-webhook=false` and `--enable-mutating-webhook=false` flag respectively.

```console
$ curl -fsSL https://raw.githubusercontent.com/appscode/stash/0.7.0-rc.3/hack/deploy/stash.sh \
| bash -s -- --enable-validating-webhook=false --enable-mutating-webhook=false [--rbac]
```
To know more about webhook in stash please visit [here]().

## Using Helm
Stash can be installed via [Helm](https://helm.sh/) using the [chart](https://github.com/appscode/stash/tree/0.7.0-rc.3/chart/stash) from [AppsCode Charts Repository](https://github.com/appscode/charts). To install the chart with the release name `my-release`:
Expand Down

0 comments on commit 1f71dae

Please sign in to comment.