Skip to content

Commit

Permalink
feat: add basic ingressroute support
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech Międzybrodzki committed Jan 9, 2025
1 parent 9f135c7 commit 2aeb2f8
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 13 deletions.
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
Platformex App chart
---
Flexible helm chart to deploy your apps to kubernetes cluster.
Simplifies complex deployments with abstractions and reasonable defaults.

## Installation:
>We did it, so you won't have to.
## Disclaimer:
Please do not consider this chart "stable" or production-ready yet. We're getting there ;)

## Installation:
Use this chart as a dependency inside your app's own chart:

```yaml
Expand All @@ -16,19 +22,18 @@ appVersion: 1.0.0

dependencies:
- name: app
version: 0.3.1
version: 0.4.0
repository: https://wojciechem.github.io/platformex
```
For values please see [values-example.yaml](charts/app/values-example.yaml)
## TODO:
- [ ] 1st working version
- [x] values-example.yaml file with all possible options used
- [ ] simple stupid test
- [x] json schema based on values-example.yaml
- [ ] deployment.containers required
- use kubernetes json schema where possible:
```text
https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.31.3/probe.json

```
- Chart
- [ ] Mimimal stable v1.0.0
- [ ] Tests
- [Ingress routes](charts/app/templates/_ingressroute.tpl)
- [ ] custom service definitions for traefik ingressroutes (see https://doc.traefik.io/traefik/routing/providers/kubernetes-crd/#kind-ingressroute)
- [ ] TraefikService support in ingressroutes
- Json schema
- [ ] deployment.containers required
- [ ] use kubernetes json schema where possible, [example](https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.31.3/probe.json)
2 changes: 1 addition & 1 deletion charts/app/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Flexible helm chart to deploy your apps to kubernetes cluster.
type: application

# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.3.1
version: 0.4.0

appVersion: 1.0.0

27 changes: 27 additions & 0 deletions charts/app/templates/_ingressroute.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- define "platformex.ingressroute" }}
{{- range .routes }}
- match: {{ .match }}
kind: Rule
middlewares:
{{- range .middlewares}}
- name: {{ .name }}
{{- end }}
services:
- kind: Service
name: {{ $.svc }}
port: {{ $.port }}
{{/* # TODO: support for custom service definitions */}}
{{/* # TODO: support for TraefikService */}}
{{- end }}
{{- end }}

{{- define "platformex.ingressroute.simple" }}
{{- if .ingress.simple}}
- match: Host(`{{ .ingress.simple }}`)
kind: Rule
services:
- kind: Service
name: {{ .svc }}
port: {{ .port }}
{{- end }}
{{- end }}
37 changes: 37 additions & 0 deletions charts/app/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: v1
kind: List
items:
{{- range $iname, $instance := .Values.instances }}
{{- range $dname, $deployment := $instance.deployments }}
{{- $deploymentContext := dict "iname" $iname "instance" $instance "name" $dname "deployment" $deployment "root" $ }}
{{- if $deployment.ingress }}
{{- $svcName := cat $iname "-" $dname | nospace }}
{{- if $deployment.service.nameOverride }}
{{- $svcName := $deployment.service.nameOverride }}
{{- end }}
- apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: {{ $iname }}-{{ $dname }}
labels:
{{- include "platformex.kubernetesAppLabels" $deploymentContext | indent 8 }}
{{- include "platformex.globalLabels" $ | indent 8 }}
annotations:
"kubernetes.io/ingress.class": "traefik"
spec:
entryPoints:
{{- if $deployment.ingress.traefikEntrypoints }}
{{- range $deployment.ingress.traefikEntrypoints }}
- {{ . }}
{{- end }}
{{- else }}
{{- range $.Values.global.defaults.traefikEntrypoints }}
- {{ . }}
{{- end }}
{{- end }}
routes:
{{- include "platformex.ingressroute.simple" (dict "ingress" $deployment.ingress "svc" $svcName "port" $deployment.service.port) | indent 8 }}
{{- include "platformex.ingressroute" (dict "routes" $deployment.ingress.routes "svc" $svcName "port" $deployment.service.port) | indent 8 }}
{{- end }}
{{- end }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/app/values-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ global:
defaults:
imagePullSecrets:
- "oci-kodzik"
traefikEntrypoints:
- web
- websecure

envRefs:
common:
Expand Down Expand Up @@ -59,6 +62,14 @@ instances:
targetPort: 80
protocol: TCP
portName: portname
ingress:
traefikEntrypoints:
- web
# if you need route for one host with no middlewares and using default service - use ingress.simple
simple: "beta.example.com"
# routes let you define routes with rules and middlewares (we plan full IngressRoute support in future)
routes:
- match: Host(`test.example.com`)
initContainers:
pszemek:
imageRef: demo
Expand Down
6 changes: 6 additions & 0 deletions charts/app/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
"items": {
"type": "string"
}
},
"traefikEntrypoints": {
"type": "array"
}
},
"title": "Defaults"
Expand Down Expand Up @@ -186,6 +189,9 @@
},
"service": {
"type": "object"
},
"ingress": {
"type": "object"
}
},
"required": [
Expand Down

0 comments on commit 2aeb2f8

Please sign in to comment.