-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set bind permissions on the executable in dockerfile (#6817)
* set bind capacity in docker file * add test for nonroot * newline
- Loading branch information
1 parent
9646f5c
commit 7393c83
Showing
7 changed files
with
285 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
global: | ||
podSecurityContext: | ||
fsGroup: 473 | ||
agent: | ||
securityContext: | ||
runAsUser: 473 | ||
runAsGroup: 473 |
42 changes: 42 additions & 0 deletions
42
operations/helm/tests/nonroot/grafana-agent/templates/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
# Source: grafana-agent/templates/configmap.yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm | ||
data: | ||
config.river: |- | ||
logging { | ||
level = "info" | ||
format = "logfmt" | ||
} | ||
discovery.kubernetes "pods" { | ||
role = "pod" | ||
} | ||
discovery.kubernetes "nodes" { | ||
role = "node" | ||
} | ||
discovery.kubernetes "services" { | ||
role = "service" | ||
} | ||
discovery.kubernetes "endpoints" { | ||
role = "endpoints" | ||
} | ||
discovery.kubernetes "endpointslices" { | ||
role = "endpointslice" | ||
} | ||
discovery.kubernetes "ingresses" { | ||
role = "ingress" | ||
} |
81 changes: 81 additions & 0 deletions
81
operations/helm/tests/nonroot/grafana-agent/templates/controllers/daemonset.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
# Source: grafana-agent/templates/controllers/daemonset.yaml | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm | ||
spec: | ||
minReadySeconds: 10 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
template: | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/default-container: grafana-agent | ||
labels: | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
spec: | ||
securityContext: | ||
fsGroup: 473 | ||
serviceAccountName: grafana-agent | ||
containers: | ||
- name: grafana-agent | ||
image: docker.io/grafana/agent:v0.40.3 | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- run | ||
- /etc/agent/config.river | ||
- --storage.path=/tmp/agent | ||
- --server.http.listen-addr=0.0.0.0:80 | ||
- --server.http.ui-path-prefix=/ | ||
env: | ||
- name: AGENT_MODE | ||
value: flow | ||
- name: AGENT_DEPLOY_MODE | ||
value: "helm" | ||
- name: HOSTNAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
ports: | ||
- containerPort: 80 | ||
name: http-metrics | ||
readinessProbe: | ||
httpGet: | ||
path: /-/ready | ||
port: 80 | ||
scheme: HTTP | ||
initialDelaySeconds: 10 | ||
timeoutSeconds: 1 | ||
securityContext: | ||
runAsGroup: 473 | ||
runAsUser: 473 | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/agent | ||
- name: config-reloader | ||
image: ghcr.io/jimmidyson/configmap-reload:v0.12.0 | ||
args: | ||
- --volume-dir=/etc/agent | ||
- --webhook-url=http://localhost:80/-/reload | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/agent | ||
resources: | ||
requests: | ||
cpu: 1m | ||
memory: 5Mi | ||
dnsPolicy: ClusterFirst | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: grafana-agent |
117 changes: 117 additions & 0 deletions
117
operations/helm/tests/nonroot/grafana-agent/templates/rbac.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
--- | ||
# Source: grafana-agent/templates/rbac.yaml | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm | ||
rules: | ||
# Rules which allow discovery.kubernetes to function. | ||
- apiGroups: | ||
- "" | ||
- "discovery.k8s.io" | ||
- "networking.k8s.io" | ||
resources: | ||
- endpoints | ||
- endpointslices | ||
- ingresses | ||
- nodes | ||
- nodes/proxy | ||
- nodes/metrics | ||
- pods | ||
- services | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
# Rules which allow loki.source.kubernetes and loki.source.podlogs to work. | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
- pods/log | ||
- namespaces | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "monitoring.grafana.com" | ||
resources: | ||
- podlogs | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
# Rules which allow mimir.rules.kubernetes to work. | ||
- apiGroups: ["monitoring.coreos.com"] | ||
resources: | ||
- prometheusrules | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- nonResourceURLs: | ||
- /metrics | ||
verbs: | ||
- get | ||
# Rules for prometheus.kubernetes.* | ||
- apiGroups: ["monitoring.coreos.com"] | ||
resources: | ||
- podmonitors | ||
- servicemonitors | ||
- probes | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
# Rules which allow eventhandler to work. | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
# needed for remote.kubernetes.* | ||
- apiGroups: [""] | ||
resources: | ||
- "configmaps" | ||
- "secrets" | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
# needed for otelcol.processor.k8sattributes | ||
- apiGroups: ["apps"] | ||
resources: ["replicasets"] | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: ["extensions"] | ||
resources: ["replicasets"] | ||
verbs: ["get", "list", "watch"] | ||
--- | ||
# Source: grafana-agent/templates/rbac.yaml | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: grafana-agent | ||
subjects: | ||
- kind: ServiceAccount | ||
name: grafana-agent | ||
namespace: default |
23 changes: 23 additions & 0 deletions
23
operations/helm/tests/nonroot/grafana-agent/templates/service.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
# Source: grafana-agent/templates/service.yaml | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: grafana-agent | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
internalTrafficPolicy: Cluster | ||
ports: | ||
- name: http-metrics | ||
port: 80 | ||
targetPort: 80 | ||
protocol: "TCP" |
13 changes: 13 additions & 0 deletions
13
operations/helm/tests/nonroot/grafana-agent/templates/serviceaccount.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
# Source: grafana-agent/templates/serviceaccount.yaml | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: grafana-agent | ||
namespace: default | ||
labels: | ||
helm.sh/chart: grafana-agent | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
app.kubernetes.io/version: "vX.Y.Z" | ||
app.kubernetes.io/managed-by: Helm |
7393c83
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this broke out grafana-agent deployment.
It now need to run with the NET_BIND_SERVICE capability bounding set.
i.e.