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

add custom ca for navi-castle, navi-restrictions, navi-async-matrix #511

Merged
merged 1 commit into from
Oct 1, 2024
Merged
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
7 changes: 7 additions & 0 deletions charts/navi-async-matrix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ See the [documentation](https://docs.2gis.com/en/on-premise/navigation/distance-
| `keys.url` | API keys service URL, ex: http://keys-api.svc/service/v1/keys. **Required** | `""` |
| `keys.token` | API token to authorize at the service. **Required** | `""` |

### customCAs **Custom Certificate Authority**

| Name | Description | Value |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------- | ----- |
| `customCAs.bundle` | Custom CA [text representation of the X.509 PEM public-key certificate](https://www.rfc-editor.org/rfc/rfc7468#section-5.1) | `""` |
| `customCAs.certsPath` | Custom CA bundle mount directory in the container. If empty, the default value: "/usr/local/share/ca-certificates" | `""` |


## Maintainers

Expand Down
9 changes: 9 additions & 0 deletions charts/navi-async-matrix/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,12 @@ Name for psql secret and volume
{{- define "navi-async-matrix.fullname-psql" -}}
{{- printf "%s-psql" (include "navi-async-matrix.fullname" .) -}}
{{- end }}

{{/*
Set custom CAs mount path
Usage:
{{ include "custom.ca.mountPath" $ }}
*/}}
{{- define "custom.ca.mountPath" -}}
{{ .Values.customCAs.certsPath | default "/usr/local/share/ca-certificates" }}
{{- end -}}
10 changes: 10 additions & 0 deletions charts/navi-async-matrix/templates/configmap-ca.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

{{- if .Values.customCAs.bundle }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "navi-async-matrix.fullname" . }}-ca
data:
custom-ca.crt: |-
{{- .Values.customCAs.bundle | nindent 4 }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/navi-async-matrix/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ spec:
{{- end }}
checksum/config: {{ (include (print $.Template.BasePath "/configmap.yaml") . | fromYaml).data | toYaml | sha256sum }}
checksum/secret: {{ (include (print $.Template.BasePath "/secret.yaml") . | fromYaml).data | toYaml | sha256sum }}
{{- if .Values.customCAs.bundle }}
checksum/custom-ca: {{ (include (print $.Template.BasePath "/configmap-ca.yaml") . | fromYaml).data | toYaml | sha256sum }}
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -93,6 +96,11 @@ spec:
- name: {{ include "navi-async-matrix.fullname-psql" . | quote }}
emptyDir: {}
{{- end }}
{{- if .Values.customCAs.bundle }}
- name: {{ include "navi-async-matrix.fullname" . }}-ca
configMap:
name: {{ include "navi-async-matrix.fullname" . }}-ca
{{- end }}
initContainers:
{{- if .Values.db.tls.enabled }}
- name: copy-certs
Expand Down Expand Up @@ -155,6 +163,11 @@ spec:
- name: {{ printf "%s-psql" (include "navi-async-matrix.fullname" .) | quote }}
mountPath: /etc/2gis/secret/psql
{{- end }}
{{- if .Values.customCAs.bundle }}
- name: {{ include "navi-async-matrix.fullname" . }}-ca
mountPath: {{ include "custom.ca.mountPath" . }}/custom-ca.crt
subPath: custom-ca.crt
{{- end }}
env:
- name: DM_ASYNC_SERVICE_HOST
value: {{ .Values.dm.host | quote }}
Expand Down Expand Up @@ -263,3 +276,7 @@ spec:
secretKeyRef:
name: {{ include "navi-async-matrix.fullname" . | quote }}
key: dmApiKey
{{- if .Values.customCAs.bundle }}
- name: SSL_CERT_FILE
value: {{ include "custom.ca.mountPath" . }}/custom-ca.crt
{{- end }}
14 changes: 14 additions & 0 deletions charts/navi-async-matrix/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,17 @@ bss:
keys:
url: ''
token: ''


# @section customCAs **Custom Certificate Authority**

# @param customCAs.bundle Custom CA [text representation of the X.509 PEM public-key certificate](https://www.rfc-editor.org/rfc/rfc7468#section-5.1)
# @param customCAs.certsPath Custom CA bundle mount directory in the container. If empty, the default value: "/usr/local/share/ca-certificates"

customCAs:
bundle: ''
# bundle: |
# -----BEGIN CERTIFICATE-----
# ...
# -----END CERTIFICATE-----
certsPath: ''
7 changes: 7 additions & 0 deletions charts/navi-castle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ See the [documentation](https://docs.2gis.com/en/on-premise/navigation) to learn
| `persistentVolume.storageClass` | Volume [storage class](https://kubernetes.io/docs/concepts/storage/storage-classes/). | `ceph-csi-rbd` |
| `persistentVolume.size` | Volume size. | `5Gi` |

### customCAs **Custom Certificate Authority**

| Name | Description | Value |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------- | ----- |
| `customCAs.bundle` | Custom CA [text representation of the X.509 PEM public-key certificate](https://www.rfc-editor.org/rfc/rfc7468#section-5.1) | `""` |
| `customCAs.certsPath` | Custom CA bundle mount directory in the container. If empty, the default value: "/usr/local/share/ca-certificates" | `""` |


## Maintainers

Expand Down
10 changes: 10 additions & 0 deletions charts/navi-castle/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,13 @@ Determine --service parameter for a specific cron job flavor
{{- define "castle.serviceParameter" -}}
{{- eq "restrictionImport" .flavor | ternary "import-restrictions" .flavor -}}
{{- end -}}


{{/*
Set custom CAs mount path
Usage:
{{ include "custom.ca.mountPath" $ }}
*/}}
{{- define "custom.ca.mountPath" -}}
{{ .Values.customCAs.certsPath | default "/usr/local/share/ca-certificates" }}
{{- end -}}
9 changes: 9 additions & 0 deletions charts/navi-castle/templates/configmap-ca.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- if .Values.customCAs.bundle }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "castle.fullname" . }}-ca
data:
custom-ca.crt: |-
{{- .Values.customCAs.bundle | nindent 4 }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/navi-castle/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ spec:
- name: {{ include "castle.fullname" $ }}-builder-config
configMap:
name: {{ include "castle.fullname" $ }}-builder-config
{{- if .Values.customCAs.bundle }}
- name: {{ include "castle.fullname" $ }}-ca
configMap:
name: {{ include "castle.fullname" $ }}-ca
{{- end }}
containers:
- name: castle-cron
image: {{ required "A valid .Values.dgctlDockerRegistry entry required" $.Values.dgctlDockerRegistry }}/{{ $.Values.castle.image.repository }}:{{ $.Values.castle.image.tag | default $.Chart.AppVersion }}
Expand All @@ -48,13 +53,23 @@ spec:
- /opt/config_builder.conf
- --service={{ include "castle.serviceParameter" ( dict "flavor" $flavor ) }}
- --jobs={{ $.Values.castle.jobs | default 1 | int }}
{{- if .Values.customCAs.bundle }}
env:
- name: SSL_CERT_FILE
value: {{ include "custom.ca.mountPath" . }}/custom-ca.crt
{{- end }}
volumeMounts:
- name: {{ include "castle.fullname" $ }}-builder-config
mountPath: /opt/config_builder.conf
subPath: config_builder.conf
- name: {{ include "castle.fullname" $ }}-builder-config
mountPath: {{ $.Values.castle.castleDataPath }}/cities_template
subPath: cities_template
{{- if .Values.customCAs.bundle }}
- name: {{ include "castle.fullname" $ }}-ca
mountPath: {{ include "custom.ca.mountPath" . }}/custom-ca.crt
subPath: custom-ca.crt
{{- end }}
- name: {{ include "castle.fullname" $ }}-pvc
mountPath: {{ $.Values.castle.castleDataPath }}
resources:
Expand Down
18 changes: 18 additions & 0 deletions charts/navi-castle/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ spec:
checksum/configbuilder: {{ include (print $.Template.BasePath "/configmapbuilder.yaml") . | sha256sum }}
checksum/configbuilder-runnable: {{ include (print $.Template.BasePath "/configmapbuilder-runnable.yaml") . | sha256sum }}
checksum/confignginx: {{ include (print $.Template.BasePath "/configmapnginx.yaml") . | sha256sum }}
{{- if .Values.customCAs.bundle }}
checksum/custom-ca: {{ (include (print $.Template.BasePath "/configmap-ca.yaml") . | fromYaml).data | toYaml | sha256sum }}
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand All @@ -49,6 +52,11 @@ spec:
- name: {{ include "castle.fullname" . }}-castle-nginx-config
configMap:
name: {{ include "castle.fullname" . }}-castle-nginx-config
{{- if .Values.customCAs.bundle }}
- name: {{ include "castle.fullname" $ }}-ca
configMap:
name: {{ include "castle.fullname" $ }}-ca
{{- end }}
{{- if (not .Values.persistentVolume.enabled) }}
- name: {{ include "castle.fullname" . }}-data
emptyDir: {}
Expand Down Expand Up @@ -97,6 +105,11 @@ spec:
command: ["/tini","--"]
args:
- /opt/update_services_init.sh
env:
{{- if .Values.customCAs.bundle }}
- name: SSL_CERT_FILE
value: {{ include "custom.ca.mountPath" . }}/custom-ca.crt
{{- end }}
resources:
{{- toYaml $.Values.resources | nindent 12 }}
startupProbe:
Expand Down Expand Up @@ -130,6 +143,11 @@ spec:
- name: {{ include "castle.fullname" $ }}-builder-config
mountPath: /opt/update_services
subPath: update_services
{{- if .Values.customCAs.bundle }}
- name: {{ include "castle.fullname" $ }}-ca
mountPath: {{ include "custom.ca.mountPath" . }}/custom-ca.crt
subPath: custom-ca.crt
{{- end }}
{{- if .Values.persistentVolume.enabled }}
- name: {{ include "castle.fullname" . }}-pvc
mountPath: {{ .Values.castle.castleDataPath }}
Expand Down
13 changes: 13 additions & 0 deletions charts/navi-castle/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,16 @@ persistentVolume:
- ReadWriteOnce
storageClass: ceph-csi-rbd
size: 5Gi

# @section customCAs **Custom Certificate Authority**

# @param customCAs.bundle Custom CA [text representation of the X.509 PEM public-key certificate](https://www.rfc-editor.org/rfc/rfc7468#section-5.1)
# @param customCAs.certsPath Custom CA bundle mount directory in the container. If empty, the default value: "/usr/local/share/ca-certificates"

customCAs:
bundle: ''
# bundle: |
# -----BEGIN CERTIFICATE-----
# ...
# -----END CERTIFICATE-----
certsPath: ''
7 changes: 7 additions & 0 deletions charts/navi-restrictions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ See the [documentation](https://docs.2gis.com/en/on-premise/restrictions) to lea
| `cron.resources.limits.cpu` | A CPU limit | `1000m` |
| `cron.resources.limits.memory` | A memory limit | `1024Mi` |

### customCAs **Custom Certificate Authority**

| Name | Description | Value |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------- | ----- |
| `customCAs.bundle` | Custom CA [text representation of the X.509 PEM public-key certificate](https://www.rfc-editor.org/rfc/rfc7468#section-5.1) | `""` |
| `customCAs.certsPath` | Custom CA bundle mount directory in the container. If empty, the default value: "/usr/local/share/ca-certificates" | `""` |


## Maintainers

Expand Down
9 changes: 9 additions & 0 deletions charts/navi-restrictions/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,12 @@ Check for deprecated values
{{- if .Values.db -}}{{ fail "[after 1.20.2] .Values.db renamed to .Values.postgres" }}{{- end }}
{{- end }} {{/* 1.20.2 */}}
{{- end }}

{{/*
Set custom CAs mount path
Usage:
{{ include "custom.ca.mountPath" $ }}
*/}}
{{- define "custom.ca.mountPath" -}}
{{ .Values.customCAs.certsPath | default "/usr/local/share/ca-certificates" }}
{{- end -}}
9 changes: 9 additions & 0 deletions charts/navi-restrictions/templates/configmap-ca.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- if .Values.customCAs.bundle }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "navi-restrictions.fullname" . }}-ca
data:
custom-ca.crt: |-
{{- .Values.customCAs.bundle | nindent 4 }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/navi-restrictions/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
spec:
{{- if .Values.customCAs.bundle }}
volumes:
- name: {{ include "navi-restrictions.fullname" $ }}-ca
configMap:
name: {{ include "navi-restrictions.fullname" $ }}-ca
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 12 }}
Expand Down Expand Up @@ -83,4 +89,14 @@ spec:
secretKeyRef:
name: {{ include "navi-restrictions.fullname" . }}
key: keysApi
{{- if .Values.customCAs.bundle }}
- name: SSL_CERT_FILE
value: {{ include "custom.ca.mountPath" . }}/custom-ca.crt
{{- end }}
{{- if .Values.customCAs.bundle }}
volumeMounts:
- name: {{ include "navi-restrictions.fullname" $ }}-ca
mountPath: {{ include "custom.ca.mountPath" . }}/custom-ca.crt
subPath: custom-ca.crt
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/navi-restrictions/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ spec:
{{- if .Values.prometheusEnabled }}
prometheus.io/scrape: "true"
{{- end }}
{{- if .Values.customCAs.bundle }}
checksum/custom-ca: {{ (include (print $.Template.BasePath "/configmap-ca.yaml") . | fromYaml).data | toYaml | sha256sum }}
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand All @@ -41,6 +44,12 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if .Values.customCAs.bundle }}
volumes:
- name: {{ include "navi-restrictions.fullname" . }}-ca
configMap:
name: {{ include "navi-restrictions.fullname" . }}-ca
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
Expand Down Expand Up @@ -90,6 +99,12 @@ spec:
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.customCAs.bundle }}
volumeMounts:
- name: {{ include "navi-restrictions.fullname" . }}-ca
mountPath: {{ include "custom.ca.mountPath" . }}/custom-ca.crt
subPath: custom-ca.crt
{{- end }}
env:
- name: DEBUG
value: "{{ .Values.api.debug | ternary "True" "False" }}"
Expand All @@ -115,3 +130,7 @@ spec:
secretKeyRef:
name: {{ include "navi-restrictions.fullname" . }}
key: keysApi
{{- if .Values.customCAs.bundle }}
- name: SSL_CERT_FILE
value: {{ include "custom.ca.mountPath" . }}/custom-ca.crt
{{- end }}
14 changes: 14 additions & 0 deletions charts/navi-restrictions/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,17 @@ cron:
# @param cron.resources.requests.memory A memory request
# @param cron.resources.limits.cpu A CPU limit
# @param cron.resources.limits.memory A memory limit


# @section customCAs **Custom Certificate Authority**

# @param customCAs.bundle Custom CA [text representation of the X.509 PEM public-key certificate](https://www.rfc-editor.org/rfc/rfc7468#section-5.1)
# @param customCAs.certsPath Custom CA bundle mount directory in the container. If empty, the default value: "/usr/local/share/ca-certificates"

customCAs:
bundle: ''
# bundle: |
# -----BEGIN CERTIFICATE-----
# ...
# -----END CERTIFICATE-----
certsPath: ''
Loading