diff --git a/README.md b/README.md index d71e3e2..5975ef9 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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) diff --git a/charts/app/Chart.yaml b/charts/app/Chart.yaml index 146be64..16b7e55 100644 --- a/charts/app/Chart.yaml +++ b/charts/app/Chart.yaml @@ -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 diff --git a/charts/app/templates/_ingressroute.tpl b/charts/app/templates/_ingressroute.tpl new file mode 100644 index 0000000..295cc1b --- /dev/null +++ b/charts/app/templates/_ingressroute.tpl @@ -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 }} diff --git a/charts/app/templates/ingress.yaml b/charts/app/templates/ingress.yaml new file mode 100644 index 0000000..72cd7a7 --- /dev/null +++ b/charts/app/templates/ingress.yaml @@ -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 }} diff --git a/charts/app/values-example.yaml b/charts/app/values-example.yaml index d9059ff..4c9570b 100644 --- a/charts/app/values-example.yaml +++ b/charts/app/values-example.yaml @@ -4,6 +4,9 @@ global: defaults: imagePullSecrets: - "oci-kodzik" + traefikEntrypoints: + - web + - websecure envRefs: common: @@ -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 diff --git a/charts/app/values.schema.json b/charts/app/values.schema.json index 53bb8d5..3ac84c8 100644 --- a/charts/app/values.schema.json +++ b/charts/app/values.schema.json @@ -87,6 +87,9 @@ "items": { "type": "string" } + }, + "traefikEntrypoints": { + "type": "array" } }, "title": "Defaults" @@ -186,6 +189,9 @@ }, "service": { "type": "object" + }, + "ingress": { + "type": "object" } }, "required": [