Skip to content

Commit 21fed61

Browse files
+semver: patch add library mode to client chart (#17)
Add library mode to support - adds possibility to use templates as libraries in external charts. Added to support usage in codefresh-gitops-runtime chart
1 parent 7e59c02 commit 21fed61

File tree

9 files changed

+145
-109
lines changed

9 files changed

+145
-109
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{- define "codefresh-tunnel-client.resources" -}}
2+
{{- include "codefresh-tunnel-client.config" . }}
3+
---
4+
{{- include "codefresh-tunnel-client.deployment" . }}
5+
---
6+
{{- include "codefresh-tunnel-client.sa" . }}
7+
{{- end}}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{/*
2+
Config
3+
*/}}
4+
{{- define "codefresh-tunnel-client.config" -}}
5+
apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: codefresh-tunnel-client-config
9+
data:
10+
frpc.ini: |-
11+
[common]
12+
server_addr = {{ required "tunnelServer.host is required" .Values.tunnelServer.host }}
13+
server_port = {{ required "tunnelServer.port is required" .Values.tunnelServer.port }}
14+
log_level = {{ default "info" .Values.logLevel }}
15+
tls_enable = {{ default "true" .Values.tunnelServer.tls }}
16+
tls_trusted_ca_file = /etc/ssl/certs/ca-certificates.crt
17+
disable_custom_tls_first_byte = true
18+
protocol = {{ default "wss" .Values.tunnelServer.protocol }}
19+
admin_addr = 127.0.0.1
20+
admin_port = 7400
21+
admin_user = admin
22+
admin_pwd = admin
23+
[{{ required "tunnel.subdomainPrefix is required" .Values.tunnel.subdomainPrefix }}]
24+
type = {{ default "http" .Values.tunnel.forwardTo.type }}
25+
local_ip = {{ required "tunnel.forwardTo.host is required" .Values.tunnel.forwardTo.host }}
26+
local_port = {{ required "tunnel.forwardTo.port is required" .Values.tunnel.forwardTo.port }}
27+
locations = {{ default "/" .Values.tunnel.forwardTo.location }}
28+
subdomain = {{ .Values.tunnel.subdomainPrefix }}
29+
meta_Authorization = {{"{{"}} .Envs.AUTHORIZATION {{"}}"}}
30+
ips_allow_list = {{ default "" .Values.tunnel.ipsAllowList }}
31+
{{- end }}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{{/*
2+
Deployment template
3+
*/}}
4+
{{- define "codefresh-tunnel-client.deployment" -}}
5+
apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: {{ include "codefresh-tunnel-client.name" . }}
9+
labels:
10+
app: {{ include "codefresh-tunnel-client.name" .}}
11+
release: {{ .Release.Name }}
12+
annotations:
13+
checksum/config: {{ include "codefresh-tunnel-client.config" . | sha256sum }}
14+
spec:
15+
replicas: 1
16+
selector:
17+
matchLabels:
18+
{{- include "codefresh-tunnel-client.selectorLabels" . | nindent 6 }}
19+
template:
20+
metadata:
21+
{{- with .Values.podAnnotations }}
22+
annotations:
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
labels:
26+
{{- include "codefresh-tunnel-client.selectorLabels" . | nindent 8 }}
27+
spec:
28+
{{- with .Values.imagePullSecrets }}
29+
imagePullSecrets:
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
serviceAccountName: {{ include "codefresh-tunnel-client.serviceAccountName" . }}
33+
securityContext:
34+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
35+
containers:
36+
- name: tunnel-client
37+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
38+
env:
39+
- name: AUTHORIZATION
40+
valueFrom:
41+
secretKeyRef:
42+
name: {{ .Values.tunnelServer.authorization.secretKeyRef.name }}
43+
key: {{ .Values.tunnelServer.authorization.secretKeyRef.key }}
44+
optional: false
45+
{{- with .Values.env -}}
46+
{{ . | toYaml | nindent 10 }}
47+
{{- end }}
48+
imagePullPolicy: {{ .Values.image.pullPolicy }}
49+
resources:
50+
{{- toYaml .Values.resources | nindent 12 }}
51+
volumeMounts:
52+
- mountPath: /etc/frp
53+
name: client-config
54+
volumes:
55+
- name: client-config
56+
projected:
57+
sources:
58+
- configMap:
59+
name: codefresh-tunnel-client-config
60+
optional: false
61+
items:
62+
- key: frpc.ini
63+
path: frpc.ini
64+
{{- with .Values.nodeSelector }}
65+
nodeSelector:
66+
{{- toYaml . | nindent 8 }}
67+
{{- end }}
68+
{{- with .Values.affinity }}
69+
affinity:
70+
{{- toYaml . | nindent 8 }}
71+
{{- end }}
72+
{{- with .Values.tolerations }}
73+
tolerations:
74+
{{- toYaml . | nindent 8 }}
75+
{{- end }}
76+
{{- end }}

