From 79510232b82e62e83b3bcb06ee37b8a041d3d032 Mon Sep 17 00:00:00 2001 From: Marcelo Grebois Date: Tue, 12 Sep 2017 15:48:27 +0200 Subject: [PATCH 1/2] Adding postgres to the chart so it can be used without dependecies. --- contrib/helm/clair/requirements.yaml | 5 +++++ contrib/helm/clair/templates/_helpers.tpl | 7 +++++++ contrib/helm/clair/templates/configmap.yaml | 4 +++- contrib/helm/clair/values.yaml | 14 +++++++++++++- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 contrib/helm/clair/requirements.yaml diff --git a/contrib/helm/clair/requirements.yaml b/contrib/helm/clair/requirements.yaml new file mode 100644 index 00000000..ef1fd2cc --- /dev/null +++ b/contrib/helm/clair/requirements.yaml @@ -0,0 +1,5 @@ +dependencies: + - name: postgresql + version: "*" + condition: postgresql.enabled + repository: "alias:stable" \ No newline at end of file diff --git a/contrib/helm/clair/templates/_helpers.tpl b/contrib/helm/clair/templates/_helpers.tpl index f0d83d2e..e91cc6b6 100644 --- a/contrib/helm/clair/templates/_helpers.tpl +++ b/contrib/helm/clair/templates/_helpers.tpl @@ -14,3 +14,10 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- $name := default .Chart.Name .Values.nameOverride -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} + +Create a default fully qualified postgresql name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "postgresql.fullname" -}} +{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/contrib/helm/clair/templates/configmap.yaml b/contrib/helm/clair/templates/configmap.yaml index 6a9858ff..5d68b625 100644 --- a/contrib/helm/clair/templates/configmap.yaml +++ b/contrib/helm/clair/templates/configmap.yaml @@ -13,7 +13,9 @@ data: options: # PostgreSQL Connection string # https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING - source: "{{ .Values.config.postgresURI }}" + # This should be done using secrets or Vault, but for now this will also work + + source: "postgres://{{ .Values.postgresql.postgresUser }}:{{ .Values.postgresql.postgresPassword }}@{{ template "postgresql.fullname" . }}:5432/{{ .Values.postgresql.postgresDatabase }}?sslmode=disable" # Number of elements kept in the cache # Values unlikely to change (e.g. namespaces) are cached in order to save prevent needless roundtrips to the database. diff --git a/contrib/helm/clair/values.yaml b/contrib/helm/clair/values.yaml index 4cf0953b..bc2ec4a8 100644 --- a/contrib/helm/clair/values.yaml +++ b/contrib/helm/clair/values.yaml @@ -36,7 +36,6 @@ resources: cpu: 100m memory: 128Mi config: - postgresURI: "postgres://user:password@host:5432/postgres?sslmode=disable" paginationKey: "XxoPtCUzrUv4JV5dS+yQ+MdW7yLEJnRMwigVY/bpgtQ=" updateInterval: 2h notificationWebhookEndpoint: https://example.com/notify/me @@ -56,3 +55,16 @@ config: - apk - dpkg - rpm +## Configuration values for the postgresql dependency. +## ref: https://github.com/kubernetes/charts/blob/master/stable/postgresql/README.md +## +postgresql: + cpu: 1000m + memory: 1Gi +## Harcording for now till https://github.com/kubernetes/helm/issues/2196 + postgresUser: clair + postgresPassword: clair + postgresDatabase: clair + + persistence: + size: 10Gi \ No newline at end of file From 3617b7a12646d9d5f68ec057ed327b2f16ffeafb Mon Sep 17 00:00:00 2001 From: Marcelo Grebois Date: Tue, 12 Sep 2017 23:29:21 +0200 Subject: [PATCH 2/2] Adding back postgresURI and correcting comments --- contrib/helm/clair/templates/configmap.yaml | 5 ++++- contrib/helm/clair/values.yaml | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/contrib/helm/clair/templates/configmap.yaml b/contrib/helm/clair/templates/configmap.yaml index 5d68b625..e30cab3e 100644 --- a/contrib/helm/clair/templates/configmap.yaml +++ b/contrib/helm/clair/templates/configmap.yaml @@ -14,8 +14,11 @@ data: # PostgreSQL Connection string # https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING # This should be done using secrets or Vault, but for now this will also work - + {{- if .Values.config.postgresURI -}} + source: "{{ .Values.config.postgresURI }}" + {{ else }} source: "postgres://{{ .Values.postgresql.postgresUser }}:{{ .Values.postgresql.postgresPassword }}@{{ template "postgresql.fullname" . }}:5432/{{ .Values.postgresql.postgresDatabase }}?sslmode=disable" + {{ end }} # Number of elements kept in the cache # Values unlikely to change (e.g. namespaces) are cached in order to save prevent needless roundtrips to the database. diff --git a/contrib/helm/clair/values.yaml b/contrib/helm/clair/values.yaml index bc2ec4a8..a30b8dcb 100644 --- a/contrib/helm/clair/values.yaml +++ b/contrib/helm/clair/values.yaml @@ -36,6 +36,7 @@ resources: cpu: 100m memory: 128Mi config: + # postgresURI: "postgres://user:password@host:5432/postgres?sslmode=disable" paginationKey: "XxoPtCUzrUv4JV5dS+yQ+MdW7yLEJnRMwigVY/bpgtQ=" updateInterval: 2h notificationWebhookEndpoint: https://example.com/notify/me @@ -55,13 +56,13 @@ config: - apk - dpkg - rpm -## Configuration values for the postgresql dependency. -## ref: https://github.com/kubernetes/charts/blob/master/stable/postgresql/README.md -## +# Configuration values for the postgresql dependency. +# ref: https://github.com/kubernetes/charts/blob/master/stable/postgresql/README.md postgresql: cpu: 1000m memory: 1Gi -## Harcording for now till https://github.com/kubernetes/helm/issues/2196 +# These values are hardcoded until Helm supports secrets. +# For more info see: https://github.com/kubernetes/helm/issues/2196 postgresUser: clair postgresPassword: clair postgresDatabase: clair