Skip to content

Commit

Permalink
Merge pull request #220 from devtron-labs/haproxy-ingress
Browse files Browse the repository at this point in the history
feat: Added haproxy-ingress
  • Loading branch information
prakarsh-dt authored Apr 29, 2024
2 parents 3e94d85 + 9de4d92 commit 2c27705
Show file tree
Hide file tree
Showing 33 changed files with 2,310 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/jcmhproxy-ingress/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
10 changes: 10 additions & 0 deletions charts/jcmhproxy-ingress/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v2
appVersion: v0.14.6
description: Ingress controller for HAProxy loadbalancer
icon: https://haproxy-ingress.github.io/favicons/favicon-256.png
keywords:
- haproxy
- ingress
name: jcmhproxy-ingress
type: application
version: 0.14.6
277 changes: 277 additions & 0 deletions charts/jcmhproxy-ingress/README.md

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions charts/jcmhproxy-ingress/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
HAProxy Ingress has been installed!

{{- if contains "NodePort" .Values.controller.service.type }}

HAProxy is exposed as a `NodePort` type service.
Get the application URL by running these commands:

export HTTP_NODE_PORT=$(kubectl --namespace {{ .Release.Namespace }} get services -o jsonpath="{.spec.ports[0].nodePort}" {{ include "haproxy-ingress.fullname" . }})
export HTTPS_NODE_PORT=$(kubectl --namespace {{ .Release.Namespace }} get services -o jsonpath="{.spec.ports[1].nodePort}" {{ include "haproxy-ingress.fullname" . }})
export NODE_IP=$(kubectl --namespace {{ .Release.Namespace }} get nodes -o jsonpath="{.items[0].status.addresses[1].address}")

echo "Visit http://$NODE_IP:$HTTP_NODE_PORT to access your application via HTTP."
echo "Visit https://$NODE_IP:$HTTPS_NODE_PORT to access your application via HTTPS."

{{- else if contains "LoadBalancer" .Values.controller.service.type }}

HAProxy is exposed as a `LoadBalancer` type service.
It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status by running:

kubectl --namespace {{ .Release.Namespace }} get services {{ include "haproxy-ingress.fullname" . }} -o wide -w

{{- else if contains "ClusterIP" .Values.controller.service.type }}

HAProxy is exposed as a `ClusterIP` type service.
Get the application URL by running these commands:

export POD_NAME=$(kubectl --namespace {{ .Release.Namespace }} get pods -o jsonpath="{.items[0].metadata.name}" -l "app={{ include "haproxy-ingress.name" . }},component={{ .Values.controller.name }},release={{ .Release.Name }}")
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
echo "Visit http://127.0.0.1:8080 to access your application."

{{- end }}
107 changes: 107 additions & 0 deletions charts/jcmhproxy-ingress/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{{/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Name (defaults to "haproxy-ingress") and a fully qualified name
* (defaults to "<release>-haproxy-ingress") of controller and a variant with `.Values.defaultBackend.name`
* for the default backend.
*
* We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
* If release name contains the chart name, it will be used as a full name.
*
*/}}
{{- define "haproxy-ingress.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "haproxy-ingress.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{- define "haproxy-ingress.defaultBackend.name" -}}
{{- printf "%s-%s" .Chart.Name .Values.defaultBackend.name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "haproxy-ingress.defaultBackend.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- printf "%s-%s" .Release.Name .Values.defaultBackend.name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s-%s" .Release.Name $name .Values.defaultBackend.name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}


{{/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Common and selector labels
*
* We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*
*/}}
{{- define "haproxy-ingress.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "haproxy-ingress.labels" -}}
helm.sh/chart: {{ include "haproxy-ingress.chart" . }}
{{ include "haproxy-ingress.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{- define "haproxy-ingress.selectorLabels" -}}
app.kubernetes.io/name: {{ include "haproxy-ingress.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "haproxy-ingress.defaultBackend.labels" -}}
helm.sh/chart: {{ include "haproxy-ingress.chart" . }}
{{ include "haproxy-ingress.defaultBackend.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{- define "haproxy-ingress.defaultBackend.selectorLabels" -}}
app.kubernetes.io/name: {{ include "haproxy-ingress.defaultBackend.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Create the name of the service account to use
*
*/}}
{{- define "haproxy-ingress.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "haproxy-ingress.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}


{{/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Construct the path for publish-service
*
*/}}
{{- define "haproxy-ingress.controller.publishServicePath" -}}
{{- if .Values.controller.publishService.pathOverride }}
{{- .Values.controller.publishService.pathOverride | trimSuffix "-" }}
{{- else }}
{{- printf "%s/%s" "$(POD_NAMESPACE)" (include "haproxy-ingress.fullname" .) | trimSuffix "-" }}
{{- end }}
{{- end }}
Loading

0 comments on commit 2c27705

Please sign in to comment.