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 helm chart #1503

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
3f734d2
First attempt at chart
patoarvizu Oct 8, 2019
aa873f4
Minimize duplication by moving if / else logic
patoarvizu Oct 9, 2019
5922c38
Consolidate storage values in a single map
patoarvizu Oct 9, 2019
c7a05b0
Only deploy signer if 'trust' is set to 'remote'
patoarvizu Oct 9, 2019
c01f19c
Remove unnecessary template
patoarvizu Oct 9, 2019
794014c
Take signer alias secret as a parameter and reference it from the Dep…
patoarvizu Oct 9, 2019
6614999
Add option to configure 'gun_prefixes'
patoarvizu Oct 9, 2019
de33e4c
Use values for ports
patoarvizu Oct 9, 2019
637670a
Only create PVC if 'storage' is not 'memory'
patoarvizu Oct 9, 2019
e871562
Parameterize PVC size
patoarvizu Oct 9, 2019
1a4ceed
Parameterize and pin versions of server, signer, and migrate
patoarvizu Oct 9, 2019
d0485c3
Missed some ports
patoarvizu Oct 9, 2019
40732f8
Add annotations to the ingress via values
patoarvizu Oct 9, 2019
a16ef65
Fix signer service name to 'notarysigner'
patoarvizu Oct 9, 2019
58456ed
Remove 'fullname' prefix from all resources to make it consistent wit…
patoarvizu Oct 10, 2019
125ad55
Add better labels to Deployments and Services
patoarvizu Oct 10, 2019
27aa2fb
Enable load balancer service too
patoarvizu Oct 10, 2019
611a7d1
Set 'command' to 'notary-signer' directly
patoarvizu Oct 10, 2019
1b3e89f
Add '.tpl' extension to config files
patoarvizu Oct 10, 2019
0a306d6
Hard-code not-so-secret aliasSecret
patoarvizu Oct 10, 2019
a609888
Add Helm section to README
patoarvizu Oct 10, 2019
f570e96
Merge branch 'master' into add_helm_chart
patoarvizu Oct 17, 2019
8fed2fb
Merge branch 'master' into add_helm_chart
patoarvizu Oct 21, 2019
6b19514
Merge branch 'master' into add_helm_chart
patoarvizu Oct 23, 2019
7d93c5f
Add 'storage.className' parameter
patoarvizu Oct 23, 2019
88fe64d
Conditionally set 'loadBalancerIP' on the notaryserver service
patoarvizu Oct 23, 2019
1b39517
Add comments to the chart's values.yaml file
patoarvizu Oct 23, 2019
a161240
Add option to provide custom certificates or let Helm auto-generate them
patoarvizu Nov 8, 2019
aac6862
Deleting symlink to fixtures
patoarvizu Nov 8, 2019
541a81a
Point 'client_ca_file' to the root CA
patoarvizu Nov 8, 2019
12ba72b
Move server and signer configuration directly into the configmap temp…
patoarvizu Nov 8, 2019
fcac30b
Add authentication options
patoarvizu Nov 8, 2019
1361d97
Add caching options
patoarvizu Nov 8, 2019
e88e83c
Rewrite section about the chart not being prod-ready
patoarvizu Nov 8, 2019
eec0f16
Split storage options to allow for remote storage
patoarvizu Nov 8, 2019
647c622
Add options to configure server and signer to use remote storage
patoarvizu Nov 8, 2019
53bd14c
Add option to specify secret to get the alias passphrase instead of a…
patoarvizu Nov 8, 2019
60b4f42
Move migrations to jobs instead of init containers on deployments
patoarvizu Nov 9, 2019
c268c82
Start parameterizing database passwords
patoarvizu Nov 9, 2019
be04c2e
Parameterize the initdb passwords so they're not in plain text in the…
patoarvizu Nov 9, 2019
5efb93a
Now parameterize Notary storage configuration
patoarvizu Nov 10, 2019
1734495
Remove unneeded volumes
patoarvizu Nov 10, 2019
872c053
Use double '%' everywhere for consistency
patoarvizu Nov 10, 2019
e5774ab
Clean up storage container so thereare no hard-coded credentials; fix…
patoarvizu Nov 10, 2019
e14c189
Use 'template' instead of templating inline
patoarvizu Nov 10, 2019
35e573c
Add comments to storage credential values
patoarvizu Nov 10, 2019
78edc48
Simplify database configuration
patoarvizu Nov 10, 2019
57d2753
Merge branch 'master' into add_helm_chart
patoarvizu Nov 10, 2019
c925f19
Add hyphen to be consistent
patoarvizu Nov 10, 2019
dd87d94
Parameterize number of replicas
patoarvizu Nov 10, 2019
78665b1
Add pod anti-affinity options
patoarvizu Nov 10, 2019
f689f91
Add node affinity options
patoarvizu Nov 10, 2019
8685262
Rename some default secrets and make them non-optional
patoarvizu Nov 10, 2019
adcd28b
Merge branch 'master' into add_helm_chart
patoarvizu Feb 15, 2020
81efdc9
PR comments
patoarvizu Feb 15, 2020
e2fc091
Merge branch 'master' into add_helm_chart
patoarvizu Jul 5, 2020
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ $ notary

