[stable/prisma]: add Prisma chart (#6483)

Signed-off-by: Giacomo Guiulfo <giacomoguiulfo@gmail.com>
This commit is contained in:
Giacomo Guiulfo
2018-10-06 11:38:33 -07:00
committed by k8s-ci-robot
parent ef0cf539ba
commit 0f89b9ba8d
15 changed files with 544 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
# 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
OWNERS
+13
View File
@@ -0,0 +1,13 @@
name: prisma
version: 0.1.0
appVersion: 1.15
kubeVersion: "^1.8.0-0"
description: Prisma turns your database into a realtime GraphQL API
home: https://www.prisma.io/
icon: https://i.imgur.com/wD4rVt4.png
sources:
- https://github.com/prismagraphql/prisma
maintainers:
- name: giacomoguiulfo
email: giacomoguiulfo@gmail.com
engine: gotpl
+4
View File
@@ -0,0 +1,4 @@
approvers:
- giacomoguiulfo
reviewers:
- giacomoguiulfo
+77
View File
@@ -0,0 +1,77 @@
# Prisma Helm Chart
[Prisma](https://prisma.io) is a performant open-source GraphQL ORM-like layer doing the heavy lifting in your GraphQL server.
## TL;DR;
```bash
$ helm install stable/prisma
```
## Introduction
This chart bootstraps a Prisma deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
**Note**: This chart doesn't support horizontal scaling for Prisma yet.
## Installing the Chart
To install the chart with the release name `my-release`:
```bash
$ helm install --name my-release stable/prisma
```
**Note**: Prisma requires a properly configured database in order to initialize. See the `values.yaml` file for the configuration values that need to be set. Also, if preferred you can set `postgresql.enabled` to `true` and Helm will deploy the PostgreSQL chart listed in the `requirements.yaml` file, and Prisma will be able to initialize properly using the default values.
> **Tip**: List all releases using `helm list`
## Uninstalling the Chart
To uninstall/delete the `my-release` deployment:
```bash
$ helm delete my-release
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
The following table lists the configurable parameters of the Prisma chart and their default values.
Parameter | Description | Default
-------------------------------- | -------------------------------------------- | ---------------------------------------------------------
`image.repository` | Prisma image repository | `prismagraphql/prisma`
`image.tag` | Prisma image tag | `1.15-heroku`
`image.pullPolicy` | Image pull policy | `IfNotPresent`
`database.connector` | Database connector | `postgres`
`database.host` | Host for the database endpoint | `""`
`database.port` | Port for the database endpoint | `""`
`database.user` | Database user | `prisma`
`database.password` | Database password | `""`
`database.migrations` | Enable database migrations | `true`
`auth.enabled` | Enable Prisma Management API authentication | `false`
`auth.secret` | Secret to use for authentication | `nil`
`service.type` | Type of Service | `ClusterIP`
`service.port` | Service TCP port | `4466`
`ingress.enabled` | Enables Ingress | `false`
`ingress.annotations` | Ingress annotations | `{}`
`ingress.path` | Ingress path | `/`
`ingress.hosts` | Ingress accepted hostnames | `[]`
`ingress.tls` | Ingress TLS configuration | `[]`
`resources` | CPU/Memory resource requests/limits | `{}`
`nodeSelector` | Node labels for pod assignment | `{}`
`affinity` | Affinity settings for pod assignment | `{}`
`tolerations` | Toleration labels for pod assignment | `[]`
`postgresql.enabled` | Install PostgreSQL chart | `false`
`postgresql.imagePullPolicy` | PostgreSQL image pull policy | `Always` if `imageTag` is `latest`, else `IfNotPresent`
`postgresql.persistence.enabled` | Persist data to a PV | `false`
`postgresql.postgresUser` | Username of new user to create | `prisma`
`postgresql.postgresPassword` | Password for the new user | `""`
`postgresql.service.port` | PostgreSQL service TCP port | `5432`
`postgresql.resources` | PostgreSQL resource requests and limits | Memory: `256Mi`, CPU: `100m`
Additional configuration parameters for the PostgreSQL database deployed with Prisma can be found [here](https://github.com/kubernetes/charts/tree/master/stable/postgresql).
> **Tip**: You can use the default [values.yaml](values.yaml)
+2
View File
@@ -0,0 +1,2 @@
postgresql:
enabled: true
+6
View File
@@ -0,0 +1,6 @@
dependencies:
- name: postgresql
repository: https://kubernetes-charts.storage.googleapis.com/
version: 0.15.0
digest: sha256:bbc1e13abc845c3e5cad4c328105a9c50ee5692d73547065ffbf63f15e6fd533
generated: 2018-08-09T17:19:54.160902267-07:00
+5
View File
@@ -0,0 +1,5 @@
dependencies:
- name: postgresql
version: ~0.15.0
repository: "https://kubernetes-charts.storage.googleapis.com/"
condition: postgresql.enabled
+19
View File
@@ -0,0 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "prisma.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ template "prisma.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "prisma.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "prisma.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:4466
{{- end }}
+88
View File
@@ -0,0 +1,88 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "prisma.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
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 "prisma.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 -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "prisma.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | 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 "prisma.postgresql.fullname" -}}
{{- $name := default "postgresql" .Values.postgresql.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified name for the secret that contains the database password.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "prisma.databaseSecret.fullname" -}}
{{- if .Values.postgresql.enabled -}}
{{- include "prisma.postgresql.fullname" . }}
{{- else -}}
{{- include "prisma.fullname" . }}
{{- end -}}
{{- end -}}
{{/*
Set the proper name for the secretKeyRef key that contains the database password.
*/}}
{{- define "prisma.databaseSecret.key" -}}
{{- if .Values.postgresql.enabled -}}
postgres-password
{{- else -}}
db-password
{{- end -}}
{{- end -}}
{{/*
Set the proper database host. If postgresql is installed as part of this chart, use the default service name,
else use user-provided host
*/}}
{{- define "prisma.database.host" }}
{{- if .Values.postgresql.enabled -}}
{{- include "prisma.postgresql.fullname" . }}
{{- else -}}
{{- .Values.database.host | quote }}
{{- end -}}
{{- end -}}
{{/*
Set the proper database port. If postgresql is installed as part of this chart, use the default postgresql port,
else use user-provided port
*/}}
{{- define "prisma.database.port" }}
{{- if .Values.postgresql.enabled -}}
{{- default "5432" ( .Values.postgresql.service.port | quote ) }}
{{- else -}}
{{- .Values.database.port | quote }}
{{- end -}}
{{- end -}}
+23
View File
@@ -0,0 +1,23 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "prisma.fullname" . }}
labels:
app: {{ template "prisma.name" . }}
chart: {{ template "prisma.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
config: |
port: 4466
{{- if .Values.auth.enabled }}
managementApiSecret: $PRISMA_API_SECRET
{{- end }}
databases:
default:
connector: $PRISMA_DB_CONNECTOR
host: $PRISMA_DB_HOST
port: $PRISMA_DB_PORT
user: $PRISMA_DB_USER
password: $PRISMA_DB_PASSWORD
migrations: $PRISMA_DB_MIGRATIONS
+78
View File
@@ -0,0 +1,78 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "prisma.fullname" . }}
labels:
app: {{ template "prisma.name" . }}
chart: {{ template "prisma.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ template "prisma.name" . }}
release: {{ .Release.Name }}
strategy:
type: Recreate
template:
metadata:
labels:
app: {{ template "prisma.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: prisma
containerPort: 4466
protocol: TCP
env:
- name: CONFIG
valueFrom:
configMapKeyRef:
name: {{ template "prisma.fullname" . }}
key: config
{{- if .Values.auth.secret }}
- name: PRISMA_API_SECRET
valueFrom:
secretKeyRef:
name: {{ template "prisma.fullname" . }}
key: api-secret
{{- end}}
- name: PRISMA_CONFIG_PATH
value: "/app/config.yml"
- name: PRISMA_DB_CONNECTOR
value: {{ .Values.database.connector | quote }}
- name: PRISMA_DB_HOST
value: {{ template "prisma.database.host" . }}
- name: PRISMA_DB_PORT
value: {{ template "prisma.database.port" . }}
- name: PRISMA_DB_USER
valueFrom:
secretKeyRef:
name: {{ template "prisma.fullname" . }}
key: db-user
- name: PRISMA_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "prisma.databaseSecret.fullname" . }}
key: {{ template "prisma.databaseSecret.key" . }}
- name: PRISMA_DB_MIGRATIONS
value: {{ .Values.database.migrations | quote }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
+39
View File
@@ -0,0 +1,39 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "prisma.fullname" . -}}
{{- $servicePort := .Values.service.port -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app: {{ template "prisma.name" . }}
chart: {{ template "prisma.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- end }}
+24
View File
@@ -0,0 +1,24 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "prisma.fullname" . }}
labels:
app: {{ template "prisma.name" . }}
chart: {{ template "prisma.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
{{- if and .Values.auth.enabled .Values.auth.secret }}
api-secret: {{ .Values.auth.secret | b64enc | quote }}
{{- else if .Values.auth.enabled }}
api-secret: {{ randAlphaNum 40 | b64enc | quote }}
{{- end }}
db-user: {{ .Values.database.user | b64enc | quote }}
{{- if not .Values.postgresql.enabled }}
{{- if .Values.database.password }}
db-password: {{ .Values.database.password | b64enc | quote }}
{{- else }}
db-password: {{ randAlphaNum 40 | b64enc | quote }}
{{- end }}
{{- end }}
+19
View File
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "prisma.fullname" . }}
labels:
app: {{ template "prisma.name" . }}
chart: {{ template "prisma.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- name: service
port: {{ .Values.service.port }}
protocol: TCP
targetPort: prisma
selector:
app: {{ template "prisma.name" . }}
release: {{ .Release.Name }}
+125
View File
@@ -0,0 +1,125 @@
# ------------------------------------------------------------------------------
# Prisma:
# ------------------------------------------------------------------------------
image:
## Prisma image repository
##
repository: prismagraphql/prisma
## Prisma image version
##
tag: 1.15-heroku
## Specify an imagePullPolicy
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
pullPolicy: IfNotPresent
database:
## The current supported connectors are [mysql, postgres]
connector: postgres
## If 'postgresql.enabled' is 'false', you will need to provide the
## following values so that Prisma can use them as the database endpoint
host: ""
port: ""
## Database credentials
##
user: prisma
password: ""
## Enable database migrations
##
migrations: true
auth:
## Prisma's Management API authentication
##
enabled: false
## Secret to use. If it isn't specified and 'auth.enabled' is set to 'true',
## a random generated one will be used
##
# secret: ""
service:
type: ClusterIP
port: 4466
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
path: /
hosts: []
# - prisma.local
tls: []
# - secretName: prisma-tls
# hosts:
# - prisma.local
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
## Node labels for pod assignment
## ref: https://kubernetes.io/docs/user-guide/node-selection/
##
nodeSelector: {}
## Tolerations for pod assignment
## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
##
tolerations: []
## Affinity for pod assignment
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
##
affinity: {}
# ------------------------------------------------------------------------------
# PostgreSQL:
# ------------------------------------------------------------------------------
postgresql:
## If true, install the PostgreSQL chart alongside Prisma
## ref: https://github.com/kubernetes/charts/tree/master/stable/postgresql
##
enabled: false
## PostgresSQL image version
## ref: https://hub.docker.com/r/library/postgres/tags/
##
imageTag: "9.6.2"
## Specify a PostgreSQL imagePullPolicy
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
imagePullPolicy: "IfNotPresent"
## Persist data to a persistent volume
##
persistence:
enabled: false
## PostgreSQL credentials
##
postgresUser: prisma
postgresPassword: ""
## PostgreSQL service TCP port
##
service:
port: 5432
## Configure PostgreSQL resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
resources: {}