|
| 1 | +// Copyright The OpenTelemetry Authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package receivers |
| 16 | + |
| 17 | +import ( |
| 18 | + "github.com/go-logr/logr" |
| 19 | + rbacv1 "k8s.io/api/rbac/v1" |
| 20 | +) |
| 21 | + |
| 22 | +type k8seventsConfig struct{} |
| 23 | + |
| 24 | +func generatek8seventsRbacRules(_ logr.Logger, _ k8seventsConfig) ([]rbacv1.PolicyRule, error) { |
| 25 | + // The k8s Events Receiver needs get permissions on the following resources always. |
| 26 | + return []rbacv1.PolicyRule{ |
| 27 | + { |
| 28 | + APIGroups: []string{""}, |
| 29 | + Resources: []string{ |
| 30 | + "events", |
| 31 | + "namespaces", |
| 32 | + "namespaces/status", |
| 33 | + "nodes", |
| 34 | + "nodes/spec", |
| 35 | + "pods", |
| 36 | + "pods/status", |
| 37 | + "replicationcontrollers", |
| 38 | + "replicationcontrollers/status", |
| 39 | + "resourcequotas", |
| 40 | + "services", |
| 41 | + }, |
| 42 | + Verbs: []string{"get", "list", "watch"}, |
| 43 | + }, |
| 44 | + { |
| 45 | + APIGroups: []string{"apps"}, |
| 46 | + Resources: []string{ |
| 47 | + "daemonsets", |
| 48 | + "deployments", |
| 49 | + "replicasets", |
| 50 | + "statefulsets", |
| 51 | + }, |
| 52 | + Verbs: []string{"get", "list", "watch"}, |
| 53 | + }, |
| 54 | + { |
| 55 | + APIGroups: []string{"extensions"}, |
| 56 | + Resources: []string{ |
| 57 | + "daemonsets", |
| 58 | + "deployments", |
| 59 | + "replicasets", |
| 60 | + }, |
| 61 | + Verbs: []string{"get", "list", "watch"}, |
| 62 | + }, |
| 63 | + { |
| 64 | + APIGroups: []string{"batch"}, |
| 65 | + Resources: []string{ |
| 66 | + "jobs", |
| 67 | + "cronjobs", |
| 68 | + }, |
| 69 | + Verbs: []string{"get", "list", "watch"}, |
| 70 | + }, |
| 71 | + { |
| 72 | + APIGroups: []string{"autoscaling"}, |
| 73 | + Resources: []string{ |
| 74 | + "horizontalpodautoscalers", |
| 75 | + }, |
| 76 | + Verbs: []string{"get", "list", "watch"}, |
| 77 | + }, |
| 78 | + }, nil |
| 79 | +} |
0 commit comments