Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on:
pull_request:
push:
branches:
- main

jobs:
render:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: 'false'

- name: Install Helm
uses: azure/setup-helm@v5

- name: Lint chart
run: helm lint charts/restinthemiddle --set config.targetHostDsn=http://example.com

- name: Render chart with value combinations
run: |
set -euo pipefail
BASE="--set config.targetHostDsn=http://example.com"
render() {
echo "=== helm template $* ==="
# shellcheck disable=SC2086
helm template ci charts/restinthemiddle $BASE "$@" > /dev/null
}
render
render --set ingress.enabled=true
render --set ingress.enabled=true --set ingress.className=nginx
render --set autoscaling.enabled=true
render --set service.type=NodePort
render --set service.type=LoadBalancer
render --set serviceAccount.create=true
render --set service.portOverride=80
render --set ingress.enabled=true --set autoscaling.enabled=true --set serviceAccount.create=true
2 changes: 2 additions & 0 deletions charts/restinthemiddle/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ name: restinthemiddle
description: Deploy the HTTP logging proxy with ease
type: application
version: 1.1.10
# autoscaling/v2 requires Kubernetes >= 1.23
kubeVersion: ">=1.23.0-0"
6 changes: 4 additions & 2 deletions charts/restinthemiddle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

Deploy the HTTP logging proxy with ease

## Requirements

Kubernetes: `>=1.23.0-0`

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| applicationName | string | `"restinthemiddle"` | |
| autoscaling.enabled | bool | `false` | Handle with care! Autoscaling will make sense only if you have centralized logging. |
| autoscaling.maxReplicas | int | `2` | |
| autoscaling.minReplicas | int | `1` | |
Expand Down Expand Up @@ -43,7 +46,6 @@ Deploy the HTTP logging proxy with ease
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| ingress.tls | list | `[]` | |
| nameOverride | string | `""` | |
| namespace | string | `"default"` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podLabels | object | `{}` | |
Expand Down
4 changes: 2 additions & 2 deletions charts/restinthemiddle/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "restinthemiddle.fullname" . }}'
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "restinthemiddle.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "restinthemiddle.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
echo http://$SERVICE_IP:{{ .Values.service.portOverride | default .Values.config.listenPort }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "restinthemiddle.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
Expand Down
6 changes: 4 additions & 2 deletions charts/restinthemiddle/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
Create the name of the service account to use.
Empty when no service account is created and none is named, so the
pod falls back to the namespace default implicitly.
*/}}
{{- define "restinthemiddle.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "restinthemiddle.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- .Values.serviceAccount.name }}
{{- end }}
{{- end }}
3 changes: 0 additions & 3 deletions charts/restinthemiddle/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{{- if .Values.config -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "restinthemiddle.fullname" . }}
namespace: {{ .Release.Namespace }}
data:
config.yaml: |
{{- toYaml .Values.config | nindent 4 }}
{{- end }}
9 changes: 4 additions & 5 deletions charts/restinthemiddle/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "restinthemiddle.fullname" . }}
labels:
{{- include "restinthemiddle.labels" . | nindent 4 }}
Expand Down Expand Up @@ -29,21 +28,21 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "restinthemiddle.serviceAccountName" . }}
{{- with include "restinthemiddle.serviceAccountName" . }}
serviceAccountName: {{ . }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ template "restinthemiddle.name" . }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Values.image.tag }}"
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.config.listenPort }}
protocol: TCP
name: listen-port
# livenessProbe: {}
# readinessProbe: {}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
Expand Down
10 changes: 7 additions & 3 deletions charts/restinthemiddle/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "restinthemiddle.fullname" . }}
Expand All @@ -17,12 +17,16 @@ spec:
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
26 changes: 4 additions & 22 deletions charts/restinthemiddle/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "restinthemiddle.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- 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 -}}
{{- $svcPort := .Values.service.portOverride | default .Values.config.listenPort -}}
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: {{ $fullName }}
Expand All @@ -23,8 +12,8 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- with .Values.ingress.className }}
ingressClassName: {{ . }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
Expand All @@ -43,19 +32,12 @@ spec:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
pathType: {{ .pathType | default "ImplementationSpecific" }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
3 changes: 0 additions & 3 deletions charts/restinthemiddle/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
namespace: default
applicationName: restinthemiddle

image:
registry: docker.io
repository: jdschulze/restinthemiddle
Expand Down