Skip to content

Commit

Permalink
Merge pull request #4 from WyriHaximusNet/add-readmes
Browse files Browse the repository at this point in the history
Add readme's and some changes to make the redirect chart simple
  • Loading branch information
WyriHaximus authored Apr 12, 2020
2 parents 9cb6080 + db4442e commit 0d76eb9
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 16 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# WyriHaximus.net Helm charts

Opinionated helm chats for my personal projects, and OSS Projects that either don't have public helm charts, and don't meet my requirements for them.

## Charts in this repository

* [`redirect`](https://hub.helm.sh/charts/wyrihaximusnet/redirect)

2 changes: 1 addition & 1 deletion charts/redirect/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 0.0.4
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
Expand Down
49 changes: 49 additions & 0 deletions charts/redirect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Redirect

Opinionated helm chart for [`wyrihaximusnet/redirect`](https://github.com/wyrihaximusnet/docker-redirect).

## Provided tags

* `random` - Each time when the images are build a random image is selected and build.
* `reactphp` - Using [ReactPHP](https://reactphp.org/)
* `nodejs` - Using [NodeJS](https://nodejs.org/en/)

## Configuration

These images comes with 3 mandatory configuration options:
* `redirect.defaultFallbackTarget` - Requests not matching other rules will be redirected here
* `redirect.buildin` - Can be either `nonWwwToWww` or `wwwToNonWww`, anything else will make the image error and stop

There is also one optional configuration option for custom hostname based redirection:
* `redirect.hosts` - from -> to based key value mapping

While the Docker image doesn't care, for the helm chart you also have to supply all the `redirect.ingressHosts` you
intend to be handled by this chart.

Full configuration example:

```yaml
redirect:
# The default fallback is use in case the application can't find a domain to redirect to within the other configuration options
defaultFallbackTarget: https://www.wyrihaximus.net/
buildin: wwwToNonWww
hosts:
www.ceesjankiewiet.nl: wyrihaximus.net
ingressHosts:
- www.wyrihaximus.net
```
Keep in mind that the configuration options are executed in the following order:
1. `redirect.hosts`
2. `redirect.buildin`
3. `redirect.defaultFallbackTarget`

## Opinionated decisions

* Ports are hardcoded to `7132` for the service, and `7133` for the metrics.
* TLS is assumed to be required, and is set up based on supplied hosts in `redirect.hosts` and `redirect.ingressHosts`.
* It's assumed that this helm chart will be run in it's own namespace, so the naming for all resources is kept as simple as possible.
* Prometheus export annotations are added for metric scraping.
* The default tag is random to randomly cycle through the different implementations, here is the [why](https://github.com/WyriHaximusNet/docker-redirect#why).
* Comes with a pod

6 changes: 3 additions & 3 deletions charts/redirect/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: {{ .Values.service.metricsPort | quote}}
prometheus.io/port: "7133"
labels:
app: {{ include ".helm.fullname" . }}
release: {{ include ".helm.fullname" . }}
Expand All @@ -38,10 +38,10 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
containerPort: 7132
protocol: TCP
- name: http-metrics
containerPort: {{ .Values.service.metricsPort }}
containerPort: 7133
protocol: TCP
livenessProbe:
httpGet:
Expand Down
2 changes: 2 additions & 0 deletions charts/redirect/templates/grafana-influxdb-dashboard.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.grafana.influxdb -}}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down Expand Up @@ -193,3 +194,4 @@ data:
"uid": "Tcemi9yZz",
"version": 1
}
{{ end }}
5 changes: 2 additions & 3 deletions charts/redirect/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- $fullName := include ".helm.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- $hosts := .Values.redirect.hosts -}}
{{- $ingressHosts := .Values.redirect.ingressHosts -}}
apiVersion: networking.k8s.io/v1beta1
Expand Down Expand Up @@ -31,14 +30,14 @@ spec:
rules:
{{- if $hosts -}}
{{- range $hostFrom, $hostTo := $hosts }}
{{- $host := dict "Host" $hostFrom "FullName" $fullName "SvcPort" $svcPort -}}
{{- $host := dict "Host" $hostFrom "FullName" $fullName "SvcPort" 7132 -}}
{{ include ".helm.hostRule" $host | nindent 4 }}
{{- end }}
{{- end }}
{{- if $ingressHosts -}}
{{- range $host := $ingressHosts }}
{{- if eq (hasKey $hosts $host) false -}}
{{- $host := dict "Host" $host "FullName" $fullName "SvcPort" $svcPort -}}
{{- $host := dict "Host" $host "FullName" $fullName "SvcPort" 7132 -}}
{{ include ".helm.hostRule" $host | nindent 4 }}
{{- end }}
{{- end }}
Expand Down
4 changes: 3 additions & 1 deletion charts/redirect/templates/pod-disruption-budget.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if gt (.Values.replicaCount | int) 1 -}}
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
Expand All @@ -7,4 +8,5 @@ spec:
selector:
matchLabels:
app: {{ include ".helm.fullname" . }}
release: {{ include ".helm.fullname" . }}
release: {{ include ".helm.fullname" . }}
{{ end }}
8 changes: 4 additions & 4 deletions charts/redirect/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ metadata:
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
- port: 7132
targetPort: 7132
protocol: TCP
name: http
- port: {{ .Values.service.metricsPort }}
targetPort: {{ .Values.service.metricsPort }}
- port: 7133
targetPort: 7133
protocol: TCP
name: http-metrics
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ spec:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include ".helm.fullname" . }}:{{ .Values.service.metricsPort }}']
args: ['{{ include ".helm.fullname" . }}:7133']
restartPolicy: Never
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ spec:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include ".helm.fullname" . }}:{{ .Values.service.port }}']
args: ['{{ include ".helm.fullname" . }}:7132']
restartPolicy: Never
5 changes: 3 additions & 2 deletions charts/redirect/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ redirect:
ingressHosts:
- www.wyrihaximus.net

grafana:
influxdb: false

replicaCount: 2

# Available tags: https://github.com/wyrihaximusnet/docker-redirect#provided-tags
Expand Down Expand Up @@ -45,8 +48,6 @@ securityContext: {}

service:
type: ClusterIP
port: 7132
metricsPort: 7133

ingress:
annotations:
Expand Down

0 comments on commit 0d76eb9

Please sign in to comment.