Skip to content

Commit

Permalink
feat(vector): Add optional Ingress resource (#53)
Browse files Browse the repository at this point in the history
* feat(vector): Add optional Ingress resource

Signed-off-by: Spencer Gilbert <[email protected]>

* fix(vector): Ensure we don't create a backend with both name and number for port

Signed-off-by: Spencer Gilbert <[email protected]>

* chore(vector): Include ci file and disable ingress by default

Signed-off-by: Spencer Gilbert <[email protected]>

* chore(vector): Run helm-docs

Signed-off-by: Spencer Gilbert <[email protected]>

* Switch to comparing versions

Signed-off-by: Spencer Gilbert <[email protected]>
  • Loading branch information
spencergilbert authored Sep 17, 2021
1 parent c8d8ff0 commit 2b87bf0
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
5 changes: 5 additions & 0 deletions charts/vector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ helm install --name <RELEASE_NAME> \
| image.pullSecrets | list | `[]` | Agent repository pullSecret (ex: specify docker registry credentials) |
| image.repository | string | `"timberio/vector"` | Override default registry + name for Vector |
| image.tag | string | Chart's appVersion | Vector image tag to use |
| ingress.annotations | object | `{}` | Set annotations on the Ingress |
| ingress.className | string | `""` | Specify the ingressClassName, requires Kubernetes >= 1.18 |
| ingress.enabled | bool | `false` | If true, create and use an Ingress resource |
| ingress.hosts | list | `[]` | Configure the hosts and paths for the Ingress |
| ingress.tls | list | `[]` | Configure TLS for the Ingress |
| livenessProbe | object | `{}` | Override default liveness probe settings |
| nodeSelector | object | `{}` | Allow Vector to be scheduled on selected nodes |
| persistence.accessModes | list | `["ReadWriteOnce"]` | Specifies the accessModes for PersistentVolumeClaims |
Expand Down
16 changes: 16 additions & 0 deletions charts/vector/ci/aggregator-ingress-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Ingress usage
## Values file for testing Ingress parameters.
ingress:
enabled: true
className: "nginx"
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /api/v1
pathType: Prefix
port:
name: "http"
number: "8080"
64 changes: 64 additions & 0 deletions charts/vector/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{- if .Values.ingress.enabled -}}
{{- if and .Values.ingress.className (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.className}}
{{- 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 "vector.fullname" . }}
labels:
{{- include "vector.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- 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: {{ if $.Values.haproxy.enabled }}{{ include "haproxy.fullname" $ }}{{ else }}{{ include "vector.fullname" $ }}{{ end }}
port:
{{- if .port.name }}
name: {{ .port.name }}
{{- else }}
number: {{ .port.number }}
{{- end }}
{{- else }}
serviceName: {{ if $.Values.haproxy.enabled }}{{ include "haproxy.fullname" $ }}{{ else }}{{ include "vector.fullname" $ }}{{ end }}
servicePort: {{ .port.number }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

28 changes: 28 additions & 0 deletions charts/vector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,34 @@ service:
# service.ports -- Override automated generation of Service ports
ports: []

## Configuration for Vector's Ingress
ingress:
# ingress.enabled -- If true, create and use an Ingress resource
enabled: false
# ingress.className -- Specify the ingressClassName, requires Kubernetes >= 1.18
## Ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/#specifying-the-class-of-an-ingress
className: ""
# ingress.annotations -- Set annotations on the Ingress
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
# ingress.hosts -- Configure the hosts and paths for the Ingress
hosts: []
# - host: chart-example.local
# paths:
# - path: /
# pathType: ImplementationSpecific
# # Specify the port name or number on the Service
# # Using name requires Kubernetes >=1.19
# port:
# name: ""
# number: ""
# ingress.tls -- Configure TLS for the Ingress
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

# existingConfigMap -- Use existing ConfigMap for Vector's configuration instead of creating a new one
## If set, this parameter takes precedence over customConfig and the chart's default configs
existingConfigMap: ""
Expand Down

0 comments on commit 2b87bf0

Please sign in to comment.