Skip to content

Commit

Permalink
add imaginary chart (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisPoinsot authored Dec 7, 2020
1 parent 1e0d931 commit bd162bf
Show file tree
Hide file tree
Showing 12 changed files with 382 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The public Ricardo AG Helm Charts. The code is provided as-is with no warranties
## Available Charts

* [promlens](https://github.com/ricardo-ch/helm-charts/tree/main/charts/promlens)
* [imaginary](https://github.com/ricardo-ch/helm-charts/tree/main/charts/imaginary)

## How To Use These Charts

Expand Down
21 changes: 21 additions & 0 deletions charts/imaginary/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
appVersion: "1.2.4"
description: Deploy imaginary to process pictures on the fly
name: imaginary
version: 0.1.0
home: https://github.com/h2non/imaginary
sources:
- https://github.com/ricardo-ch/helm-charts/tree/main/charts/imaginary
- https://github.com/h2non/imaginary
maintainers:
- name: ricardo-ch
email: [email protected]
keywords:
- imaginary
- h2non
annotations:
artifacthub.io/changes: |
- Initial release
artifacthub.io/images: |
- name: imaginary
image: h2non/imaginary:v1.2.4
53 changes: 53 additions & 0 deletions charts/imaginary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# PromLens

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![AppVersion: 1.2.4](https://img.shields.io/badge/AppVersion-1.2.4-informational?style=flat-square) ![Release Status](https://github.com/ricardo-ch/helm-charts/workflows/Release%20Charts/badge.svg) [![License](https://img.shields.io/github/license/ricardo-ch/helm-charts)](https://github.com/ricardo-ch/helm-charts/blob/main/LICENSE)

This chart installs [Imaginary](https://github.com/h2non/imaginary).

Imaginary is a tool to process images.
e.g: crop, resize, add background...

## Helm Chart

This chart should allow most use case of Imaginary.

### How To Install

Simply add this Chart repository to Helm:

```sh
➜ helm repo add ricardo https://ricardo-ch.github.io/helm-charts/
"ricardo" has been added to your repositories
```

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| additionalAnnotations | object | `{}` | append annotation to the pod annotation list |
| additionalLabels | object | `{}` | append labels to both the deployment, pdb, hpa and the pods label list |
| apikey | string | `""` | Define API key for authorization |
| config | object | `{}` | Imaginary arguments. use the same hyphen separated synthax for the key. use strings for the value or you might get a bad formatting. |
| hpa | object | `{"maxReplicas":2,"minReplicas":2}` | Horizontal pod autoscaling configuration |
| httpPort | int | `8080` | Which port should Imaginary and its Kubernetes service listen |
| image | string | `"h2non/imaginary:1.2.4"` | Docker image repository to pull it. |
| imagePullPolicy | string | `"IfNotPresent"` | imagePullPolicy used by k8s |
| livenessProbe.failureThreshold | int | `3` | |
| livenessProbe.periodSeconds | int | `10` | |
| livenessProbe.successThreshold | int | `1` | |
| livenessProbe.timeoutSeconds | int | `1` | |
| nodeSelector | object | `{}` | A node selector label |
| pdb.minAvailable | string | `"50%"` | minAvailable field from k8s pdb |
| readinessProbe | object | `{"failureThreshold":3,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":1}` | Config for Liveness & Readiness probes |
| resources | object | `{}` | Set kubernetes specific resource limits |
| serviceType | string | `"ClusterIP"` | Kubernetes service type |
| tls.certificate | string | `""` | Base64 encoded TLS certificate file |
| tls.privateKey | string | `""` | Base64 encoded private key file for TLS certificate. |

## Source Code

* <https://github.com/ricardo-ch/helm-charts/tree/main/charts/imaginary>
* <https://github.com/h2non/imaginary>

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.3.0](https://github.com/norwoodj/helm-docs/releases/v1.3.0)
29 changes: 29 additions & 0 deletions charts/imaginary/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# PromLens

{{ template "chart.deprecationWarning" . }}

{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}![Release Status](https://github.com/ricardo-ch/helm-charts/workflows/Release%20Charts/badge.svg) [![License](https://img.shields.io/github/license/ricardo-ch/helm-charts)](https://github.com/ricardo-ch/helm-charts/blob/main/LICENSE)

This chart installs [Imaginary](https://github.com/h2non/imaginary).

Imaginary is a tool to process images.
e.g: crop, resize, add background...

## Helm Chart

This chart should allow most use case of Imaginary.

### How To Install

Simply add this Chart repository to Helm:

```sh
➜ helm repo add ricardo https://ricardo-ch.github.io/helm-charts/
"ricardo" has been added to your repositories
```

{{ template "chart.valuesSection" . }}

{{ template "chart.sourcesSection" . }}

{{ template "helm-docs.versionFooter" . }}
28 changes: 28 additions & 0 deletions charts/imaginary/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- define "imaginary.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 "imaginary.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 "imaginary.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
100 changes: 100 additions & 0 deletions charts/imaginary/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "imaginary.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
app: {{ template "imaginary.fullname" . }}
{{- range $key, $value := .Values.additionalLabels }}
{{ $key }}: {{ $value }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "imaginary.fullname" . }}
template:
metadata:
labels:
app: {{ template "imaginary.fullname" . }}
{{- range $key, $value := .Values.additionalLabels }}
{{ $key }}: {{ $value }}
{{- end }}
annotations:
{{ toYaml .Values.additionalAnnotations | indent 8 }}
spec:
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
containers:
- name: "imaginary"
image: {{ .Values.image | quote }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
env:
- name: PORT
value: {{ .Values.httpPort | quote }}
{{- if .Values.apiKey }}
- name: API_KEY
valueFrom:
secretKeyRef:
name: {{ template "imaginary.fullname" . }}-secret
key: apikey
{{- end }}
args:
{{- /* apiKey is not in the config object because I fail to set the value from helm secret when I do so */}}
{{- if .Values.apiKey }}
- "-key=$(API_KEY)"
{{- end }}
{{- range $configKey, $configValue := .Values.config }}
- "-{{ $configKey }}={{ print $configValue }}"
{{- end }}
{{- if and .Values.tls.certificate .Values.tls.privateKey }}
- "-certfile=/etc/tls.crt"
- "-keyfile=/etc/tls.key"
volumeMounts:
- mountPath: /etc/tls.key
name: certificates
subPath: tls.key
- mountPath: /etc/tls.crt
name: certificates
subPath: tls.crt
{{- end }}
resources:
{{ toYaml .Values.resources | indent 10 }}
ports:
- containerPort: {{ .Values.httpPort }}
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /health
port: {{ .Values.httpPort }}
scheme: HTTP
{{- if .Values.apiKey }}
httpHeaders:
- name: api-key
{{- /* Yes it means it is in PLAIN text in the k8s resource. No idea how to reference a k8s secret here */}}
value: {{ print .Values.apiKey | quote }}
{{- end }}
initialDelaySeconds: 10
livenessProbe:
httpGet:
path: /health
port: {{ .Values.httpPort }}
scheme: HTTP
{{- if .Values.apiKey }}
httpHeaders:
- name: api-key
{{- /* Yes it means it is in PLAIN text in the k8s resource. No idea how to reference a k8s secret here */}}
value: {{ print .Values.apiKey | quote }}
{{- end }}
initialDelaySeconds: 10
{{- if and .Values.tls.certificate .Values.tls.privateKey }}
volumes:
- name: certificates
secret:
secretName: {{ template "imaginary.fullname" . }}-tls
{{- end }}
18 changes: 18 additions & 0 deletions charts/imaginary/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
labels:
app: {{ template "imaginary.fullname" . }}
{{- range $key, $value := .Values.additionalLabels }}
{{ $key }}: {{ $value }}
{{- end }}
name: {{ template "imaginary.fullname" . }}
namespace: {{ .Release.Namespace }}
spec:
maxReplicas: {{ .Values.hpa.maxReplicas }}
minReplicas: {{ .Values.hpa.minReplicas }}
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "imaginary.fullname" . }}
targetCPUUtilizationPercentage: 80
15 changes: 15 additions & 0 deletions charts/imaginary/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
labels:
app: {{ template "imaginary.fullname" . }}
{{- range $key, $value := .Values.additionalLabels }}
{{ $key }}: {{ $value }}
{{- end }}
name: {{ template "imaginary.fullname" . }}-pdb
namespace: {{ .Release.Namespace }}
spec:
minAvailable: {{ .Values.pdb.minAvailable }}
selector:
matchLabels:
app: {{ template "imaginary.fullname" . }}
15 changes: 15 additions & 0 deletions charts/imaginary/templates/seccret_tls.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if and .Values.tls.privateKey .Values.tls.certificate }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "imaginary.fullname" . }}-tls
labels:
app: {{ template "imaginary.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
type: kubernetes.io/tls
data:
tls.key: {{ .Values.tls.privateKey }}
tls.crt: {{ .Values.tls.certificate }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/imaginary/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "imaginary.fullname" . }}-secret
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "imaginary.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
type: Opaque
data:
apikey: {{ print .Values.apiKey | b64enc | quote }}


18 changes: 18 additions & 0 deletions charts/imaginary/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "imaginary.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
app: {{ .Release.Name | quote }}
spec:
selector:
app: {{ template "imaginary.fullname" . }}
ports:
- name: http
port: {{ .Values.httpPort }}
protocol: TCP
type: {{ .Values.serviceType }}
69 changes: 69 additions & 0 deletions charts/imaginary/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# -- A node selector label
nodeSelector: {}

# -- Docker image repository to pull it.
image: "h2non/imaginary:1.2.4"
# -- imagePullPolicy used by k8s
imagePullPolicy: IfNotPresent

# -- Set kubernetes specific resource limits
resources: {}
# limits:
# cpu: 700m
# memory: 700Mi
# requests:
# cpu: 700m
# memory: 700Mi

# -- Which port should Imaginary and its Kubernetes service listen
httpPort: 8080

# -- Kubernetes service type
serviceType: "ClusterIP"

# -- Config for Liveness & Readiness probes
readinessProbe:
periodSeconds: 10
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
livenessProbe:
periodSeconds: 10
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3

# -- Imaginary arguments.
# use the same hyphen separated synthax for the key.
# use strings for the value or you might get a bad formatting.
config: {}
# example
# path-prefix: "/nya"

tls:
# -- Base64 encoded private key file for TLS certificate.
privateKey: ""

# -- Base64 encoded TLS certificate file
certificate: ""

# -- Horizontal pod autoscaling configuration
hpa:
minReplicas: 2
maxReplicas: 2


# -- Define API key for authorization
apikey: ""

# -- append labels to both the deployment, pdb, hpa and the pods label list
additionalLabels: {}
# example_label: "hello"

# -- append annotation to the pod annotation list
additionalAnnotations: {}
# sumologic.com/exclude: "true"

pdb:
# -- minAvailable field from k8s pdb
minAvailable: 50%

0 comments on commit bd162bf

Please sign in to comment.