Skip to content

Commit

Permalink
Add stash-metrics chart (#202)
Browse files Browse the repository at this point in the history
* Add stash-metrics chart

Signed-off-by: Tamal Saha <[email protected]>

* Update metricsconfig-backupconfiguration.yaml

Signed-off-by: Tamal Saha <[email protected]>

Co-authored-by: Emruz Hossain <[email protected]>
  • Loading branch information
tamalsaha and Emruz Hossain authored Sep 29, 2021
1 parent 0610818 commit 9ffc6aa
Show file tree
Hide file tree
Showing 17 changed files with 658 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ jobs:
run: |
make ci
- name: Check metrics configuration
run: |
# install metrics-configuration-checker
curl -fsSL -o metrics-configuration-checker https://github.com/kmodules/metrics-configuration-checker/releases/download/v0.0.1/metrics-configuration-checker-linux-amd64
chmod +x metrics-configuration-checker
sudo mv metrics-configuration-checker /usr/local/bin/metrics-configuration-checker
# check stash-metrics chart
metrics-configuration-checker --content=./charts/stash-metrics/templates/
kubernetes:
name: Kubernetes
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion charts/stash-crds/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Get the KubeDB crds by running the following command:
Get the Stash crds by running the following command:

kubectl get crds --selector=app.kubernetes.io/name=stash
23 changes: 23 additions & 0 deletions charts/stash-metrics/.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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
13 changes: 13 additions & 0 deletions charts/stash-metrics/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v2
name: stash-metrics
description: Stash State Metrics
type: application
version: v2021.08.02
appVersion: v2021.08.02
home: https://stash.run
icon: https://cdn.appscode.com/images/products/stash/stash-community-icon.png
sources:
- https://github.com/stashed
maintainers:
- name: appscode
email: [email protected]
43 changes: 43 additions & 0 deletions charts/stash-metrics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Stash Metrics

[Stash Metrics](https://github.com/stashed) - Stash State Metrics

## TL;DR;

```console
$ helm repo add appscode https://charts.appscode.com/stable/
$ helm repo update
$ helm install stash-metrics appscode/stash-metrics -n kube-system
```

## Introduction

This chart deploys Stash metrics configurations on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.16+

## Installing the Chart

To install the chart with the release name `stash-metrics`:

```console
$ helm install stash-metrics appscode/stash-metrics -n kube-system
```

The command deploys Stash metrics configurations on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`
## Uninstalling the Chart

To uninstall/delete the `stash-metrics`:

```console
$ helm delete stash-metrics -n kube-system
```

The command removes all the Kubernetes components associated with the chart and deletes the release.


Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions charts/stash-metrics/doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
project:
name: Stash Metrics
shortName: Stash Metrics
url: https://github.com/stashed
description: Stash State Metrics
app: Stash metrics configurations
repository:
url: https://charts.appscode.com/stable/
name: appscode
chart:
name: stash-metrics
values: -- generate from values file --
valuesExample: -- generate from values file --
prerequisites:
- Kubernetes 1.16+
release:
name: stash-metrics
namespace: kube-system
3 changes: 3 additions & 0 deletions charts/stash-metrics/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Get the Stash crds by running the following command:

kubectl get crds --selector=app.kubernetes.io/name=stash
32 changes: 32 additions & 0 deletions charts/stash-metrics/templates/metrics-user-roles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: appscode:metrics:edit
labels:
rbac.authorization.k8s.io/aggregate-to-admin: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation
rules:
- apiGroups:
- metrics.appscode.com
resources:
- "*"
verbs: ["*"]
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: appscode:metrics:view
labels:
rbac.authorization.k8s.io/aggregate-to-view: "true"
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation
rules:
- apiGroups:
- metrics.appscode.com
resources:
- "*"
verbs: ["get", "list", "watch"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: metrics.appscode.com/v1alpha1
kind: MetricsConfiguration
metadata:
name: stash-appscode-com-backupconfiguration
spec:
targetRef:
apiVersion: stash.appscode.com/v1beta1
kind: BackupConfiguration
metrics:
- name: stash_backupconfiguration_created
help: "Unix creation timestamp of this BackupConfiguration object"
type: gauge
field:
path: .metadata.creationTimestamp
type: DateTime
metricValue:
valueFromPath: .metadata.creationTimestamp
- name: stash_backupconfiguration_info
help: "General information about this BackupConfiguration"
type: gauge
labels:
- key: driver
valuePath: .spec.driver
- key: repository
valuePath: .spec.repository.name
- key: schedule
valuePath: .spec.schedule
- key: target_api_version
valuePath: .spec.target.ref.apiVersion
- key: target_kind
valuePath: .spec.target.ref.kind
- key: target_name
valuePath: .spec.target.ref.name
- key: invoker_kind
value: "BackupConfiguration"
- key: invoker_name
valuePath: .metadata.name
metricValue:
value: 1
- name: stash_backupconfiguration_conditions
help: "Current conditions of this BackupConfiguration"
type: gauge
field:
path: .status.conditions
type: Array
labels:
- key: invoker_kind
value: "BackupConfiguration"
- key: invoker_name
valuePath: .metadata.name
- key: condition
valuePath: .status.conditions[*].type
- key: status
valuePath: .status.conditions[*].status
metricValue:
value: 1
38 changes: 38 additions & 0 deletions charts/stash-metrics/templates/metricsconfig-backupsession.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: metrics.appscode.com/v1alpha1
kind: MetricsConfiguration
metadata:
name: stash-appscode-com-backupsession
spec:
targetRef:
apiVersion: stash.appscode.com/v1beta1
kind: BackupSession
metrics:
- name: stash_backupsession_created
help: "Unix creation timestamp of this BackupSession"
type: gauge
field:
path: .metadata.creationTimestamp
type: DateTime
labels:
- key: invoker_api_group
valuePath: .spec.invoker.apiGroup
- key: invoker_kind
valuePath: .spec.invoker.kind
- key: invoker_name
valuePath: .spec.invoker.name
metricValue:
valueFromPath: .metadata.creationTimestamp
- name: stash_backupsession_info
help: "General information about BackupSession"
type: gauge
labels:
- key: invoker_api_group
valuePath: .spec.invoker.apiGroup
- key: invoker_kind
valuePath: .spec.invoker.kind
- key: invoker_name
valuePath: .spec.invoker.name
- key: phase
valuePath: .status.phase
metricValue:
value: 1
17 changes: 17 additions & 0 deletions charts/stash-metrics/templates/metricsconfig-repository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: metrics.appscode.com/v1alpha1
kind: MetricsConfiguration
metadata:
name: stash-appscode-com-repository
spec:
targetRef:
apiVersion: stash.appscode.com/v1alpha1
kind: Repository
metrics:
- name: stash_repository_created
help: "Unix creation timestamp of this Repository"
type: gauge
field:
path: .metadata.creationTimestamp
type: DateTime
metricValue:
valueFromPath: .metadata.creationTimestamp
44 changes: 44 additions & 0 deletions charts/stash-metrics/templates/metricsconfig-restoresession.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: metrics.appscode.com/v1alpha1
kind: MetricsConfiguration
metadata:
name: stash-appscode-com-restoresession
spec:
targetRef:
apiVersion: stash.appscode.com/v1beta1
kind: RestoreSession
metrics:
- name: stash_restoresession_created
help: "Unix creation timestamp of this RestoreSession object"
type: gauge
field:
path: .metadata.creationTimestamp
type: DateTime
labels:
- key: invoker_kind
value: "RestoreSession"
- key: invoker_name
valuePath: .metadata.name
metricValue:
valueFromPath: .metadata.creationTimestamp
- name: stash_restoresession_info
help: "General information about this RestoreSession"
type: gauge
labels:
- key: driver
valuePath: .spec.driver
- key: repository
valuePath: .spec.repository.name
- key: target_api_version
valuePath: .spec.target.ref.apiVersion
- key: target_kind
valuePath: .spec.target.ref.kind
- key: target_name
valuePath: .spec.target.ref.name
- key: invoker_kind
value: "RestoreSession"
- key: invoker_name
valuePath: .metadata.name
- key: phase
valuePath: .status.phase
metricValue:
value: 1
3 changes: 3 additions & 0 deletions charts/stash-metrics/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Default values for stash-metrics.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
10 changes: 8 additions & 2 deletions charts/stash/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ dependencies:
- name: stash-catalog
repository: file://../stash-catalog
version: v2021.08.02
digest: sha256:2d93f3754c745d0723a5e97b173603f964984587976fdfc3f78b849905949f89
generated: "2021-07-31T08:10:43.951844786Z"
- name: stash-catalog
repository: file://../stash-catalog
version: v2021.08.02
- name: stash-metrics
repository: file://../stash-metrics
version: v2021.08.02
digest: sha256:495a3436959d0385792255a323d83df9b2f7072aa27f888c81db7bfc7ccee713
generated: "2021-09-17T09:50:10.202973769-07:00"
8 changes: 8 additions & 0 deletions charts/stash/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ dependencies:
repository: file://../stash-catalog
version: v2021.08.02
condition: features.enterprise
- name: stash-catalog
repository: file://../stash-catalog
version: v2021.08.02
condition: features.enterprise
- name: stash-metrics
repository: file://../stash-metrics
version: v2021.08.02
condition: features.enterprise
4 changes: 4 additions & 0 deletions hack/scripts/import-crds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ crd-importer --v=v1 \
--out=. --output-yaml=crds/stash-catalog-crds.yaml \
--gk=Function.stash.appscode.com \
--gk=Task.stash.appscode.com

crd-importer \
--input=https://github.com/kmodules/custom-resources/raw/kubernetes-1.21.1/crds/metrics.appscode.com_metricsconfigurations.yaml \
--out=./charts/stash-metrics/crds

0 comments on commit 9ffc6aa

Please sign in to comment.