Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Amper committed Sep 20, 2023
1 parent ffa27b0 commit 4ef7f72
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 39 deletions.
121 changes: 113 additions & 8 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ consisting of `vmstorage`, `vmselect` and `vminsert`):

More details about resources of VictoriaMetrics operator you can find on the [resources page](https://docs.victoriametrics.com/operator/resources/).

### VictoriaMetrics cluster (select, insert, storage)
### VMCluster (vmselect, vminsert, vmstorage)

Let's start by deploying the [`vmcluster`](https://docs.victoriametrics.com/operator/resources/vmcluster.html) resource.

Expand Down Expand Up @@ -211,7 +211,7 @@ After that you can deploy `vmcluster` resource to the kubernetes cluster:
```shell
kubectl apply -f vmcluster.yaml -n vm
# vmcluster.operator.victoriametrics.com/demo configured
# vmcluster.operator.victoriametrics.com/demo created
```

Check that `vmcluster` is running:
Expand Down Expand Up @@ -248,7 +248,7 @@ the [vmcluster page](https://docs.victoriametrics.com/operator/resources/vmclust

### Scraping

#### vmagent
#### VMAgent

Now let's deploy [`vmagent`](https://docs.victoriametrics.com/operator/resources/vmagent.html) resource.

Expand Down Expand Up @@ -276,7 +276,7 @@ After that you can deploy `vmagent` resource to the kubernetes cluster:
```shell
kubectl apply -f vmagent.yaml -n vm
# vmagent.operator.victoriametrics.com/demo configured
# vmagent.operator.victoriametrics.com/demo created
```

Check that `vmagent` is running:
Expand All @@ -291,7 +291,7 @@ kubectl get pods -n vm -l "app.kubernetes.io/instance=demo" -l "app.kubernetes.i
More information about `vmagent` resource you can find on
the [vmagent page](https://docs.victoriametrics.com/operator/resources/vmagent.html).

### vmservicescrapes
#### VMServiceScrape

Now we have the timeseries database (vmcluster) and the tool to collect metrics (vmagent) and send it to the database.

Expand Down Expand Up @@ -329,12 +329,15 @@ After that you can deploy `vmservicescrape` resource to the kubernetes cluster:
```shell
kubectl apply -f vmservicescrape.yaml -n vm
# vmservicescrape.operator.victoriametrics.com/vmoperator-demo configured
# vmservicescrape.operator.victoriametrics.com/vmoperator-demo created
```

### Access

We need to look at the results of what we got. Up until now, we've just been looking only at the status of the pods.

#### VMAuth

Let's expose our components with [`vmauth`](https://docs.victoriametrics.com/operator/resources/vmauth.html).

Create file `vmauth.yaml`
Expand Down Expand Up @@ -362,6 +365,8 @@ spec:
Your cluster will have them differently.
Also, for simplicity, we don't use tls, but in real environments not having tls is unsafe.

#### VMUser

To get authorized access to our data it is necessary to create a user using
the [vmuser](https://docs.victoriametrics.com/operator/resources/vmuser.html) resource.

Expand Down Expand Up @@ -396,8 +401,8 @@ After that you can deploy `vmauth` and `vmuser` resources to the kubernetes clus
kubectl apply -f vmauth.yaml -n vm
kubectl apply -f vmuser.yaml -n vm
# vmauth.operator.victoriametrics.com/demo configured
# vmuser.operator.victoriametrics.com/demo configured
# vmauth.operator.victoriametrics.com/demo created
# vmuser.operator.victoriametrics.com/demo created
```

Operator automatically creates a secret with username/password token for `VMUser` resource with `generatePassword=true`:
Expand Down Expand Up @@ -427,8 +432,108 @@ and your given password (`Yt3N2r3cPl` in our case):
### Alerting

The remaining components will be needed for alerting.

#### VMAlertmanager

Let's start with [`vmalertmanager`](https://docs.victoriametrics.com/operator/resources/vmalertmanager.html).

Create file `vmuser.yaml`

```shell
code vmuser.yaml
```

with the following content:

```yaml
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAlertmanager
metadata:
name: demo
spec:
configRawYaml: |
global:
resolve_timeout: 5m
route:
group_wait: 30s
group_interval: 5m
repeat_interval: 12h
receiver: 'webhook'
receivers:
- name: 'webhook'
webhook_configs:
- url: 'http://your-webhook-url'
```

where webhook-url is the address of the webhook to receive notifications
(configuration of AlertManager notifications will remain out of scope).
You can find more details about `alertmanager` configuration in
the [Alertmanager documentation](https://prometheus.io/docs/alerting/latest/configuration/).

After that you can deploy `vmalertmanager` resource to the kubernetes cluster:

```shell
kubectl apply -f vmalertmanager.yaml -n vm
# vmalertmanager.operator.victoriametrics.com/demo created
```

Check that `vmalertmanager` is running:

```shell
kubectl get pods -n vm -l "app.kubernetes.io/instance=demo" -l "app.kubernetes.io/name=vmalertmanager"
# NAME READY STATUS RESTARTS AGE
# vmalertmanager-demo-0 2/2 Running 0 107s
```

#### VMAlert

And now you can create [`vmalert`](https://docs.victoriametrics.com/operator/resources/vmalert.html) resource.

Create file `vmalert.yaml`

```shell
code vmalert.yaml
```

with the following content:

```yaml
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAlert
metadata:
name: demo
spec:
datasource:
url: "http://vmselect-demo.vm.svc:8429"
notifier:
url: "http://vmalertmanager-demo.vm.svc:9093"
evaluationInterval: "30s"
selectAllByDefault: true
```

After that you can deploy `vmalert` resource to the kubernetes cluster:

```shell
kubectl apply -f vmalert.yaml -n vm
# vmalert.operator.victoriametrics.com/demo created
```

Check that `vmalert` is running:

```shell
kubectl get pods -n vm -l "app.kubernetes.io/instance=demo" -l "app.kubernetes.io/name=vmalert"
# NAME READY STATUS RESTARTS AGE
# vmalert-demo-bf75c67cb-hh4qd 2/2 Running 0 5s
```

#### VMRule

Now you can create [`vmrule`](https://docs.victoriametrics.com/operator/resources/vmrule.html) resource
for [vmalert](https://docs.victoriametrics.com/operator/resources/vmalert.html).

## Anything else

Expand Down
25 changes: 16 additions & 9 deletions docs/resources/vmagent.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,22 @@ In addition to the above selectors, the filtering of objects in a cluster is aff

Following rules are applied:

| `*NamespaceSelector` | `*Selector` | `selectAllByDefault` | `WATCH_NAMESPACE` | Selected objects |
|----------------------|-------------|----------------------|-------------------|------------------------------------------------------------------------------------------------------------------|
| undefined | undefined | false | undefined | nothing |
| undefined | undefined | **true** | undefined | all objects of given type (`*`) in the cluster |
| **defined** | undefined | any | undefined | all objects of given type (`*`) are matching at namespaces for given `NamespaceSelector` |
| undefined | **defined** | any | undefined | all objects of given type (`*`) only at `VMAgent`'s namespace are matching for given `Selector` |
| **defined** | **defined** | any | undefined | all objects of given type (`*`) only at namespaces matched `NamespaceSelector` for given `Selector` are matching |
| any | undefined | any | **defined** | all objects of given type (`*`) only at `VMAgent`'s namespace | |
| any | **defined** | any | **defined** | all objects of given type (`*`) only at `VMAgent`'s namespace for given `Selector` are matching |
- If `*NamespaceSelector` and `*Selector` both undefined, then by default select nothing. With option set - `spec.selectAllByDefault: true`, select all objects of given type.
- If `*NamespaceSelector` defined, `*Selector` undefined, then all objects are matching at namespaces for given `*NamespaceSelector`.
- If `*NamespaceSelector` undefined, `*Selector` defined, then all objects at `VMAgent`'s namespaces are matching for given `*Selector`.
- If `*NamespaceSelector` and `*Selector` both defined, then only objects at namespaces matched `*NamespaceSelector` for given `*Selector` are matching.

Here's a more visual and more detailed view:

| `*NamespaceSelector` | `*Selector` | `selectAllByDefault` | `WATCH_NAMESPACE` | Selected objects |
|----------------------|-------------|----------------------|-------------------|-------------------------------------------------------------------------------------------------------|
| undefined | undefined | false | undefined | nothing |
| undefined | undefined | **true** | undefined | all objects of given type (`*`) in the cluster |
| **defined** | undefined | any | undefined | all objects of given type (`*`) at namespaces for given `*NamespaceSelector` |
| undefined | **defined** | any | undefined | all objects of given type (`*`) only at `VMAgent`'s namespace are matching for given `Selector |
| **defined** | **defined** | any | undefined | all objects of given type (`*`) only at namespaces matched `*NamespaceSelector` for given `*Selector` |
| any | undefined | any | **defined** | all objects of given type (`*`) only at `VMAgent`'s namespace |
| any | **defined** | any | **defined** | all objects of given type (`*`) only at `VMAgent`'s namespace for given `*Selector` |

More details about `WATCH_NAMESPACE` variable you can read in [this doc](https://docs.victoriametrics.com/operator/configuration.html#namespaced-mode).

Expand Down
29 changes: 18 additions & 11 deletions docs/resources/vmalert.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,29 @@ In addition to the above selectors, the filtering of objects in a cluster is aff

Following rules are applied:

| `ruleNamespaceSelector` | `ruleSelector` | `selectAllByDefault` | `WATCH_NAMESPACE` | Selected rules |
|-------------------------|----------------|----------------------|-------------------|----------------------------------------------------------------------------------------------------|
| undefined | undefined | false | undefined | nothing |
| undefined | undefined | **true** | undefined | all rules in the cluster |
| **defined** | undefined | any | undefined | all rules are matching at namespaces for given `ruleNamespaceSelector` |
| undefined | **defined** | any | undefined | all rules only at `VMAlert`'s namespace are matching for given `ruleSelector` |
| **defined** | **defined** | any | undefined | all rules only at namespaces matched `ruleNamespaceSelector` for given `ruleSelector` are matching |
| any | undefined | any | **defined** | all rules only at `VMAlert`'s namespace |
| any | **defined** | any | **defined** | all rules only at `VMAlert`'s namespace for given `ruleSelector` are matching |
- If `ruleNamespaceSelector` and `ruleSelector` both undefined, then by default select nothing. With option set - `spec.selectAllByDefault: true`, select all vmrules.
- If `ruleNamespaceSelector` defined, `ruleSelector` undefined, then all vmrules are matching at namespaces for given `ruleNamespaceSelector`.
- If `ruleNamespaceSelector` undefined, `ruleSelector` defined, then all vmrules at `VMAgent`'s namespaces are matching for given `ruleSelector`.
- If `ruleNamespaceSelector` and `ruleSelector` both defined, then only vmrules at namespaces matched `ruleNamespaceSelector` for given `ruleSelector` are matching.

Here's a more visual and more detailed view:

| `ruleNamespaceSelector` | `ruleSelector` | `selectAllByDefault` | `WATCH_NAMESPACE` | Selected rules |
|-------------------------|----------------|----------------------|-------------------|------------------------------------------------------------------------------------------------------|
| undefined | undefined | false | undefined | nothing |
| undefined | undefined | **true** | undefined | all vmrules in the cluster |
| **defined** | undefined | any | undefined | all vmrules are matching at namespaces for given `ruleNamespaceSelector` |
| undefined | **defined** | any | undefined | all vmrules only at `VMAlert`'s namespace are matching for given `ruleSelector` |
| **defined** | **defined** | any | undefined | all vmrules only at namespaces matched `ruleNamespaceSelector` for given `ruleSelector` are matching |
| any | undefined | any | **defined** | all vmrules only at `VMAlert`'s namespace |
| any | **defined** | any | **defined** | all vmrules only at `VMAlert`'s namespace for given `ruleSelector` are matching |

More details about `WATCH_NAMESPACE` variable you can read in [this doc](https://docs.victoriametrics.com/operator/configuration.html#namespaced-mode).

Here are some examples of `VMAlert` configuration with selectors:

```yaml
# select all scrape objects in the cluster
# select all rule objects in the cluster
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAlert
metadata:
Expand All @@ -64,7 +71,7 @@ spec:
---
# select all scrape objects in specific namespace (my-namespace)
# select all rule objects in specific namespace (my-namespace)
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAlert
metadata:
Expand Down
Loading

0 comments on commit 4ef7f72

Please sign in to comment.