Skip to content

Commit

Permalink
add roles
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Oct 19, 2023
1 parent 5e09b01 commit da60b62
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 4 deletions.
5 changes: 3 additions & 2 deletions charts/operator-wandb/charts/otel/templates/_config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{{- $config = mustMergeOverwrite (include "otel.logsCollectionReceiver" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.kubeletMetricsReceiver" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.kubernetesEventReceiver" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.kubernetesClusterReceiver" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.extensions" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.processors" . | fromYaml) $config }}
{{- $config = mustMergeOverwrite (include "otel.service" . | fromYaml) $config }}
Expand Down Expand Up @@ -33,7 +34,7 @@ processors:
spike_limit_percentage: 25
k8sattributes:
filter:
node_from_env_var: NODE_NAME
node_from_env_var: K8S_NODE_NAME
passthrough: false
pod_association:
- sources:
Expand Down Expand Up @@ -67,7 +68,7 @@ service:
metrics:
exporters: [debug]
processors: [memory_limiter, batch, k8sattributes]
receivers: [hostmetrics]
receivers: [hostmetrics, k8s_cluster, kubeletstats]
logs:
exporters: [debug]
processors: [memory_limiter, batch]
Expand Down
9 changes: 8 additions & 1 deletion charts/operator-wandb/charts/otel/templates/_receivers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ receivers:
kubeletstats:
collection_interval: 20s
auth_type: "serviceAccount"
endpoint: "${env:NODE_NAME}:10250"
endpoint: "https://${env:K8S_NODE_NAME}:10250"
insecure_skip_verify: true
{{- end }}

{{- define "otel.kubernetesEventReceiver" -}}
Expand All @@ -152,4 +153,10 @@ receivers:
group: "events.k8s.io"
exclude_watch_type:
- "DELETED"
{{- end }}

{{- define "otel.kubernetesClusterReceiver" -}}
receivers:
k8s_cluster:
collection_interval: 10s
{{- end }}
54 changes: 54 additions & 0 deletions charts/operator-wandb/charts/otel/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "otel.fullname" . }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "wandb.commonLabels" . | nindent 4 }}
{{- include "otel.commonLabels" . | nindent 4 }}
{{- include "otel.labels" . | nindent 4 }}
{{- if .Values.clusterRole.labels -}}
{{- toYaml .Values.clusterRole.labels | nindent 4 }}
{{- end }}
annotations:
{{- if .Values.clusterRole.annotations -}}
{{- toYaml .Values.clusterRole.annotations | nindent 4 }}
{{- end }}
rules:
# kubernetesAttributes
- apiGroups: [""]
resources: ["pods", "namespaces"]
verbs: ["get", "watch", "list"]
- apiGroups: ["apps"]
resources: ["replicasets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources: ["replicasets"]
verbs: ["get", "list", "watch"]

# clusterMetrics
- apiGroups: [""]
resources: ["events", "namespaces", "namespaces/status", "nodes", "nodes/spec", "pods", "pods/status", "replicationcontrollers", "replicationcontrollers/status", "resourcequotas", "services" ]
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources: ["daemonsets", "deployments", "replicasets", "statefulsets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources: ["daemonsets", "deployments", "replicasets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
resources: ["jobs", "cronjobs"]
verbs: ["get", "list", "watch"]
- apiGroups: ["autoscaling"]
resources: ["horizontalpodautoscalers"]
verbs: ["get", "list", "watch"]

# kubeletMetrics
- apiGroups: [""]
resources: ["nodes/stats"]
verbs: ["get", "watch", "list"]

# kubernetesEvents
- apiGroups: ["events.k8s.io"]
resources: ["events"]
verbs: ["watch", "list"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "otel.fullname" . }}
labels:
{{- include "wandb.commonLabels" . | nindent 4 }}
{{- include "otel.commonLabels" . | nindent 4 }}
{{- include "otel.labels" . | nindent 4 }}
{{- if .Values.clusterRole.labels -}}
{{- toYaml .Values.clusterRole.labels | nindent 4 }}
{{- end }}
annotations:
{{- if .Values.clusterRole.annotations -}}
{{- toYaml .Values.clusterRole.annotations | nindent 4 }}
{{- end }}
roleRef:
kind: ClusterRole
apiGroup: rbac.authorization.k8s.io
name: {{ include "otel.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "otel.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
2 changes: 1 addition & 1 deletion charts/operator-wandb/charts/otel/templates/deamonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ spec:
protocol: TCP
hostPort: 9411
env:
- name: NODE_NAME
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
Expand Down

0 comments on commit da60b62

Please sign in to comment.