Skip to content

Commit

Permalink
feat: add exporter rbac (#246)
Browse files Browse the repository at this point in the history
* feat: add exporter rbac

* fix: owner

* feat: support exporter filter

* fix: comments

* fix: remove code

* fix: remove
  • Loading branch information
kqzh authored Aug 22, 2023
1 parent 3eed8d8 commit 0137212
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
10 changes: 10 additions & 0 deletions apis/apps/v1alpha1/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package v1alpha1
type NebulaExporterComponent interface {
ComponentSpec() ComponentAccessor
MaxRequests() int32
CollectRegex() string
IgnoreRegex() string
}

var _ NebulaExporterComponent = &exporterComponent{}
Expand All @@ -41,3 +43,11 @@ func (e *exporterComponent) ComponentSpec() ComponentAccessor {
func (e *exporterComponent) MaxRequests() int32 {
return e.nc.Spec.Exporter.MaxRequests
}

func (e *exporterComponent) CollectRegex() string {
return e.nc.Spec.Exporter.CollectRegex
}

func (e *exporterComponent) IgnoreRegex() string {
return e.nc.Spec.Exporter.IgnoreRegex
}
8 changes: 8 additions & 0 deletions apis/apps/v1alpha1/nebulacluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ type ExporterSpec struct {
// +kubebuilder:default=40
// +optional
MaxRequests int32 `json:"maxRequests,omitempty"`

// CollectRegex means the regex to filter metrics
// +optional
CollectRegex string `json:"collectRegex,omitempty"`

// IgnoreRegex means the regex to ignore metrics
// +optional
IgnoreRegex string `json:"ignoreRegex,omitempty"`
}

// AgentContainerSpec defines the desired state of Agent
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,8 @@ spec:
additionalProperties:
type: string
type: object
collectRegex:
type: string
env:
items:
properties:
Expand Down Expand Up @@ -903,6 +905,8 @@ spec:
- name
type: object
type: array
ignoreRegex:
type: string
image:
type: string
initContainers:
Expand Down
25 changes: 15 additions & 10 deletions pkg/controller/component/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ func (e *nebulaExporter) generateDeployment(nc *v1alpha1.NebulaCluster) *appsv1.
Name: "ng-exporter",
Image: nc.ExporterComponent().ComponentSpec().PodImage(),
Args: []string{
"--listen-address=0.0.0.0:9100", fmt.Sprintf("--namespace=%s", namespace),
fmt.Sprintf("--cluster=%s", ncName), fmt.Sprintf("--max-request=%d", nc.ExporterComponent().MaxRequests()),
"--listen-address=0.0.0.0:9100",
fmt.Sprintf("--namespace=%s", namespace),
fmt.Sprintf("--cluster=%s", ncName),
fmt.Sprintf("--max-request=%d", nc.ExporterComponent().MaxRequests()),
fmt.Sprintf("--collect=%s", nc.ExporterComponent().CollectRegex()),
fmt.Sprintf("--ignore=%s", nc.ExporterComponent().IgnoreRegex()),
},
Env: nc.ExporterComponent().ComponentSpec().PodEnvVars(),
Ports: []corev1.ContainerPort{
Expand Down Expand Up @@ -165,14 +169,15 @@ func (e *nebulaExporter) generateDeployment(nc *v1alpha1.NebulaCluster) *appsv1.
Annotations: nc.ExporterComponent().ComponentSpec().PodAnnotations(),
},
Spec: corev1.PodSpec{
SchedulerName: nc.Spec.SchedulerName,
NodeSelector: nc.ExporterComponent().ComponentSpec().NodeSelector(),
InitContainers: nc.ExporterComponent().ComponentSpec().InitContainers(),
Containers: containers,
ImagePullSecrets: nc.Spec.ImagePullSecrets,
Affinity: nc.ExporterComponent().ComponentSpec().Affinity(),
Tolerations: nc.ExporterComponent().ComponentSpec().Tolerations(),
Volumes: nc.ExporterComponent().ComponentSpec().SidecarVolumes(),
SchedulerName: nc.Spec.SchedulerName,
NodeSelector: nc.ExporterComponent().ComponentSpec().NodeSelector(),
InitContainers: nc.ExporterComponent().ComponentSpec().InitContainers(),
Containers: containers,
ImagePullSecrets: nc.Spec.ImagePullSecrets,
Affinity: nc.ExporterComponent().ComponentSpec().Affinity(),
Tolerations: nc.ExporterComponent().ComponentSpec().Tolerations(),
Volumes: nc.ExporterComponent().ComponentSpec().SidecarVolumes(),
ServiceAccountName: v1alpha1.NebulaServiceAccountName,
},
},
},
Expand Down

0 comments on commit 0137212

Please sign in to comment.