Skip to content

Commit

Permalink
[FEATURE] standard ingress with TLS
Browse files Browse the repository at this point in the history
This will replace ingress with helm standard ingress, which also adds support for TLS configuration. Recommended usage:

```yaml
    ingress:
      enabled: true
      annotations:
        kubernetes.io/tls-acme: "true"
      hosts:
        - perses.example.com
      tls:
        - secretName: ingress-cert
          hosts:
            - perses.example.com
```

in combination with [cert-manager](https://cert-manager.io/) this will automatically generate certificates and configure HTTPS.

Signed-off-by: Michael Sprauer <[email protected]>
  • Loading branch information
MichaelSp committed Oct 10, 2024
1 parent 0f8b747 commit da66a36
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 26 deletions.
3 changes: 2 additions & 1 deletion charts/perses/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ helm delete my-release
| ingress | object | `{"annotations":{},"enabled":false,"hostname":"perses.local","ingressClassName":"","path":"/","pathType":"Prefix"}` | Configure the ingress resource that allows you to access Thanos Query Frontend ref: https://kubernetes.io/docs/concepts/services-networking/ingress/ |
| ingress.annotations | object | `{}` | Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations. For a full list of possible ingress annotations, please see ref: https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/annotations.md |
| ingress.enabled | bool | `false` | Enable ingress controller resource |
| ingress.hostname | string | `"perses.local"` | Default host for the ingress resource |
| ingress.hosts | array | `["perses.local"]` | Default host for the ingress resource |
| ingress.ingressClassName | string | `""` | IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster . ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/ |
| ingress.path | string | `"/"` | Ingress path |
| ingress.pathType | string | `"Prefix"` | Ingress path type |
| ingress.tls | array | `[]` | |
| livenessProbe | object | `{"enabled":true,"failureThreshold":5,"initialDelaySeconds":10,"periodSeconds":60,"successThreshold":1,"timeoutSeconds":5}` | Liveness probe configuration Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ |
| logLevel | string | `"info"` | Log level for Perses be configured in available options "panic", "error", "warning", "info", "debug", "trace" |
| nameOverride | string | `""` | Override name of the chart used in Kubernetes object names. |
Expand Down
4 changes: 0 additions & 4 deletions charts/perses/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@
{{- if and .Values.persistence.enabled (eq .Values.persistence.storageClass "") }}
{{ fail "[ERROR] 'persistencen.storageClass' must be set." }}
{{ end }}

{{- if and .Values.ingress.enabled (eq .Values.ingress.ingressClassName "") }}
{{ fail "[ERROR] 'ingress.ingressClassName' must be set." }}
{{ end }}
65 changes: 49 additions & 16 deletions charts/perses/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,61 @@
{{- if .Values.ingress.enabled }}
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "perses.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.ingressClassName (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.ingressClassName}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ include "perses.fullname" . }}
name: {{ $fullName }}
labels:
{{- include "perses.labels" . | nindent 4 }}
app.kubernetes.io/component: networking
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName | quote }}
{{- if and .Values.ingress.ingressClassName (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
- host : {{ .Values.ingress.hostname }}
http:
paths:
- path: {{ .Values.ingress.path }}
pathType: {{ .Values.ingress.pathType }}
backend:
service:
name: {{ include "perses.fullname" . }}
port:
name: {{ .Values.service.portName }}
{{- end }}
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
32 changes: 28 additions & 4 deletions charts/perses/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,11 @@
"enabled": {
"type": "boolean"
},
"hostname": {
"type": "string"
"hosts": {
"type": "array",
"items": {
"type": "string"
}
},
"ingressClassName": {
"type": "string"
Expand All @@ -521,11 +524,32 @@
"Prefix",
"ImplementationSpecific"
]
},
"tls": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"hosts": {
"type": "array",
"items": {
"type": "string"
}
},
"secretName": {
"type": "string"
}
},
"required": [
"hosts",
"secretName"
]
}
}
},
"required": [
"hostname",
"ingressClassName",
"hosts",
"path",
"pathType"
]
Expand Down
8 changes: 7 additions & 1 deletion charts/perses/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ ingress:
enabled: false

# -- Default host for the ingress resource
hostname: perses.local
hosts:
- perses.local

# -- IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+)
# This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .
Expand All @@ -190,6 +191,11 @@ ingress:
# -- Ingress path type
pathType: Prefix

# -- Ingress TLS configuration
tls: []
# - secretName: ingress-cert
# hosts: []

# -- Configure datasources
# ref: https://github.com/perses/perses/blob/90beed356243208f14cf2249bebb6f6222cb77ae/docs/datasource.md
datasources:
Expand Down

0 comments on commit da66a36

Please sign in to comment.