-
Notifications
You must be signed in to change notification settings - Fork 122
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
#171 - Allow setting up read only replicas #174
Merged
jp-gouin
merged 24 commits into
jp-gouin:master
from
davidfrickert:feat/add-readonly-replicas
Oct 9, 2024
Merged
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
329ec14
split LDAP_EXTRA_SCHEMAS from main configmap
davidfrickert e31a2a0
support creating a read only replica statefulset
davidfrickert a790f75
separate values for read only services from normal service
davidfrickert 389e1cf
splitenable ldap port values
davidfrickert 95f06a7
WIP: Write test that verifies readonly replica
davidfrickert d0dc984
Code review fixes
davidfrickert 44c8ae9
ci - call readonly job
davidfrickert 26156ba
need to load custom ldif for test to work as expected
davidfrickert 2a410cd
use 0 read only replicas as the default
davidfrickert 9740e50
add kind ports for read only ldap tests
davidfrickert 4fe875e
changes in replication to support readonly replica
davidfrickert 685cba1
CI readonly test fix
davidfrickert a8f0e11
save current readlonly strategy
jp-gouin b3c79d4
commit some changes that were uncommitted for readonly functionality
davidfrickert d1c380c
add read-only replica
jp-gouin f3fa7ea
add read-only replica
jp-gouin 0ba2528
merge helper
jp-gouin baee6c9
merge helper
jp-gouin 8567aaf
fix ci
jp-gouin 7bb4a28
fix load of schema
jp-gouin cff4c66
fix mount custom schema
jp-gouin ae47cb4
allow read only to load custom schema during startup
jp-gouin 02187ad
resolve conflicts
jp-gouin 3f666e5
Merge branch 'master' into feat/add-readonly-replicas
jp-gouin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
persistence: | ||
accessModes: | ||
- ReadWriteOnce | ||
enabled: true | ||
size: 1Gi | ||
ltb-passwd: | ||
enabled : false | ||
phpldapadmin: | ||
enabled: false | ||
replicaCount: 3 | ||
readOnlyReplicaCount: 1 | ||
replication: | ||
clusterName: cluster.local | ||
enabled: true | ||
interval: "00:00:00:10" | ||
retry: 60 | ||
starttls: critical | ||
timeout: 1 | ||
tls_reqcert: never | ||
initTLSSecret: | ||
tls_enabled: true | ||
secret: "custom-cert" | ||
service: | ||
ldapPortNodePort: 30389 | ||
sslLdapPortNodePort: 30636 | ||
type: NodePort | ||
serviceReadOnly: | ||
ldapPortNodePort: 31389 | ||
sslLdapPortNodePort: 31636 | ||
type: NodePort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# WIP! | ||
name: Test readonly replica | ||
on: | ||
workflow_call: | ||
jobs: | ||
qualif: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v1 | ||
- name: Run custom action | ||
# Use the location in the repository (without action.yml) | ||
uses: ./.github/actions/setup | ||
with: | ||
install-chaos: false | ||
- name: setup certs | ||
shell: bash | ||
run: | | ||
openssl req -x509 -newkey rsa:4096 -nodes -subj '/CN=example.com' -keyout tls.key -out tls.crt -days 365 | ||
cp tls.crt ca.crt | ||
kubectl create secret generic custom-cert --from-file=./tls.crt --from-file=./tls.key --from-file=./ca.crt | ||
- name: deploy openldap-stack-ha | ||
shell: bash | ||
run: | | ||
cd "$GITHUB_WORKSPACE" | ||
helm install openldap-stack-ha -f .bin/readonly.yaml . | ||
kubectl rollout status sts openldap-stack-ha | ||
- name: verify deployment | ||
shell: bash | ||
run: | | ||
echo "test access to openldap database" | ||
sleep 10 | ||
LDAPTLS_REQCERT=never ldapsearch -x -D 'cn=admin,dc=example,dc=org' -w Not@SecurePassw0rd -H ldaps://localhost:30636 -b 'dc=example,dc=org' | ||
- name: verify certs | ||
shell: bash | ||
run: | | ||
echo "verify certificate" | ||
echo | openssl s_client -showcerts -servername example.com -connect localhost:30636 2>/dev/null | openssl x509 -inform pem -noout -text > /tmp/test-cert.txt | ||
if ! grep -q "CN = example.com" /tmp/test-cert.txt; then echo exit 1; fi | ||
- name: test write on main cluster | ||
shell: bash | ||
run: | | ||
echo "Write test to openldap database" | ||
LDAPTLS_REQCERT=never ldapadd -x -D 'cn=admin,dc=example,dc=org' -w Not@SecurePassw0rd -H ldaps://localhost:30636 -f .bin/user.ldif | ||
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 | ||
if ! grep "Einstein" /tmp/test-write.txt; then echo 'no Einstein entry found' ; fi | ||
if ! grep "objectClass: ownCloud" /tmp/test-write.txt; then echo 'no ownCloud entry found'; fi | ||
- name: test memberOf on main cluster | ||
shell: bash | ||
run: | | ||
echo "MemberOf test to openldap database" | ||
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' "(memberOf=cn=testgroup,ou=Group,dc=example,dc=org)" > /tmp/test-write.txt | ||
if [ $(grep "numResponses" /tmp/test-write.txt | cut -d ":" -f 2 | tr -d ' ') -ne 2 ]; then exit 1 ; fi | ||
if ! grep -q "uid=test1,ou=People,dc=example,dc=org" /tmp/test-write.txt; then echo exit 1; fi | ||
- name: test write on readonly replica | ||
run: | | ||
echo "Write test to openldap readonly replica" | ||
LDAPTLS_REQCERT=never ldapadd -x -D 'cn=admin,dc=example,dc=org' -w Not@SecurePassw0rd -H ldaps://localhost:31636 -f .bin/user.ldif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{- if (gt (.Values.readOnlyReplicaCount | int) 0) }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "openldap.fullname" . }}-readonly | ||
labels: | ||
app: {{ template "openldap.name" . }} | ||
chart: {{ template "openldap.chart" . }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
{{- if .Values.extraLabels }} | ||
{{ toYaml .Values.extraLabels | indent 4 }} | ||
{{- end }} | ||
data: | ||
# replication | ||
readonly.ldif: | | ||
dn: olcDatabase={2}mdb,cn=config | ||
olcReadonly: TRUE | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{{- if (gt (.Values.readOnlyReplicaCount | int) 0) }} | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
{{- if .Values.serviceReadOnly.annotations }} | ||
annotations: | ||
{{ toYaml .Values.serviceReadOnly.annotations | indent 4 }} | ||
{{- end }} | ||
name: {{ template "openldap.fullname" . }}-readonly | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
app.kubernetes.io/component: {{ template "openldap.fullname" . }} | ||
chart: {{ template "openldap.chart" . }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
{{- if .Values.extraLabels }} | ||
{{ toYaml .Values.extraLabels | indent 4 }} | ||
{{- end }} | ||
spec: | ||
type: {{ .Values.serviceReadOnly.type }} | ||
{{- if and (eq .Values.serviceReadOnly.type "LoadBalancer") .Values.serviceReadOnly.loadBalancerIP }} | ||
loadBalancerIP: {{ .Values.serviceReadOnly.loadBalancerIP }} | ||
{{- end }} | ||
{{- if and (eq .Values.serviceReadOnly.type "LoadBalancer") .Values.serviceReadOnly.loadBalancerSourceRanges }} | ||
loadBalancerSourceRanges: {{ toYaml .Values.serviceReadOnly.loadBalancerSourceRanges | nindent 4 }} | ||
{{- end }} | ||
{{- if and (eq .Values.serviceReadOnly.type "ClusterIP") .Values.serviceReadOnly.clusterIP }} | ||
clusterIP: {{ .Values.serviceReadOnly.clusterIP }} | ||
{{- end }} | ||
ports: | ||
{{- if .Values.serviceReadOnly.enableLdapPort }} | ||
- name: ldap-port | ||
protocol: TCP | ||
port: {{ .Values.global.ldapPort }} | ||
targetPort: ldap-port | ||
{{- if and (or (eq .Values.serviceReadOnly.type "NodePort") (eq .Values.serviceReadOnly.type "LoadBalancer")) (not (empty .Values.serviceReadOnly.ldapPortNodePort)) }} | ||
nodePort: {{ .Values.serviceReadOnly.ldapPortNodePort }} | ||
{{- else if eq .Values.serviceReadOnly.type "ClusterIP" }} | ||
nodePort: null | ||
{{- end }} | ||
{{- end }} | ||
{{- if .Values.serviceReadOnly.enableSslLdapPort }} | ||
- name: ssl-ldap-port | ||
protocol: TCP | ||
port: {{ .Values.global.sslLdapPort }} | ||
targetPort: ssl-ldap-port | ||
{{- if and (or (eq .Values.serviceReadOnly.type "NodePort") (eq .Values.serviceReadOnly.type "LoadBalancer")) (not (empty .Values.serviceReadOnly.sslLdapPortNodePort)) }} | ||
nodePort: {{ .Values.serviceReadOnly.sslLdapPortNodePort }} | ||
{{- else if eq .Values.serviceReadOnly.type "ClusterIP" }} | ||
nodePort: null | ||
{{- end }} | ||
{{- end }} | ||
sessionAffinity: {{ .Values.service.sessionAffinity }} | ||
selector: | ||
app.kubernetes.io/component: {{ template "openldap.fullname" . }}-readonly | ||
release: {{ .Release.Name }} | ||
{{- end }} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to update .bin/kind-conf.yml to include the 2 new ports :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, thanks for the tip