Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cluster role document #1796

Merged
merged 21 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/docs/troubleshooting/provisioning_flow_chart.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="app.diagrams.net" modified="2022-10-18T00:18:01.657Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36" etag="TN0chO2VRAjQmLvDBTCH" version="20.4.1" type="device"><diagram id="C5RBs43oDa-KdzZeNtuy" name="main_chart">7V1bk9q4Ev41U+eJKd+w4XEumWTPJqmczW3ztGWwAG+MTWwzM+TXH8lYGCQDQmNbgulJVWZsjGzo/vrerSv7bv78NvUXsw9JgKIrywier+z7K8syHcvFv8iZ1frMwHXWJ6ZpGJQXVSc+h79RedIozy7DAGU7F+ZJEuXhYvfkOIljNM53zvlpmjztXjZJot27Lvwp4k58HvsRf/Z7GOQz+nRGdf4dCqez8s4efWHkj39O02QZl7e7suzJgPxbvzz36VLl9dnMD5KnrVP2myv7Lk2SfP3X/PkOReSrpd/a9z9W36P3P923//1f9sv/evvnl4/feuvFHk55y+YDpijOpZf+Nfr4Ie19+I6yn0+rYH7/9unjU/kW49GPloh+C8VnzVf06y2+IUQWMa7s21k+j/CfJv7zX5Tnq5Id/GWe4FNJms+SaRL70fskWZTXTZI4Ly8zyTGKgxtCdnw8ipLxz/WphzCiC+Oj8vo+PsryNPm5oaxFzlBCkAeK/BGKbjekvEuiJMUvxUmMyFIBZpXys1QP96Y6e4uew/xvstZ1vzz6QR8D/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oWtduWqfIQrpH8uUTyhzuksn0PPXIk0uOTYof3uvZRNI3MeucZE8rR2jEXnk0CBJF4SJDx3nAzxbFJtr3k/CZ8A2fQCWUCsd+dFO+MA+DIKplhDJYvT+MzbtMbTEN3YeOQpuPatMAdjdBbcqKbTHMmzgAdnmBMrB2+cXq1wwtaYtjDg2b2OKXP7LKLibKPYlqGtOwB5oXA8jIO8kNoABDhP59pUNrahmgpimRTp9bk94oaX3ICHgteUyWft1uE1FLP0tK4ENctP246GlMuB2rPCSpj3dz6zu106HD5Ta3lp3a2R+yQBTc3qGVyfC19II+UU3zku3j8pCiPZO2L8dmLFXpKmNuJZNtIGsRqvgwTQiQqsuxZTL7kASIXPF/</diagram></mxfile>
3 changes: 1 addition & 2 deletions assets/docs/troubleshooting/provisioning_flow_chart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion assets/docs/troubleshooting/troubleshooting.drawio

This file was deleted.

4 changes: 4 additions & 0 deletions docs/overview/component/discoverer.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ For example, Vald LB Gateway creates the new `discoverer client` with config par
When the `initContainer` successes, Vald LB Gateway can get the metrics asynchronously according to its set parameters.

<!-- TODO:image -->

### Cluster role configurations

Please refer [here](../../user-guides/cluster-role-binding.md) for more information about the cluster role configuration.
149 changes: 149 additions & 0 deletions docs/user-guides/cluster-role-binding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Cluster Role Configuration

The cluster role contains rules that represent a set of permission to grant access to a specific target depending on the binding rule.

This page describes why we need a cluster role for the Vald cluster and how to configure it.

## What are cluster role and cluster role binding for the Vald cluster?

Vald applies the distributed index system across the Kubernetes cluster depending on the resource usage of the Kubernetes Node, it requires configuration to grant permission to a specific role to retrieve cluster information on Kubernetes.

By default, the cluster role configurations are deployed automatically when using Helm.

The following manifest will be deployed by default.