codefresh-tunnel-client/templates/_helpers.yaml renamed to codefresh-tunnel-client/templates/_libs/_helpers.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ release: {{ .Release.Name }}
2424
{{- define "codefresh-tunnel-client.labels" -}}
2525
app: {{ include "codefresh-tunnel-client.name" .}}
2626
release: {{ .Release.Name }}
27+
app.kubernetes.io/part-of: codefresh-tunnel-client
2728
{{- end }}
2829

2930
{{/*
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{- define "codefresh-tunnel-client.sa" }}
2+
{{- if .Values.serviceAccount.create -}}
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: {{ include "codefresh-tunnel-client.serviceAccountName" . }}
7+
labels:
8+
{{- include "codefresh-tunnel-client.labels" . | nindent 4 }}
9+
{{- with .Values.serviceAccount.annotations }}
10+
annotations:
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
{{- end }}
14+
{{- end }}
Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
apiVersion: v1
2-
kind: ConfigMap
3-
metadata:
4-
name: codefresh-tunnel-client-config
5-
data:
6-
frpc.ini: |-
7-
[common]
8-
server_addr = {{ required "tunnelServer.host is required" .Values.tunnelServer.host }}
9-
server_port = {{ required "tunnelServer.port is required" .Values.tunnelServer.port }}
10-
log_level = {{ default "info" .Values.logLevel }}
11-
tls_enable = {{ default "true" .Values.tunnelServer.tls }}
12-
tls_trusted_ca_file = /etc/ssl/certs/ca-certificates.crt
13-
disable_custom_tls_first_byte = true
14-
protocol = {{ default "wss" .Values.tunnelServer.protocol }}
15-
admin_addr = 127.0.0.1
16-
admin_port = 7400
17-
admin_user = admin
18-
admin_pwd = admin
19-
[{{ required "tunnel.subdomainPrefix is required" .Values.tunnel.subdomainPrefix }}]
20-
type = {{ default "http" .Values.tunnel.forwardTo.type }}
21-
local_ip = {{ required "tunnel.forwardTo.host is required" .Values.tunnel.forwardTo.host }}
22-
local_port = {{ required "tunnel.forwardTo.port is required" .Values.tunnel.forwardTo.port }}
23-
locations = {{ default "/" .Values.tunnel.forwardTo.location }}
24-
subdomain = {{ .Values.tunnel.subdomainPrefix }}
25-
meta_Authorization = {{"{{"}} .Envs.AUTHORIZATION {{"}}"}}
26-
ips_allow_list = {{ default "" .Values.tunnel.ipsAllowList }}
1+
{{- if not .Values.libraryMode }}
2+
{{- include "codefresh-tunnel-client.config" . }}
3+
{{- end }}
Lines changed: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,3 @@
1-
apiVersion: apps/v1
2-
kind: Deployment
3-
metadata:
4-
name: {{ include "codefresh-tunnel-client.name" . }}
5-
labels:
6-
app: {{ include "codefresh-tunnel-client.name" .}}
7-
release: {{ .Release.Name }}
8-
annotations:
9-
checksum/config: {{ include (print $.Template.BasePath "/client-config.yaml") . | sha256sum }}
10-
spec:
11-
replicas: 1
12-
selector:
13-
matchLabels:
14-
{{- include "codefresh-tunnel-client.selectorLabels" . | nindent 6 }}
15-
template:
16-
metadata:
17-
{{- with .Values.podAnnotations }}
18-
annotations:
19-
{{- toYaml . | nindent 8 }}
20-
{{- end }}
21-
labels:
22-
{{- include "codefresh-tunnel-client.selectorLabels" . | nindent 8 }}
23-
spec:
24-
{{- with .Values.imagePullSecrets }}
25-
imagePullSecrets:
26-
{{- toYaml . | nindent 8 }}
27-
{{- end }}
28-
serviceAccountName: {{ include "codefresh-tunnel-client.serviceAccountName" . }}
29-
securityContext:
30-
{{- toYaml .Values.podSecurityContext | nindent 8 }}
31-
containers:
32-
- name: tunnel-client
33-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
34-
env:
35-
- name: AUTHORIZATION
36-
valueFrom:
37-
secretKeyRef:
38-
name: {{ .Values.tunnelServer.authorization.secretKeyRef.name }}
39-
key: {{ .Values.tunnelServer.authorization.secretKeyRef.key }}
40-
optional: false
41-
{{- with .Values.env -}}
42-
{{ . | toYaml | nindent 10 }}
43-
{{- end }}
44-
imagePullPolicy: {{ .Values.image.pullPolicy }}
45-
resources:
46-
{{- toYaml .Values.resources | nindent 12 }}
47-
volumeMounts:
48-
- mountPath: /etc/frp
49-
name: client-config
50-
volumes:
51-
- name: client-config
52-
projected:
53-
sources:
54-
- configMap:
55-
name: codefresh-tunnel-client-config
56-
optional: false
57-
items:
58-
- key: frpc.ini
59-
path: frpc.ini
60-
{{- with .Values.nodeSelector }}
61-
nodeSelector:
62-
{{- toYaml . | nindent 8 }}
63-
{{- end }}
64-
{{- with .Values.affinity }}
65-
affinity:
66-
{{- toYaml . | nindent 8 }}
67-
{{- end }}
68-
{{- with .Values.tolerations }}
69-
tolerations:
70-
{{- toYaml . | nindent 8 }}
71-
{{- end }}
1+
{{- if not .Values.libraryMode }}
2+
{{- include "codefresh-tunnel-client.deployment" . }}
3+
{{- end }}
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
{{- if .Values.serviceAccount.create -}}
2-
apiVersion: v1
3-
kind: ServiceAccount
4-
metadata:
5-
name: {{ include "codefresh-tunnel-client.serviceAccountName" . }}
6-
labels:
7-
{{- include "codefresh-tunnel-client.labels" . | nindent 4 }}
8-
{{- with .Values.serviceAccount.annotations }}
9-
annotations:
10-
{{- toYaml . | nindent 4 }}
11-
{{- end }}
12-
{{- end }}
1+
{{- if not .Values.libraryMode }}
2+
{{- include "codefresh-tunnel-client.sa" . }}
3+
{{- end }}

codefresh-tunnel-client/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Defines if library mode is used for tunnel client. No templates are generated when using this mode.
2+
# Added to support usage in codefresh-gitops-runtime Helm chart
3+
libraryMode: false
14

25
image:
36
repository: quay.io/codefresh/frpc
@@ -24,6 +27,9 @@ tunnel:
2427
# Subdomain is defined on the sever. The client sets it's prefix. For example, if the subdomain host on server
2528
# is tunnels.example setting this value to would make the tunnel acces
2629
subdomainPrefix:
30+
# Subdomain host as defined on the server. This is not actually used in any of the templates in the client chart. Rather, this is required
31+
# in the chart that installs the runtime
32+
subdomainHost:
2733

2834
# lists the rules to configure which IP addresses and subnet masks can access your client
2935
ipsAllowList: ""
@@ -32,6 +38,7 @@ tunnel:
3238
forwardTo:
3339
type: http
3440
host: internal-router
41+
location: "/"
3542
port: 80
3643

3744

0 commit comments

Comments
 (0)