Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(socal-tunneller): set localPort to bind #20

Merged
merged 2 commits into from
Aug 14, 2023
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
2 changes: 1 addition & 1 deletion charts/socat-tunneller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
appVersion: "1.0"
description: A Helm chart for socat-tunneller
name: socat-tunneller
version: 0.1.5
version: 0.2.0
home: http://www.dest-unreach.org/socat/
maintainers:
- name: plumdog
Expand Down
2 changes: 1 addition & 1 deletion charts/socat-tunneller/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Connect to the target by using kubectl port-forward to forward one of your local ports to a tunneller pod's port {{ .Values.tunnel.port }}, or to the service using svc/{{ include "tunneller.fullname" . }}.
Connect to the target by using kubectl port-forward to forward one of your local ports to a tunneller pod's port {{ include "tunneller.localPort" . }}, or to the service using svc/{{ include "tunneller.fullname" . }}.
11 changes: 11 additions & 0 deletions charts/socat-tunneller/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ Create chart name and version as used by the chart label.
{{- define "tunneller.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Define local port to bind.
*/}}
{{- define "tunneller.localPort" -}}
{{- if .Values.tunnel.localPort -}}
{{- .Values.tunnel.localPort -}}
{{- else -}}
{{- .Values.tunnel.port -}}
{{- end -}}
{{- end -}}
6 changes: 4 additions & 2 deletions charts/socat-tunneller/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ spec:
command:
- socat
args:
- "TCP-LISTEN:$(TUNNEL_PORT),fork"
- "TCP-LISTEN:$(TUNNEL_LOCAL_PORT),fork"
- "TCP:$(TUNNEL_HOST):$(TUNNEL_PORT)"
env:
- name: TUNNEL_LOCAL_PORT
value: {{ include "tunneller.localPort" . | quote }}
- name: TUNNEL_HOST
value: {{ required "Must specify a target host for the tunnel." .Values.tunnel.host | quote }}
- name: TUNNEL_PORT
value: {{ required "Must specify a target port for the tunnel." .Values.tunnel.port | quote }}
ports:
- name: tunnel-port
containerPort: {{ (int64 .Values.tunnel.port) }}
containerPort: {{ include "tunneller.localPort" . }}
protocol: TCP
resources:
{{ toYaml .Values.resources | indent 12 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/socat-tunneller/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.tunnel.port }}
- port: {{ include "tunneller.localPort" . }}
targetPort: tunnel-port
protocol: TCP
name: tunnel-port
Expand Down
3 changes: 2 additions & 1 deletion charts/socat-tunneller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ replicaCount: 1

image:
repository: alpine/socat
tag: 1.0.5
tag: 1.7.4.4
pullPolicy: IfNotPresent

nameOverride: ""
Expand All @@ -24,3 +24,4 @@ podAnnotations: {}
tunnel:
host: myhost
port: 9999
localPort: null
Loading