Restrict Discovery to Specific Namespace(s)
Restrict Discovery to Single and Multiple Namespaces.
This topic describes how you can use user-defined service accounts in different scopes to discover services. You can create the necessary roles in your cluster, and provide the service account name in the UI.
Cluster Scope
In this scope, the service account is created by default and the discovery runs in cluster scope by default.
Single Namespace Scope
When you want to discover resources from a particular namespace, you can create a service account with the role, da-mgmt. This role is bound to the service account.
apiVersion: v1
kind: ServiceAccount
metadata:
name: namespace-discoveryThe role da-mgmt is required during the process of service discovery to manage the discovery process.
To manage the entire process of discovery, it is required to create pods that are transient. Hence, the role da-mgmt is created (that is common to all modes) that is described below.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: da-mgmt
namespace: hce-sa
rules:
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- delete
- get
- list
- apiGroups:
- ""
resources:
- pods/log
verbs:
- get
- list
- watch
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- delete
- get
- list
- patch
- updateTo discover services and metadata associated with it, you need to create a role da-discovery. The YAML below describes creating a role da-discovery in the namespace hce-sa.
The YAML below describes how the da-mgmt RoleBinding is applied to service account namespace-discovery.
The YAML below describes how the da-discovery role is bound to service account namespace-discovery.
Multiple Namespaces
You can add multiple namespaces in the UI by selecting the Inclusion option in the UI. To exclude certain namespaces, select Exclusion and specify namespaces to exclude from the service discovery process.
The da-mgmt role remains constant, to help manage service discovery process.
The YAML below describes how the cluster role da-discovery is configured to discover services and metadata associated with it.
If you want to have multiple namespaces when discovering services, you can create RoleBindings to bind the cluster role with the specific namespace. To enable discovery for two namespaces, say hce and cert-manager, you need two role bindings. The YAML below describes how you can achieve this.
Additional Permissions for Multiple Namespaces
To discover traffic on multiple namespaces, additional permissions are necessary. Without the additional permissions, connectivity can't be discovered in single and multiple namespaces.
The YAML below describes how you can attach additional permissions with the existing service account.
Once you create the necessary roles in your cluster, add the service account name in the UI. Follow the steps below.
Select Project Settings -> Discovery under Project-level resources and click New Discovery Agent.
Provide the Environment, Infrastructure, Discovery Agent Name, and Namespace.
Single Namespace Scope
To use single namespace, select Inclusion and provide the namespace. Disable the Detect network trace connectivity.
Multiple Namespace Scope
To use multiple namespaces, provide multiple namespaces and click Create New Discovery Agent.
Last updated
Was this helpful?