Skip to content

Commit ff5348b

Browse files
authored
Merge pull request #155 from guillomep/allow_disable_port_svc
Allow to disable port on services.
2 parents 9c3db29 + 5b989e3 commit ff5348b

File tree

8 files changed

+75
-2
lines changed

8 files changed

+75
-2
lines changed

.bin/disableLdapPort.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
logLevel: debug
2+
resources:
3+
limits:
4+
cpu: "128m"
5+
memory: "64Mi"
6+
replicaCount: 3
7+
customLdifFiles:
8+
00-root.ldif: |-
9+
# Root creation
10+
dn: dc=example,dc=org
11+
objectClass: dcObject
12+
objectClass: organization
13+
o: Example, Inc
14+
service:
15+
enableLdapPort: false
16+
sslLdapPortNodePort: 30636
17+
type: NodePort
18+
initTLSSecret:
19+
tls_enabled: true
20+
image:
21+
registry: docker.io
22+
repository: alpine/openssl
23+
tag: latest
24+
pullPolicy: IfNotPresent
25+
secret: "custom-cert"

.bin/simpleUser.ldif

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
dn: cn=Jean Dupond,dc=example,dc=org
2+
cn: Jean Dupond
3+
gidnumber: 500
4+
givenname: Jean
5+
homedirectory: /home/users/jdupond
6+
objectclass: inetOrgPerson
7+
objectclass: posixAccount
8+
objectclass: top
9+
sn: Dupond
10+
uid: jdupond
11+
uidnumber: 1000
12+
userpassword: {MD5}KOULhzfBhPTq9k7a9XfCGw==

.github/workflows/ci.yml

+18
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,24 @@ jobs:
105105
LDAPTLS_REQCERT=never ldapsearch -x -D 'cn=admin,dc=singlenode,dc=org' -w Not@SecurePassw0rd -H ldaps://localhost:30636 -b 'dc=singlenode,dc=org' > /tmp/test-single-node.txt
106106
cat /tmp/test-single-node.txt
107107
if [ $(grep "numResponses" /tmp/test-single-node.txt | cut -d ":" -f 2 | tr -d ' ') -ne 6 ]; then exit 1 ; fi
108+
- name: deploy openldap-stack-ha-disable-ldap-port
109+
shell: bash
110+
run: |
111+
helm delete -n single openldap-stack-ha
112+
cd "$GITHUB_WORKSPACE"
113+
helm install openldap-stack-ha -n no-ldap-port --create-namespace -f .bin/disableLdapPort.yaml .
114+
kubectl -n no-ldap-port create secret generic custom-cert --from-file=./tls.crt --from-file=./tls.key --from-file=./ca.crt
115+
kubectl -n no-ldap-port rollout status sts openldap-stack-ha -n no-ldap-port
116+
- name: verify no ldap port deployment
117+
shell: bash
118+
run: |
119+
echo "test access to openldap database"
120+
sudo apt-get install -y ldap-utils
121+
echo "Write test to openldap database"
122+
LDAPTLS_REQCERT=never ldapadd -x -D 'cn=admin,dc=example,dc=org' -w Not@SecurePassw0rd -H ldaps://localhost:30636 -f .bin/simpleUser.ldif
123+
LDAPTLS_REQCERT=never ldapsearch -o nettimeout=20 -x -D 'cn=admin,dc=example,dc=org' -w Not@SecurePassw0rd -H ldaps://localhost:30636 -b 'dc=example,dc=org' > /tmp/test-write.txt
124+
cat /tmp/test-write.txt
125+
if [ $(grep "numResponses" /tmp/test-write.txt | cut -d ":" -f 2 | tr -d ' ') -ne 3 ]; then exit 1 ; fi
108126
109127
110128

Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- bitnami-common
1414
version: ~2
1515
home: https://www.openldap.org
16-
version: 4.2.2
16+
version: 4.2.3
1717
appVersion: 2.6.6
1818
description: Community developed LDAP software
1919
icon: https://raw.githubusercontent.com/jp-gouin/helm-openldap/master/logo.png

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ Parameters related to Kubernetes.
125125
| `extraDeploy` | extraDeploy Array of extra objects to deploy with the release | `""` |
126126
| `service.annotations` | Annotations to add to the service | `{}` |
127127
| `service.externalIPs` | Service external IP addresses | `[]` |
128+
| `service.enableLdapPort` | Enable LDAP port on the service and headless service | `true` |
129+
| `service.enableSslLdapPort` | Enable SSL LDAP port on the service and headless service | `true` |
128130
| `service.ldapPortNodePort` | Nodeport of External service port for LDAP if service.type is NodePort | `nil` |
129131
| `service.loadBalancerIP` | IP address to assign to load balancer (if supported) | `""` |
130132
| `service.loadBalancerSourceRanges` | List of IP CIDRs allowed access to load balancer (if supported) | `[]` |

templates/service.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ spec:
2424
loadBalancerSourceRanges: {{ toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
2525
{{- end }}
2626
ports:
27+
{{- if .Values.service.enableLdapPort }}
2728
- name: ldap-port
2829
protocol: TCP
2930
port: {{ .Values.global.ldapPort }}
@@ -33,6 +34,8 @@ spec:
3334
{{- else if eq .Values.service.type "ClusterIP" }}
3435
nodePort: null
3536
{{- end }}
37+
{{- end }}
38+
{{- if .Values.service.enableSslLdapPort }}
3639
- name: ssl-ldap-port
3740
protocol: TCP
3841
port: {{ .Values.global.sslLdapPort }}
@@ -42,6 +45,7 @@ spec:
4245
{{- else if eq .Values.service.type "ClusterIP" }}
4346
nodePort: null
4447
{{- end }}
48+
{{- end }}
4549
sessionAffinity: {{ .Values.service.sessionAffinity }}
4650
selector:
4751
app.kubernetes.io/component: {{ template "openldap.fullname" . }}

templates/svc-headless.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@ metadata:
99
heritage: {{ .Release.Service }}
1010
spec:
1111
ports:
12+
{{- if .Values.service.enableLdapPort }}
1213
- port: {{ .Values.global.ldapPort }}
1314
name: ldap-port
1415
targetPort: ldap-port
16+
{{- end }}
17+
{{- if .Values.service.enableSslLdapPort }}
18+
- port: {{ .Values.global.sslLdapPort }}
19+
name: ssl-ldap-port
20+
targetPort: ssl-ldap-port
21+
{{- end }}
1522
clusterIP: None
1623
selector:
1724
app.kubernetes.io/component: {{ template "openldap.fullname" . }}
1825
release: {{ .Release.Name }}
1926
type: ClusterIP
20-
sessionAffinity: None
27+
sessionAffinity: None

values.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ service:
7979
## If service type NodePort, define the value here
8080
#ldapPortNodePort:
8181
#sslLdapPortNodePort:
82+
83+
# Disable if you do not want to expose port on service
84+
enableLdapPort: true
85+
enableSslLdapPort: true
86+
8287
## List of IP addresses at which the service is available
8388
## Ref: https://kubernetes.io/docs/user-guide/services/#external-ips
8489
##

0 commit comments

Comments
 (0)