Skip to content

Commit

Permalink
Add recommended labels for trivy
Browse files Browse the repository at this point in the history
  • Loading branch information
JhoLee committed Sep 21, 2021
1 parent 1d5aa9c commit fd00de9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
16 changes: 16 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,22 @@ app.kubernetes.io/component: registry
component: registry
{{- end -}}

{{/*
Labels for harbor-trivy
*/}}
{{- define "harbor.trivy.labels" -}}
app.kubernetes.io/version: {{ .Values.trivy.internal.image.tag }}
{{ include "harbor.trivy.matchLabels" . }}
{{- end -}}

{{/*
Matchlabels for harbor-trivy
*/}}
{{- define "harbor.trivy.matchLabels" -}}
app.kubernetes.io/component: trivy
component: trivy
{{- end -}}

{{- define "harbor.autoGenCert" -}}
{{- if and .Values.expose.tls.enabled (eq .Values.expose.tls.certSource "auto") -}}
{{- printf "true" -}}
Expand Down
1 change: 1 addition & 0 deletions templates/trivy/trivy-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
name: {{ template "harbor.trivy" . }}
labels:
{{ include "harbor.labels" . | indent 4 }}
{{ include "harbor.trivy.labels" . | indent 4 }}
type: Opaque
data:
redisURL: {{ include "harbor.redis.urlForTrivy" . | b64enc }}
Expand Down
7 changes: 4 additions & 3 deletions templates/trivy/trivy-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ metadata:
name: {{ template "harbor.trivy" . }}
labels:
{{ include "harbor.labels" . | indent 4 }}
component: trivy
{{ include "harbor.trivy.labels" . | indent 4 }}
spec:
replicas: {{ .Values.trivy.replicas }}
serviceName: {{ template "harbor.trivy" . }}
selector:
matchLabels:
{{ include "harbor.matchLabels" . | indent 6 }}
component: trivy
{{ include "harbor.trivy.matchLabels" . | indent 6 }}
template:
metadata:
labels:
{{ include "harbor.labels" . | indent 8 }}
component: trivy
{{ include "harbor.trivy.labels" . | indent 8 }}
annotations:
checksum/secret: {{ include (print $.Template.BasePath "/trivy/trivy-secret.yaml") . | sha256sum }}
{{- if and .Values.internalTLS.enabled (eq .Values.internalTLS.certSource "auto") }}
Expand Down Expand Up @@ -180,6 +180,7 @@ spec:
name: data
labels:
{{ include "harbor.labels" . | indent 8 }}
{{ include "harbor.trivy.labels" . | indent 8 }}
spec:
accessModes: [{{ $trivy.accessMode | quote }}]
{{- if $trivy.storageClass }}
Expand Down
3 changes: 2 additions & 1 deletion templates/trivy/trivy-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ metadata:
name: "{{ template "harbor.trivy" . }}"
labels:
{{ include "harbor.labels" . | indent 4 }}
{{ include "harbor.trivy.labels" . | indent 4 }}
spec:
ports:
- name: {{ ternary "https-trivy" "http-trivy" .Values.internalTLS.enabled }}
protocol: TCP
port: {{ template "harbor.trivy.servicePort" . }}
selector:
{{ include "harbor.matchLabels" . | indent 4 }}
component: trivy
{{ include "harbor.trivy.matchLabels" . | indent 4 }}
{{ end }}
1 change: 1 addition & 0 deletions templates/trivy/trivy-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
name: "{{ template "harbor.internalTLS.trivy.secretName" . }}"
labels:
{{ include "harbor.labels" . | indent 4 }}
{{ include "harbor.trivy.labels" . | indent 4 }}
type: kubernetes.io/tls
data:
ca.crt: {{ (required "The \"internalTLS.trustCa\" is required!" .Values.internalTLS.trustCa) | b64enc | quote }}
Expand Down

0 comments on commit fd00de9

Please sign in to comment.