- [clusterrole.yaml](https://github.com/vdaas/vald/blob/main/k8s/discoverer/clusterrole.yaml)
- [clusterrolebinding.yaml](https://github.com/vdaas/vald/blob/main/k8s/discoverer/clusterrolebinding.yaml)

These configurations allow the service account `discoverer`, which is for the Vald Discoverer components, to access different resources in the Kubernetes cluster.

This service account allows [Vald Discoverer](../overview/component/discoverer.md) to retrieve Node and Pod resource usage from [kube-apiserver](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/), and share it to other components in the Vald cluster.

For example, [Vald LB Gateway](../overview/component/lb-gateway.md) will control which Vald Agent to insert based on the Node and Pod resource usage retrieved by Vald Discoverer.

If you are interested, please refer to the [insert data flow](../overview/data-flow.md#insert) for more detail.

## Configuration for Vald Discoverer

As described in the above section, Vald Discoverer requires configuration on cluster role and cluster role binding to retrieve Node and Pod information from the Kubernetes Cluster.

In this section, we will describe how to configure it and how to customize these configurations.

### Cluster role configuration for Vald Discoverer

By looking at the [cluster role configuration](https://github.com/vdaas/vald/blob/main/k8s/discoverer/clusterrole.yaml), the access right of the following resources are granted to the cluster role `discoverer`.

```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: discoverer
...
kevindiu marked this conversation as resolved.
Show resolved Hide resolved
rules:
- apiGroups:
- apps
resources:
- replicasets
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- nodes
- nodes/proxy
- services
- endpoints
- pods
verbs:
- get
- list
- watch
- nonResourceURLs:
- /metrics
verbs:
- get
- apiGroups:
- "metrics.k8s.io"
resources:
- nodes
- pods
verbs:
- get
- list
```

All of these rules are required to retrieve Node and Pod resource usage from [kube-apiserver](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/) and also used to discover new Vald Agent Pods or Nodes created on the cluster.

### Cluster role binding configuration for Vald Discoverer

The cluster role binding configuration binds the cluster role `discoverer` described in the previous section to the service account `vald` according to the [configuration file](https://github.com/vdaas/vald/blob/main/k8s/discoverer/clusterrolebinding.yaml).

```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: discoverer
...
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: discoverer
subjects:
- kind: ServiceAccount
name: vald
namespace: default
```

When the role binds to the service account, the access right of the role will be granted to the service account.
In this case, all the access rights of the role `discoverer` will be granted to the service account `vald`.

The service account `vald` is required for [Vald Discoverer](https://github.com/vdaas/vald/blob/main/k8s/discoverer/deployment.yaml#L155) to retrieve the required information to operate the Vald cluster.

For more information about Vald Discoverer, please refer [here](../overview/component/discoverer.md).

## Customize cluster role and cluster role binding configuration on Helm chart for Vald Discoverer

To customize the cluster role configuration on the Helm chart for Vald Discoverer, you may need to change the `discoverer.clusterRole` configuration on the Helm chart file. The cluster role configurations are enabled by default.

```yaml
discoverer:
...
clusterRole:
# discoverer.clusterRole.enabled -- creates clusterRole resource
enabled: true
# discoverer.clusterRole.name -- name of clusterRole
name: discoverer
clusterRoleBinding:
# discoverer.clusterRoleBinding.enabled -- creates clusterRoleBinding resource
enabled: true
# discoverer.clusterRoleBinding.name -- name of clusterRoleBinding
name: discoverer
serviceAccount:
# discoverer.serviceAccount.enabled -- creates service account
enabled: true
# discoverer.serviceAccount.name -- name of service account
name: vald
...

<div class="warning">
If you disable these configurations, the Vald Discoverer will not work, and the Vald cluster will not be functional.
</div>
kevindiu marked this conversation as resolved.
Show resolved Hide resolved

If you want to modify or disable these configurations, you need to grant the [cluster role configuration](https://github.com/vdaas/vald/blob/main/k8s/discoverer/clusterrole.yaml) and bind it to the Vald Discoverer to retrieve required information to operate the Vald cluster.

## Customize cluster role configuration on Cloud Providers

Please refer to the official guidelines to configure cluster role configuration for your cloud provider, and configure the service account name for Vald Discoverer.

kevindiu marked this conversation as resolved.
Show resolved Hide resolved
For example:
- [Amazon EKS](https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html)
- [GKE](https://cloud.google.com/kubernetes-engine/docs/how-to/role-based-access-control)

For other cloud providers, you may need to find the related document on their official website, or you can enable the cluster role and the cluster role binding configurations on the Helm chart.

## Related Documents

- [Vald Discoverer](../overview/component/discoverer.md)
- [Data Flow](../overview/data-flow.md)