Skip to content

Commit

Permalink
fix: refine templates, code agent
Browse files Browse the repository at this point in the history
  • Loading branch information
soniqua committed Jul 31, 2024
1 parent 8772151 commit ffc3c4a
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 75 deletions.
38 changes: 37 additions & 1 deletion charts/snyk-broker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,42 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{/*
Create a default fully qualified app name for CRA.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "container-registry-agent.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- ( printf "%s-container-registry-agent" .Values.fullnameOverride ) | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default "container-registry-agent" .Values.nameOverride }}
{{- if .Values.disableSuffixes }}
{{- printf "%s" $name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create a default fully qualified app name for CA.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "code-agent.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- ( printf "%s-code-agent" .Values.fullnameOverride ) | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default "code-agent" .Values.nameOverride }}
{{- if .Values.disableSuffixes }}
{{- printf "%s" $name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down Expand Up @@ -191,7 +227,7 @@ Create the name of the service account to use

{{/* CRA */}}
{{- define "container-registry-agent.url" -}}
{{ printf "http://cra-service-%s:%d" (include "snyk-broker.fullname" . ) ( .Values.deployment.container.crSnykPort | int ) }}
{{ printf "http://%s:%d" (include "container-registry-agent.fullname" . ) ( .Values.deployment.container.crSnykPort | int ) }}
{{- end }}