To build the server and signer, run `docker-compose build`.

## Helm

If you prefer to deploy with [Helm](https://helm.sh), this repo includes a chart in the [helm/](helm/) directory. Assuming you already have a target Kubernetes cluster with Helm/Tiller running, you can quickly launch a Notary service with `helm install -n release-name helm/`. With the default values, this chart will create a containerized mysql database, run the required migrations, and launch a single instance of a server an a single instance of a signer (with their respective service endpoints).

For compatibility, the server is exposed **both** by an `Ingress`, and by a `Service` of `type: LoadBalancer`. Depending on Kubernetes distribution or configuration you're using, it may be easier to use one or the other. Also, if you're running any virtualized or containerized distribution (like [Minikube](https://github.com/kubernetes/minikube), or [k3d](https://github.com/rancher/k3d)), you might need to map host ports to the corresponding service ports (443 for the `Ingress` and 4443 by default on the `Service`).

The chart's default [values.yaml](helm/values.yaml) can give you an idea of the configuration options. One useful setting is `storage.type`, which can be set to `mysql`, `postgres`, or `memory`. If it's set to memory, then the chart will not create a containerized database, and instead set the storage for both the server and the signer to memory. Also, `server.trust` is set to `remote` by default, which means the chart will spin up a signer and point the server there, but if `server.trust` is set to `local`, then no signer will be created (all settings will be ignored). You can combine both `storage.type: memory` and `server.trust: local`, to very quickly spin up a Notary endpoint you can immediately point your CLI to.

### IMPORTANT!

This chart is currently **NOT** meant to be used in production, but rather as a way of quickly deploying Notary in a development or test environment, to explore or validate its use in a Kubernetes environment. It uses self-signed certs that have been distributed publicly, hard-coded, plain-text passwords, doesn't scale, etc.

If you are looking to deploy Notary in Kubernetes in production, the chart will provide a starting point, but it will require considerable improvements before it can be considered prod-ready. At a minimum, you will need to make sure that your secrets are distributed properly and securely (with [KMS](https://aws.amazon.com/kms/), [Vault](https://www.vaultproject.io), etc.), but also make sure you use your own TLS certs, preferably created and distributed dynamically (like with [Let's Encrypt](https://letsencrypt.org)).

## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Ftheupdateframework%2Fnotary.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Ftheupdateframework%2Fnotary?ref=badge_large)
21 changes: 21 additions & 0 deletions helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
4 changes: 4 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
description: Notary
name: notary
version: 0.0.0
26 changes: 26 additions & 0 deletions helm/files/server-config.json.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"server": {
"http_addr": ":{{ .Values.server.port }}",
"tls_key_file": "/tls/notary-server.key",
"tls_cert_file": "/tls/notary-server.crt"
},
"trust_service": {
"type": "{{ .Values.server.trust.type }}",
"hostname": "notarysigner",
"port": "{{ .Values.server.trust.port }}",
"tls_ca_file": "/tls/root-ca.crt",
"key_algorithm": "ecdsa",
"tls_client_cert": "/tls/notary-server.crt",
"tls_client_key": "/tls/notary-server.key"
},
"logging": {
"level": "{{ .Values.logging.level }}"
},
"storage": {
"backend": "{{ .Values.storage.type }}",
"db_url": "{{ template "notary.serverdburl" . }}"
},
"repositories": {
"gun_prefixes": {{ .Values.server.gunPrefixes | toJson }}
}
}
16 changes: 16 additions & 0 deletions helm/files/signer-config.json.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"server": {
"grpc_addr": ":{{ .Values.signer.port }}",
"tls_cert_file": "/tls/notary-signer.crt",
"tls_key_file": "/tls/notary-signer.key",
"client_ca_file": "/tls/notary-server.crt"
},
"logging": {
"level": "{{ .Values.logging.level }}"
},
"storage": {
"backend": "{{ .Values.storage.type }}",
"db_url": "{{ template "notary.signerdburl" . }}",
"default_alias": "{{ .Values.signer.defaultAlias }}"
}
}
1 change: 1 addition & 0 deletions helm/fixtures
1 change: 1 addition & 0 deletions helm/migrations
1 change: 1 addition & 0 deletions helm/notarysql
36 changes: 36 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- define "notary.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "notary.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{- define "notary.serverdburl" -}}
{{- if eq .Values.storage.type "mysql" -}}
root@tcp(notary-db:3306)/notaryserver
{{- else if eq .Values.storage.type "postgres" -}}
server@notary-db:5432/notaryserver?sslmode=verify-ca&sslrootcert=/tls/database-ca.pem&sslcert=/tls/notary-server.pem&sslkey=/tls/notary-server-key.pem
{{- end -}}
{{- end -}}

{{- define "notary.signerdburl" -}}
{{- if eq .Values.storage.type "mysql" -}}
root@tcp(notary-db:3306)/notarysigner
{{- else if eq .Values.storage.type "postgres" -}}
signer@notary-db:5432/notarysigner?sslmode=verify-ca&sslrootcert=/tls/database-ca.pem&sslcert=/tls/notary-signer.pem&sslkey=/tls/notary-signer-key.pem"
{{- end -}}
{{- end -}}

{{- define "notary.gunprefixes" -}}
{{- .Values.server.gunPrefixes | toJson -}}
{{ end -}}
76 changes: 76 additions & 0 deletions helm/templates/configmaps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{{- if not (eq .Values.storage.type "memory") }}

apiVersion: v1
kind: ConfigMap
metadata:
name: notarysql
data:
{{- if eq .Values.storage.type "mysql" }}
{{- range $path, $bytes := .Files.Glob "notarysql/mysql-initdb.d/**" }}
{{ base $path }}: |
{{ $.Files.Get $path | indent 4 }}
{{- end }}
{{- else if eq .Values.storage.type "postgres" }}
{{- range $path, $bytes := .Files.Glob "notarysql/postgresql-initdb.d/**" }}
{{ base $path }}: |
{{ $.Files.Get $path | indent 4 }}
{{- end }}
{{- end }}


---

apiVersion: v1
kind: ConfigMap
metadata:
name: notary-migrations-server
data:
{{- if eq .Values.storage.type "mysql" }}
{{- range $path, $bytes := .Files.Glob "migrations/server/mysql/**" }}
{{ base $path }}: |
{{ $.Files.Get $path | indent 4 }}
{{- end }}
{{- else if eq .Values.storage.type "postgres" }}
{{- range $path, $bytes := .Files.Glob "migrations/server/postgresql/**" }}
{{ base $path }}: |
{{ $.Files.Get $path | indent 4 }}
{{- end }}
{{- end }}


{{- if eq .Values.server.trust.type "remote" }}

---

apiVersion: v1
kind: ConfigMap
metadata:
name: notary-migrations-signer
data:
{{- if eq .Values.storage.type "mysql" }}
{{- range $path, $bytes := .Files.Glob "migrations/signer/mysql/**" }}
{{ base $path }}: |
{{ $.Files.Get $path | indent 4 }}
{{- end }}
{{- else if eq .Values.storage.type "postgres" }}
{{- range $path, $bytes := .Files.Glob "migrations/signer/postgresql/**" }}
{{ base $path }}: |
{{ $.Files.Get $path | indent 4 }}
{{- end }}
{{- end }}

{{- end }}

---

{{- end }}

apiVersion: v1
kind: ConfigMap
metadata:
name: notary-config
data:
server-config.json: |
{{ tpl (.Files.Get "files/server-config.json.tpl") . | indent 4 }}
signer-config.json: |
{{ tpl (.Files.Get "files/signer-config.json.tpl") . | indent 4 }}
Loading