From 1f71dae104bdf2f01bc9abbf93caa5fff9bc4681 Mon Sep 17 00:00:00 2001 From: "Md. Emruz Hossain" Date: Fri, 20 Apr 2018 11:36:26 +0600 Subject: [PATCH] Update StatefulSet doc (#445) --- docs/examples/workloads/statefulset.yaml | 32 +++++++++------------- docs/guides/workloads.md | 35 ++++++++++-------------- docs/setup/install.md | 3 +- 3 files changed, 29 insertions(+), 41 deletions(-) diff --git a/docs/examples/workloads/statefulset.yaml b/docs/examples/workloads/statefulset.yaml index d06fe88ac..eb962cdc6 100644 --- a/docs/examples/workloads/statefulset.yaml +++ b/docs/examples/workloads/statefulset.yaml @@ -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 @@ -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 @@ -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: @@ -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 \ No newline at end of file diff --git a/docs/guides/workloads.md b/docs/guides/workloads.md index 8fa043226..2c9f6adea 100644 --- a/docs/guides/workloads.md +++ b/docs/guides/workloads.md @@ -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 @@ -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 @@ -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 @@ -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: @@ -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: diff --git a/docs/setup/install.md b/docs/setup/install.md index e843f6359..0fb4639df 100644 --- a/docs/setup/install.md +++ b/docs/setup/install.md @@ -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`: