Skip to content

Commit

Permalink
Enable status subresource for crds (#524)
Browse files Browse the repository at this point in the history
* Enable status subresource for crds
* Update installer
  • Loading branch information
tamalsaha authored Jul 2, 2018
1 parent 8a3a3ba commit ec81f6b
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 11 deletions.
25 changes: 16 additions & 9 deletions apis/stash/v1alpha1/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import (
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
)

var (
EnableStatusSubresource bool
)

func (c Restic) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
return crdutils.NewCustomResourceDefinition(crdutils.Config{
Group: SchemeGroupVersion.Group,
Expand All @@ -17,9 +21,10 @@ func (c Restic) CustomResourceDefinition() *apiextensions.CustomResourceDefiniti
Labels: crdutils.Labels{
LabelsMap: map[string]string{"app": "stash"},
},
SpecDefinitionName: "github.com/appscode/stash/apis/stash/v1alpha1.Restic",
EnableValidation: true,
GetOpenAPIDefinitions: GetOpenAPIDefinitions,
SpecDefinitionName: "github.com/appscode/stash/apis/stash/v1alpha1.Restic",
EnableValidation: true,
GetOpenAPIDefinitions: GetOpenAPIDefinitions,
EnableStatusSubresource: EnableStatusSubresource,
})
}

Expand All @@ -35,9 +40,10 @@ func (c Recovery) CustomResourceDefinition() *apiextensions.CustomResourceDefini
Labels: crdutils.Labels{
LabelsMap: map[string]string{"app": "stash"},
},
SpecDefinitionName: "github.com/appscode/stash/apis/stash/v1alpha1.Recovery",
EnableValidation: true,
GetOpenAPIDefinitions: GetOpenAPIDefinitions,
SpecDefinitionName: "github.com/appscode/stash/apis/stash/v1alpha1.Recovery",
EnableValidation: true,
GetOpenAPIDefinitions: GetOpenAPIDefinitions,
EnableStatusSubresource: EnableStatusSubresource,
})
}

Expand All @@ -53,8 +59,9 @@ func (c Repository) CustomResourceDefinition() *apiextensions.CustomResourceDefi
Labels: crdutils.Labels{
LabelsMap: map[string]string{"app": "stash"},
},
SpecDefinitionName: "github.com/appscode/stash/apis/stash/v1alpha1.Repository",
EnableValidation: true,
GetOpenAPIDefinitions: GetOpenAPIDefinitions,
SpecDefinitionName: "github.com/appscode/stash/apis/stash/v1alpha1.Repository",
EnableValidation: true,
GetOpenAPIDefinitions: GetOpenAPIDefinitions,
EnableStatusSubresource: EnableStatusSubresource,
})
}
1 change: 1 addition & 0 deletions chart/stash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The following table lists the configurable parameters of the Stash chart and the
| `apiserver.enableValidatingWebhook` | Enable validating webhooks for Stash CRDs | false |
| `apiserver.enableMutatingWebhook` | Enable mutating webhooks for Kubernetes workloads | false |
| `apiserver.ca` | CA certificate used by main Kubernetes api server | `` |
| `enableStatusSubresource` | If true, uses status sub resource for crds | `false` |
| `enableAnalytics` | Send usage events to Google Analytics | `true` |


Expand Down
1 change: 1 addition & 0 deletions chart/stash/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spec:
- --audit-log-path=-
- --tls-cert-file=/var/serving-cert/tls.crt
- --tls-private-key-file=/var/serving-cert/tls.key
- --enable-status-subresource={{ .Values.enableStatusSubresource }}
- --enable-analytics={{ .Values.enableAnalytics }}
ports:
- containerPort: 8443
Expand Down
3 changes: 3 additions & 0 deletions chart/stash/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ apiserver:

# Send usage events to Google Analytics
enableAnalytics: true