{{/**/}}
Expand Down
2 changes: 1 addition & 1 deletion charts/snyk-broker/templates/broker_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ spec:
{{- if .Values.enableCodeAgent }}
# Code Agent
- name: GIT_CLIENT_URL
value: {{ default (printf "http://code-agent-service:%s" (.Values.deployment.container.caSnykPort | toString)) .Values.gitClientUrl }}
value: {{ default (printf "http://%s:%s" (include "code-agent.fullname" .) (.Values.deployment.container.caSnykPort | toString)) .Values.gitClientUrl }}
{{- end }}
# Logging
- name: LOG_LEVEL
Expand Down
16 changes: 7 additions & 9 deletions charts/snyk-broker/templates/code_agent_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ .Values.scmType}}-code-agent{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }}"
name: {{ include "code-agent.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ .Release.Name }}-ca
app.kubernetes.io/name: {{ include "code-agent.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: 1
{{- end }}
selector:
matchLabels:
app.kubernetes.io/name: {{ .Release.Name }}-ca
app.kubernetes.io/name: {{ include "code-agent.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
Expand All @@ -22,7 +20,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ .Release.Name }}-ca
app.kubernetes.io/name: {{ include "code-agent.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- with .Values.imagePullSecrets }}
Expand Down Expand Up @@ -58,7 +56,7 @@ spec:
- name: SNYK_TOKEN
valueFrom:
secretKeyRef:
name: snyk-token{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }}
name: {{ include "snyk-broker.snykTokenName" . }}
key: snyk-token-key
{{- if .Values.tlsRejectUnauthorized }}
# Troubleshooting - Set to 0 for SSL inspection testing
Expand All @@ -85,7 +83,7 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: "code-agent-service{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }}"
name: {{ include "code-agent.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "snyk-broker.labels" . | nindent 4 }}
Expand All @@ -95,7 +93,7 @@ spec:
- port: {{ .Values.deployment.container.caSnykPort }}
targetPort: {{ .Values.deployment.container.caSnykPort}}
selector:
app.kubernetes.io/name: {{ .Release.Name }}-ca
app.kubernetes.io/name: {{ include "code-agent.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

{{- end }}
14 changes: 8 additions & 6 deletions charts/snyk-broker/templates/cra_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: cr-{{ include "snyk-broker.deploymentName" . }}
name: {{ include "container-registry-agent.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: cr-{{ include "snyk-broker.deploymentName" . }}
app.kubernetes.io/name: {{ include "container-registry-agent.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: cr-{{ include "snyk-broker.deploymentName" . }}
app.kubernetes.io/name: {{ include "container-registry-agent.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
Expand All @@ -20,7 +20,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app.kubernetes.io/name: cr-{{ include "snyk-broker.deploymentName" . }}
app.kubernetes.io/name: {{ include "container-registry-agent.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- if .Values.extraPodSpecsCr }}
Expand Down Expand Up @@ -50,6 +50,8 @@ spec:
- name: http
containerPort: {{ .Values.deployment.container.crSnykPort }}
env:
- name: DEBUG
value: "*"
- name: SNYK_PORT
value: {{ .Values.deployment.container.crSnykPort | squote }}
{{- if .Values.tlsRejectUnauthorized }}
Expand Down Expand Up @@ -85,7 +87,7 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: cra-service-{{ include "snyk-broker.fullname" . }}
name: {{ include "container-registry-agent.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "snyk-broker.labels" . | nindent 4 }}
Expand All @@ -95,6 +97,6 @@ spec:
- port: {{ .Values.deployment.container.crSnykPort }}
targetPort: {{ .Values.deployment.container.crSnykPort}}
selector:
app.kubernetes.io/name: cr-{{ include "snyk-broker.deploymentName" . }}
app.kubernetes.io/name: {{ include "container-registry-agent.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ with CRA:
key: container-registry-agent-broker-token-key
name: container-registry-agent-broker-token-RELEASE-NAME-snyk-broker
- name: CR_AGENT_URL
value: http://cra-service-RELEASE-NAME-snyk-broker:8081
value: http://RELEASE-NAME-container-registry-agent:8081
- name: CR_TYPE
value: ecr
- name: CR_ROLE_ARN
Expand All @@ -50,7 +50,7 @@ with CRA:
- name: BROKER_CLIENT_URL
value: http://container-registry-agent-RELEASE-NAME-snyk-broker:8000
- name: BROKER_CLIENT_VALIDATION_URL
value: http://cra-service-RELEASE-NAME-snyk-broker:8081/healthcheck
value: http://RELEASE-NAME-container-registry-agent:8081/healthcheck
- name: LOG_LEVEL
value: info
- name: LOG_ENABLE_BODY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ renders extraPodSpecs CRA:
key: container-registry-agent-broker-token-key
name: container-registry-agent-broker-token-RELEASE-NAME-snyk-broker
- name: CR_AGENT_URL
value: http://cra-service-RELEASE-NAME-snyk-broker:8081
value: http://RELEASE-NAME-container-registry-agent:8081
- name: CR_TYPE
value: ecr
- name: CR_ROLE_ARN
Expand All @@ -28,7 +28,7 @@ renders extraPodSpecs CRA:
- name: BROKER_CLIENT_URL
value: http://container-registry-agent-RELEASE-NAME-snyk-broker:8000
- name: BROKER_CLIENT_VALIDATION_URL
value: http://cra-service-RELEASE-NAME-snyk-broker:8081/healthcheck
value: http://RELEASE-NAME-container-registry-agent:8081/healthcheck
- name: LOG_LEVEL
value: info
- name: LOG_ENABLE_BODY
Expand Down Expand Up @@ -88,6 +88,8 @@ renders extraPodSpecs CRA:
2: |
containers:
- env:
- name: DEBUG
value: '*'
- name: SNYK_PORT
value: "8081"
image: snyk/container-registry-agent:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ with CRA:
key: container-registry-agent-broker-token-key
name: container-registry-agent-broker-token-RELEASE-NAME-snyk-broker
- name: CR_AGENT_URL
value: http://cra-service-RELEASE-NAME-snyk-broker:8081
value: http://RELEASE-NAME-container-registry-agent:8081
- name: CR_TYPE
value: ecr
- name: CR_ROLE_ARN
Expand All @@ -50,7 +50,7 @@ with CRA:
- name: BROKER_CLIENT_URL
value: http://container-registry-agent-RELEASE-NAME-snyk-broker:8000
- name: BROKER_CLIENT_VALIDATION_URL
value: http://cra-service-RELEASE-NAME-snyk-broker:8081/healthcheck
value: http://RELEASE-NAME-container-registry-agent:8081/healthcheck
- name: LOG_LEVEL
value: info
- name: LOG_ENABLE_BODY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ default values:
key: container-registry-agent-broker-token-key
name: container-registry-agent-broker-token-RELEASE-NAME-snyk-broker
- name: CR_AGENT_URL
value: http://cra-service-RELEASE-NAME-snyk-broker:8081
value: http://RELEASE-NAME-container-registry-agent:8081
- name: CR_TYPE
value: digitalocean-cr
- name: CR_BASE
Expand All @@ -51,7 +51,7 @@ default values:
- name: BROKER_CLIENT_URL
value: http://container-registry-agent-RELEASE-NAME-snyk-broker:8000
- name: BROKER_CLIENT_VALIDATION_URL
value: http://cra-service-RELEASE-NAME-snyk-broker:8081/healthcheck
value: http://RELEASE-NAME-container-registry-agent:8081/healthcheck
- name: LOG_LEVEL
value: info
- name: LOG_ENABLE_BODY
Expand Down Expand Up @@ -107,23 +107,25 @@ default values:
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker
name: cr-container-registry-agent-RELEASE-NAME-snyk-broker
app.kubernetes.io/name: RELEASE-NAME-container-registry-agent
name: RELEASE-NAME-container-registry-agent
namespace: NAMESPACE
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker
app.kubernetes.io/name: RELEASE-NAME-container-registry-agent
template:
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker
app.kubernetes.io/name: RELEASE-NAME-container-registry-agent
spec:
containers:
- env:
- name: DEBUG
value: '*'
- name: SNYK_PORT
value: "8081"
image: snyk/container-registry-agent:latest
Expand Down Expand Up @@ -158,13 +160,13 @@ default values:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME-snyk-broker
helm.sh/chart: snyk-broker-0.0.0
name: cra-service-RELEASE-NAME-snyk-broker
name: RELEASE-NAME-container-registry-agent
namespace: NAMESPACE
spec:
ports:
- port: 8081
targetPort: 8081
selector:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker
app.kubernetes.io/name: RELEASE-NAME-container-registry-agent
type: ClusterIP
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ default values:
key: container-registry-agent-broker-token-key
name: container-registry-agent-broker-token-snyk-broker
- name: CR_AGENT_URL
value: http://cra-service-snyk-broker:8081
value: http://container-registry-agent:8081
- name: CR_TYPE
value: ecr
- name: CR_ROLE_ARN
Expand All @@ -50,7 +50,7 @@ default values:
- name: BROKER_CLIENT_URL
value: http://container-registry-agent-snyk-broker:8000
- name: BROKER_CLIENT_VALIDATION_URL
value: http://cra-service-snyk-broker:8081/healthcheck
value: http://container-registry-agent:8081/healthcheck
- name: LOG_LEVEL
value: info
- name: LOG_ENABLE_BODY
Expand Down Expand Up @@ -106,23 +106,25 @@ default values:
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: cr-container-registry-agent-snyk-broker
name: cr-container-registry-agent-snyk-broker
app.kubernetes.io/name: container-registry-agent
name: container-registry-agent
namespace: NAMESPACE
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: cr-container-registry-agent-snyk-broker
app.kubernetes.io/name: container-registry-agent
template:
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: cr-container-registry-agent-snyk-broker
app.kubernetes.io/name: container-registry-agent
spec:
containers:
- env:
- name: DEBUG
value: '*'
- name: SNYK_PORT
value: "8081"
image: snyk/container-registry-agent:latest
Expand Down Expand Up @@ -157,13 +159,13 @@ default values:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker
helm.sh/chart: snyk-broker-0.0.0
name: cra-service-snyk-broker
name: container-registry-agent
namespace: NAMESPACE
spec:
ports:
- port: 8081
targetPort: 8081
selector:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: cr-container-registry-agent-snyk-broker
app.kubernetes.io/name: container-registry-agent
type: ClusterIP
Loading

0 comments on commit ffc3c4a

Please sign in to comment.