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

fix: adds labels to broker deployment [HYB-560] #120

Merged
merged 10 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 6 additions & 5 deletions charts/snyk-broker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ Create chart name and version as used by the chart label.
Common labels
*/}}
{{- define "snyk-broker.labels" -}}
helm.sh/chart: {{ include "snyk-broker.chart" . }}
{{ include "snyk-broker.selectorLabels" . }}
{{- $commonLabels := dict "helm.sh/chart" (include "snyk-broker.chart" .) }}
{{- $commonLabels = merge $commonLabels (include "snyk-broker.selectorLabels" . | fromYaml) }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- $commonLabels = merge $commonLabels (dict "app.kubernetes.io/version" (quote .Chart.AppVersion)) }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- $commonLabels = merge $commonLabels (dict "app.kubernetes.io/managed-by" .Release.Service) }}
{{- with .Values.labels }}
{{ toYaml . }}
{{- $commonLabels = merge $commonLabels . }}
saumilmac marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}
{{- toYaml $commonLabels | nindent 2 }}
{{- end }}

{{/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ should render artifactoryUrl and brokerClientValidationUrl as secrets:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: artifactory-broker-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand Down Expand Up @@ -109,8 +107,6 @@ should render artifactoryUrl and brokerClientValidationUrl as secrets:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: artifactory-broker-service-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand Down Expand Up @@ -154,7 +150,5 @@ should render artifactoryUrl and brokerClientValidationUrl as secrets:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: snyk-broker-RELEASE-NAME
namespace: NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ cacert:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: github-com-broker-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand Down Expand Up @@ -118,8 +116,6 @@ cacert:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: github-com-broker-service-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand Down Expand Up @@ -162,8 +158,6 @@ cacert:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: RELEASE-NAME-snyk-broker-cacert-configmap-RELEASE-NAME
namespace: NAMESPACE
4: |
Expand All @@ -183,8 +177,6 @@ cacert:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: snyk-broker-RELEASE-NAME
namespace: NAMESPACE
cacertfile:
Expand All @@ -197,8 +189,6 @@ cacertfile:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: github-com-broker-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand Down Expand Up @@ -307,8 +297,6 @@ cacertfile:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: github-com-broker-service-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand All @@ -330,8 +318,6 @@ cacertfile:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: RELEASE-NAME-snyk-broker-cacert-configmap-RELEASE-NAME
namespace: NAMESPACE
4: |
Expand All @@ -351,7 +337,5 @@ cacertfile:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: snyk-broker-RELEASE-NAME
namespace: NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ should render render nexusUrl, baseNexusUrl and brokerClientValidationUrl as sec
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: nexus-broker-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand Down Expand Up @@ -112,8 +110,6 @@ should render render nexusUrl, baseNexusUrl and brokerClientValidationUrl as sec
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: nexus-broker-service-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand Down Expand Up @@ -165,7 +161,5 @@ should render render nexusUrl, baseNexusUrl and brokerClientValidationUrl as sec
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: snyk-broker-RELEASE-NAME
namespace: NAMESPACE
152 changes: 140 additions & 12 deletions charts/snyk-broker/tests/__snapshot__/broker_deployment_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,7 @@ add deployment labels:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
test: node1
name: github-com-broker-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand Down Expand Up @@ -542,8 +541,7 @@ add deployment labels:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
test: node1
name: github-com-broker-service-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand Down Expand Up @@ -571,8 +569,7 @@ add deployment labels:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
test: node1
name: snyk-broker-RELEASE-NAME
namespace: NAMESPACE
default values:
Expand All @@ -585,8 +582,6 @@ default values:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: github-com-broker-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand Down Expand Up @@ -685,8 +680,6 @@ default values:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: github-com-broker-service-RELEASE-NAME
namespace: NAMESPACE
spec:
Expand Down Expand Up @@ -714,8 +707,143 @@ default values:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
node1: test1
node2: test2
name: snyk-broker-RELEASE-NAME
namespace: NAMESPACE
handles duplicative labels:
1: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
name: github-com-broker-RELEASE-NAME
namespace: NAMESPACE
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
template:
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
spec:
containers:
- env:
- name: BROKER_SERVER_URL
value: https://broker.test.snyk.io
- name: BROKER_HEALTHCHECK_PATH
value: /healthcheck
- name: BROKER_SYSTEMCHECK_PATH
value: /systemcheck
- name: BROKER_TOKEN
valueFrom:
secretKeyRef:
key: github-com-broker-token-key
name: github-com-broker-token-RELEASE-NAME
- name: GITHUB_TOKEN
valueFrom:
secretKeyRef:
key: github-com-token-key
name: github-com-token-RELEASE-NAME
- name: PORT
value: "8000"
- name: BROKER_CLIENT_URL
value: http://brokerclient
- name: LOG_LEVEL
value: info
- name: LOG_ENABLE_BODY
value: "false"
- name: ACCEPT_CODE
value: "true"
- name: ACCEPT_IAC
value: tf,yaml,yml,json,tpl
- name: BROKER_DISPATCHER_BASE_URL
value: https://api.test.snyk.io
image: snyk/broker:github-com
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthcheck
port: 8000
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 10
timeoutSeconds: 1
name: github-com-broker-RELEASE-NAME
ports:
- containerPort: 8000
name: http
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthcheck
port: 8000
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 10
timeoutSeconds: 1
resources:
limits:
cpu: 1
memory: 256Mi
requests:
cpu: 1
memory: 256Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
volumeMounts: null
securityContext: {}
serviceAccountName: snyk-broker-RELEASE-NAME
volumes: null
2: |
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
name: github-com-broker-service-RELEASE-NAME
namespace: NAMESPACE
spec:
ports:
- port: 8000
targetPort: 8000
selector:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
type: ClusterIP
3: |
apiVersion: v1
data:
github-com-broker-token-key: MTIz
kind: Secret
metadata:
name: github-com-broker-token-RELEASE-NAME
type: Opaque
4: |
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
name: snyk-broker-RELEASE-NAME
namespace: NAMESPACE
preflight checks off:
Expand Down
11 changes: 11 additions & 0 deletions charts/snyk-broker/tests/broker_deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,16 @@ tests:
- it: add deployment labels
values:
- ./fixtures/default_values.yaml
set:
labels:
test: node1
asserts:
- matchSnapshot: {}
saumilmac marked this conversation as resolved.
Show resolved Hide resolved
- it: handles duplicative labels
values:
- ./fixtures/default_values.yaml
set:
labels:
app.kubernetes.io/name: "my duplicated label"
asserts:
- matchSnapshot: {}
6 changes: 1 addition & 5 deletions charts/snyk-broker/tests/fixtures/default_values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,4 @@ preflightChecks:

highAvailabilityMode:
enabled: false
brokerDispatcherUrl: "https://api.test.snyk.io"

labels:
node1: test1
node2: test2
brokerDispatcherUrl: "https://api.test.snyk.io"
saumilmac marked this conversation as resolved.
Show resolved Hide resolved
Loading