# If true, uses status sub resource for crds.
enableStatusSubresource: false
1 change: 1 addition & 0 deletions docs/reference/stash.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Stash is a Kubernetes operator for restic. For more information, visit here: htt
```
--alsologtostderr log to standard error as well as files
--enable-analytics Send analytical events to Google Analytics (default true)
--enable-status-subresource If true, uses sub resource for crds.
-h, --help help for stash
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
Expand Down
1 change: 1 addition & 0 deletions docs/reference/stash_backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ stash backup [flags]
```
--alsologtostderr log to standard error as well as files
--enable-analytics Send analytical events to Google Analytics (default true)
--enable-status-subresource If true, uses sub resource for crds.
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--logtostderr log to standard error instead of files
Expand Down
1 change: 1 addition & 0 deletions docs/reference/stash_check.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ stash check [flags]
```
--alsologtostderr log to standard error as well as files
--enable-analytics Send analytical events to Google Analytics (default true)
--enable-status-subresource If true, uses sub resource for crds.
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--logtostderr log to standard error instead of files
Expand Down
1 change: 1 addition & 0 deletions docs/reference/stash_forget.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ stash forget [snapshotID ...] [flags]
```
--alsologtostderr log to standard error as well as files
--enable-analytics Send analytical events to Google Analytics (default true)
--enable-status-subresource If true, uses sub resource for crds.
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--logtostderr log to standard error instead of files
Expand Down
1 change: 1 addition & 0 deletions docs/reference/stash_recover.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ stash recover [flags]
```
--alsologtostderr log to standard error as well as files
--enable-analytics Send analytical events to Google Analytics (default true)
--enable-status-subresource If true, uses sub resource for crds.
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--logtostderr log to standard error instead of files
Expand Down
1 change: 1 addition & 0 deletions docs/reference/stash_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ stash run [flags]
```
--alsologtostderr log to standard error as well as files
--enable-analytics Send analytical events to Google Analytics (default true)
--enable-status-subresource If true, uses sub resource for crds.
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--logtostderr log to standard error instead of files
Expand Down
1 change: 1 addition & 0 deletions docs/reference/stash_scaledown.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ stash scaledown [flags]
```
--alsologtostderr log to standard error as well as files
--enable-analytics Send analytical events to Google Analytics (default true)
--enable-status-subresource If true, uses sub resource for crds.
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--logtostderr log to standard error instead of files
Expand Down
1 change: 1 addition & 0 deletions docs/reference/stash_snapshots.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ stash snapshots [snapshotID ...] [flags]
```
--alsologtostderr log to standard error as well as files
--enable-analytics Send analytical events to Google Analytics (default true)
--enable-status-subresource If true, uses sub resource for crds.
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--logtostderr log to standard error instead of files
Expand Down
1 change: 1 addition & 0 deletions docs/reference/stash_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ stash version [flags]
```
--alsologtostderr log to standard error as well as files
--enable-analytics Send analytical events to Google Analytics (default true)
--enable-status-subresource If true, uses sub resource for crds.
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--logtostderr log to standard error instead of files
Expand Down
5 changes: 4 additions & 1 deletion docs/setup/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ options:
--docker-registry docker registry used to pull stash images (default: appscode)
--image-pull-secret name of secret used to pull stash operator images
--run-on-master run stash operator on master
--enable-validating-webhook enable/disable validating webhooks for Stash CRDs
--enable-validating-webhook enable/disable validating webhooks for Stash crds
--enable-mutating-webhook enable/disable mutating webhooks for Kubernetes workloads
--enable-status-subresource If enabled, uses status sub resource for crds
--enable-analytics send usage events to Google Analytics (default: true)
--uninstall uninstall stash
--purge purges stash crd objects and crds
Expand Down Expand Up @@ -100,6 +101,8 @@ $ curl -fsSL https://raw.githubusercontent.com/appscode/stash/0.7.0/hack/deploy/
| bash -s -- --enable-validating-webhook=false --enable-mutating-webhook=false [--rbac]
```

Stash 0.8.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.

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

Expand Down
1 change: 1 addition & 0 deletions hack/deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ spec:
- --audit-log-path=-
- --tls-cert-file=/var/serving-cert/tls.crt
- --tls-private-key-file=/var/serving-cert/tls.key
- --enable-status-subresource=${STASH_ENABLE_STATUS_SUBRESOURCE}
- --enable-analytics=${STASH_ENABLE_ANALYTICS}
ports:
- containerPort: 8443
Expand Down
12 changes: 11 additions & 1 deletion hack/deploy/stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export STASH_DOCKER_REGISTRY=appscode
export STASH_IMAGE_TAG=0.7.0
export STASH_IMAGE_PULL_SECRET=
export STASH_IMAGE_PULL_POLICY=IfNotPresent
export STASH_ENABLE_STATUS_SUBRESOURCE=false
export STASH_ENABLE_ANALYTICS=true
export STASH_UNINSTALL=0
export STASH_PURGE=0
Expand All @@ -111,6 +112,7 @@ fi

KUBE_APISERVER_VERSION=$(kubectl version -o=json | $ONESSL jsonpath '{.serverVersion.gitVersion}')
$ONESSL semver --check='<1.9.0' $KUBE_APISERVER_VERSION || { export STASH_ENABLE_VALIDATING_WEBHOOK=true; export STASH_ENABLE_MUTATING_WEBHOOK=true; }
$ONESSL semver --check='<1.11.0' $KUBE_APISERVER_VERSION || { export STASH_ENABLE_STATUS_SUBRESOURCE=true; }

show_help() {
echo "stash.sh - install stash operator"
Expand All @@ -124,8 +126,9 @@ show_help() {
echo " --docker-registry docker registry used to pull stash images (default: appscode)"
echo " --image-pull-secret name of secret used to pull stash operator images"
echo " --run-on-master run stash operator on master"
echo " --enable-validating-webhook enable/disable validating webhooks for Stash CRDs"
echo " --enable-validating-webhook enable/disable validating webhooks for Stash crds"
echo " --enable-mutating-webhook enable/disable mutating webhooks for Kubernetes workloads"
echo " --enable-status-subresource If enabled, uses status sub resource for crds"
echo " --enable-analytics send usage events to Google Analytics (default: true)"
echo " --uninstall uninstall stash"
echo " --purge purges stash crd objects and crds"
Expand Down Expand Up @@ -174,6 +177,13 @@ while test $# -gt 0; do
fi
shift
;;
--enable-status-subresource*)
val=`echo $1 | sed -e 's/^[^=]*=//g'`
if [ "$val" = "false" ]; then
export STASH_ENABLE_STATUS_SUBRESOURCE=false
fi
shift
;;
--enable-analytics*)
val=`echo $1 | sed -e 's/^[^=]*=//g'`
if [ "$val" = "false" ]; then
Expand Down

0 comments on commit ec81f6b

Please sign in to comment.