Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Prod 2299/coreos pod monitor for deployment operator chart #230

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/deployment-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
If release name contains chart name it will be used as a full name.
*/}}
{{- define "agentk.fullname" -}}
{{- include "deployment-operator.fullname"}}-agentk
{{- include "deployment-operator.fullname" . }}-agentk
{{- end }}

{{/*
Expand Down
11 changes: 11 additions & 0 deletions charts/deployment-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.monitoring.enabled }}
{{- with .Values.monitoring.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
labels:
{{- include "deployment-operator.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
Expand Down Expand Up @@ -53,50 +58,56 @@
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- if .Values.monitoring.enabled }}
- name: observability
containerPort: {{ .Values.monitoring.metricsPort }}
- name: metrics
containerPort: 8080
{{- end }}
livenessProbe:
httpGet:
path: /healthz
port: http
readinessProbe:
httpGet:
path: /healthz
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{ if .Values.additionalVolumeMounts }}
volumeMounts:
- name: temp
mountPath: /tmp
{{ toYaml .Values.additionalVolumeMounts | nindent 12 }}
{{ end }}
- name: {{ .Chart.Name }}-agentk
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ .Values.agentk.image.repository }}:{{ .Values.agentk.image.tag }}
imagePullPolicy: {{ .Values.agentk.image.pullPolicy }}
terminationMessagePolicy: {{ .Values.agentk.terminationMessagePolicy }}
{{ $kasAddress := replace "gql" "kas" (default "" .Values.consoleUrl) | replace "https" "wss" }}
args:
- --token-file=/etc/agentk/secrets/token
- --kas-address={{ $kasAddress }}
- --observability-listen-address=:8081
{{- if .Values.agentk.config.caCert }}
- --ca-cert-file=/etc/agentk/config/ca.crt
{{- end }}
{{- if .Values.agentk.config.kasHeaders }}
{{- range .Values.agentk.config.kasHeaders }}
- --kas-header
- {{ . | quote }}
{{- end }}
{{- end }}
{{- range .Values.agentk.extraArgs }}
- {{ . }}
{{- end }}
livenessProbe:
httpGet:
path: /liveness
port: 8081
initialDelaySeconds: 15

Check warning

Code scanning / Trivy

Can elevate its own privileges Medium

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV001
Severity: MEDIUM
Message: Container 'deployment-operator-agentk' of Deployment 'deployment-operator' should set 'securityContext.allowPrivilegeEscalation' to false
Link: KSV001

Check notice

Code scanning / Trivy

Default capabilities: some containers do not drop all Low

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV003
Severity: LOW
Message: Container 'deployment-operator-agentk' of Deployment 'deployment-operator' should add 'ALL' to 'securityContext.capabilities.drop'
Link: KSV003

Check notice

Code scanning / Trivy

CPU not limited Low

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV011
Severity: LOW
Message: Container 'deployment-operator-agentk' of Deployment 'deployment-operator' should set 'resources.limits.cpu'
Link: KSV011

Check warning

Code scanning / Trivy

Runs as root user Medium

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV012
Severity: MEDIUM
Message: Container 'deployment-operator-agentk' of Deployment 'deployment-operator' should set 'securityContext.runAsNonRoot' to true
Link: KSV012

Check failure

Code scanning / Trivy

Root file system is not read-only High

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV014
Severity: HIGH
Message: Container 'deployment-operator-agentk' of Deployment 'deployment-operator' should set 'securityContext.readOnlyRootFilesystem' to true
Link: KSV014

Check notice

Code scanning / Trivy

CPU requests not specified Low

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV015
Severity: LOW
Message: Container 'deployment-operator-agentk' of Deployment 'deployment-operator' should set 'resources.requests.cpu'
Link: KSV015

Check notice

Code scanning / Trivy

Memory requests not specified Low

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV016
Severity: LOW
Message: Container 'deployment-operator-agentk' of Deployment 'deployment-operator' should set 'resources.requests.memory'
Link: KSV016

Check notice

Code scanning / Trivy

Memory not limited Low

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV018
Severity: LOW
Message: Container 'deployment-operator-agentk' of Deployment 'deployment-operator' should set 'resources.limits.memory'
Link: KSV018

Check notice

Code scanning / Trivy

Runs with UID <= 10000 Low

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV020
Severity: LOW
Message: Container 'deployment-operator-agentk' of Deployment 'deployment-operator' should set 'securityContext.runAsUser' > 10000
Link: KSV020

Check notice

Code scanning / Trivy

Runs with GID <= 10000 Low

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV021
Severity: LOW
Message: Container 'deployment-operator-agentk' of Deployment 'deployment-operator' should set 'securityContext.runAsGroup' > 10000
Link: KSV021

Check notice

Code scanning / Trivy

Runtime/Default Seccomp profile not set Low

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV030
Severity: LOW
Message: Either Pod or Container should set 'securityContext.seccompProfile.type' to 'RuntimeDefault'
Link: KSV030

Check notice

Code scanning / Trivy

Container capabilities must only include NET_BIND_SERVICE Low

Artifact: charts/deployment-operator/templates/deployment.yaml
Type: helm
Vulnerability KSV106
Severity: LOW
Message: container should drop all
Link: KSV106
periodSeconds: 20
readinessProbe:
httpGet:
Expand Down
22 changes: 22 additions & 0 deletions charts/deployment-operator/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{ if .Values.monitoring.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "deployment-operator.fullname" . }}-podmonitor
labels:
{{ include "deployment-operator.labels" . | indent 4 }}
spec:
podMetricsEndpoints:
- port: metrics
path: '/metrics'
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "deployment-operator.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
podTargetLabels:
- app.kubernetes.io/name
- app.kubernetes.io/instance
{{ end }}
8 changes: 4 additions & 4 deletions charts/deployment-operator/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if (.Values.agentk.serviceMonitor).enabled }}
{{- if .Values.monitoring.enabled }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -8,7 +8,7 @@ metadata:
spec:
type: ClusterIP
ports:
- port: 8080
- port: {{ .Values.monitoring.metricsPort }}
protocol: TCP
name: observability
selector:
Expand All @@ -29,6 +29,6 @@ spec:
- {{ .Release.Namespace | quote }}
endpoints:
- port: observability
interval: 30s
scrapeTimeout: 25s
interval: 10s
scrapeTimeout: 9s
{{- end }}
15 changes: 9 additions & 6 deletions charts/deployment-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ rbac:

podLabels: {}
podAnnotations: {}
# prometheus.io/scrape: "true"
# prometheus.io/path: "/metrics"
# prometheus.io/port: "8080"

podSecurityContext: {}
# fsGroup: 2000
Expand All @@ -57,6 +54,15 @@ securityContext: {}
# runAsNonRoot: true
# runAsUser: 1000

monitoring:
enabled: false
prometheus: "k8s"
metricsPort: 8000
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "8000"

service:
type: ClusterIP
port: 9001
Expand Down Expand Up @@ -135,6 +141,3 @@ agentk:
# requests:
# cpu: 100m
# memory: 128Mi
serviceMonitor:
# Specifies whether to create a ServiceMonitor resource for collecting Prometheus metrics
enabled: false
Loading