1
0
Fork 0

Add Listen Port to Ingress

This commit is contained in:
Joao Gilberto Magalhaes 2022-08-28 15:20:16 -05:00
parent b01ec6a09a
commit 72b40a3c66
5 changed files with 18 additions and 3 deletions

View file

@ -33,6 +33,8 @@ There are two ways to install EasyHAProxy in a Kubernetes cluster. You can use K
3.1. Using Kubernetes Manifest
```bash
kubectl create namespace easyhaproxy
kubectl apply -f \
https://raw.githubusercontent.com/haproxytech/kubernetes-ingress/master/deploy/haproxy-ingress-daemonset.yaml
```
@ -45,7 +47,7 @@ Minimal configuration
```bash
helm repo add byjg https://opensource.byjg.com/helm
helm repo update
helm repo update byjg
kubectl create namespace easyhaproxy
helm upgrade --install ingress byjg/easyhaproxy \
--namespace easyhaproxy \
@ -68,6 +70,8 @@ easyhaproxy:
easyhaproxy: DEBUG
haproxy: DEBUG
listen_extra_ports: []
# Make sure to create this
masterNode:
label: easyhaproxy/node
@ -120,6 +124,7 @@ Caveats:
| easyhaproxy.letsencrypt | (optional) Boolean. It will request letsencript certificates for the ingresses domains. | false | true or false
| easyhaproxy.redirect | (optional) Json. Specific a domain and its destination. | *empty* | {"domain":"redirect_url"}
| easyhaproxy.mode | (optional) Set the HTTP mode for that connection. | http | http or tcp
| easyhaproxy.listen_port | (optional) Set the an additional port for that ingress | http | http or tcp
**Important**: The annotations are per ingress and applied to all hosts in that ingress configuration.

View file

@ -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.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.1.1
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to

View file

@ -43,6 +43,11 @@ spec:
- name: stats
containerPort: 1936
hostPort: 1936
{{ range .Values.listen_extra_ports }}
- name: extra_{{ . }}
containerPort: {{ . }}
hostPort: {{ . }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:

View file

@ -58,6 +58,8 @@ easyhaproxy:
easyhaproxy: DEBUG
haproxy: DEBUG
listen_extra_ports: []
# Make sure to create this
masterNode:
label: easyhaproxy/node

View file

@ -158,6 +158,9 @@ class Kubernetes(ProcessorInterface):
redirect_ssl = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.redirect_ssl")
redirect = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.redirect")
mode = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.mode")
listen_port = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.listen_port")
if listen_port is None:
listen_port = 80
data = {}
data["creation_timestamp"] = ingress.metadata.creation_timestamp.strftime("%x %X")
@ -191,7 +194,7 @@ class Kubernetes(ProcessorInterface):
port_number = rule.http.paths[0].backend.service.port.number
definition = "easyhaproxy.%s_%s" % (rule.host.replace(".", "-"), port_number)
rule_data["%s.host" % (definition)] = rule.host
rule_data["%s.port" % (definition)] = "80"
rule_data["%s.port" % (definition)] = listen_port
rule_data["%s.localport" % (definition)] = port_number
if rule.host in ssl_hosts:
rule_data["%s.clone_to_ssl" % (definition)] = 'true'