Skip to content

Commit beac331

Browse files
committed
add github action for PR and push to master for jp-gouin#22, update custom certs -> ca.crt need to be added otherwise the chart will fail. Add PR template and check on semantic
1 parent 50ad33b commit beac331

12 files changed

+370
-8
lines changed

Diff for: .bin/argo-chaos-cr.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: argo-chaos
5+
rules:
6+
- apiGroups:
7+
- "apps"
8+
resources:
9+
- pods
10+
- statefulsets
11+
- deployments
12+
verbs:
13+
- get
14+
- list
15+
- watch
16+
- patch
17+
- apiGroups:
18+
- chaos-mesh.org
19+
resources:
20+
- '*'
21+
verbs:
22+
- '*'
23+

Diff for: .bin/argo-default-rbac.yaml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# give our webhook ap (as default:default) permissions to create workflows
2+
---
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
kind: Role
5+
metadata:
6+
name: argo-invocation
7+
namespace: argo
8+
rules:
9+
- apiGroups:
10+
- ""
11+
resources:
12+
- pods
13+
verbs:
14+
- get
15+
- watch
16+
- patch
17+
- apiGroups:
18+
- ""
19+
resources:
20+
- pods/log
21+
verbs:
22+
- get
23+
- watch
24+
- apiGroups:
25+
- ""
26+
resources:
27+
- secrets
28+
verbs:
29+
- get
30+
- apiGroups:
31+
- ""
32+
resources:
33+
- services
34+
verbs:
35+
- create
36+
- get
37+
- watch
38+
- patch
39+
- delete
40+
---
41+
apiVersion: rbac.authorization.k8s.io/v1
42+
kind: RoleBinding
43+
metadata:
44+
name: default-default-invocation
45+
namespace: argo
46+
roleRef:
47+
apiGroup: rbac.authorization.k8s.io
48+
kind: Role
49+
name: argo-invocation
50+
subjects:
51+
- kind: ServiceAccount
52+
name: argo-workflow-invocator
53+
namespace: argo
54+
---
55+
apiVersion: rbac.authorization.k8s.io/v1
56+
kind: ClusterRoleBinding
57+
metadata:
58+
name: argo-invocation-chaos
59+
roleRef:
60+
apiGroup: rbac.authorization.k8s.io
61+
kind: ClusterRole
62+
name: argo-chaos
63+
subjects:
64+
- kind: ServiceAccount
65+
name: argo-workflow-invocator
66+
namespace: argo
67+

Diff for: .bin/chaos.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: chaos-mesh.org/v1alpha1
2+
kind: PodChaos
3+
metadata:
4+
name: pod-failure-openldap
5+
annotations:
6+
experiment.chaos-mesh.org/pause: "false"
7+
spec:
8+
action: pod-failure
9+
mode: random-max-percent
10+
value: "100"
11+
duration: "15s"
12+
selector:
13+
labelSelectors:
14+
"app": "openldap-openldap-stack-ha"
15+
scheduler:
16+
cron: "@every 2m"

Diff for: .bin/kind-conf.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
kind: Cluster
2+
apiVersion: kind.x-k8s.io/v1alpha4
3+
nodes:
4+
- role: control-plane
5+
- role: worker
6+
kubeadmConfigPatches:
7+
- |
8+
kind: JoinConfiguration
9+
nodeRegistration:
10+
kubeletExtraArgs:
11+
node-labels: "ingress-ready=true"
12+
extraPortMappings:
13+
- containerPort: 80
14+
hostPort: 8080
15+
protocol: TCP
16+
- containerPort: 443
17+
hostPort: 8443
18+
protocol: TCP
19+
- containerPort: 30636
20+
hostPort: 30636
21+
- containerPort: 30389
22+
hostPort: 30389
23+
- role: worker
24+
- role: worker

Diff for: .bin/myval.yaml

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
logLevel: debug
2+
resources:
3+
limits:
4+
cpu: "128m"
5+
memory: "64Mi"
6+
replicaCount: 3
27
ltb-passwd:
38
ingress:
49
hosts:
@@ -10,8 +15,6 @@ phpldapadmin:
1015
customTLS:
1116
enabled: true
1217
secret: "custom-cert"
13-
CA:
14-
enabled: false
1518
customLdifFiles:
1619
01-default-group.ldif: |-
1720
dn: cn=myGroup,dc=example,dc=org
@@ -32,3 +35,7 @@ customLdifFiles:
3235
uid: jdupond
3336
uidnumber: 1000
3437
userpassword: {MD5}KOULhzfBhPTq9k7a9XfCGw==
38+
service:
39+
ldapPortNodePort: 30389
40+
sslLdapPortNodePort: 30636
41+
type: NodePort

Diff for: .bin/phpldap-test.py

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Generated by Selenium IDE
2+
import pytest
3+
import time
4+
import json
5+
from selenium import webdriver
6+
from selenium.webdriver.common.by import By
7+
from selenium.webdriver.common.action_chains import ActionChains
8+
from selenium.webdriver.support import expected_conditions
9+
from selenium.webdriver.support.wait import WebDriverWait
10+
from selenium.webdriver.common.keys import Keys
11+
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
12+
13+
class TestPhpldap():
14+
15+
def setup_method(self, method):
16+
op = webdriver.ChromeOptions()
17+
op.add_argument('headless')
18+
self.driver = webdriver.Chrome(options=op)
19+
self.vars = {}
20+
21+
def teardown_method(self, method):
22+
self.driver.quit()
23+
24+
def test_phpldap(self):
25+
self.driver.get("http://phpldapadmin.example.lan:8080/")
26+
print(self.driver.title)
27+
self.driver.find_element(By.LINK_TEXT, "login").click()
28+
#element = self.driver.find_element(By.LINK_TEXT, "login")
29+
#actions = ActionChains(self.driver)
30+
#actions.move_to_element(element).perform()
31+
#element = self.driver.find_element(By.CSS_SELECTOR, "body")
32+
#actions = ActionChains(self.driver)
33+
#actions.move_to_element(element, 0, 0).perform()
34+
self.driver.find_element(By.ID, "login").click()
35+
self.driver.find_element(By.ID, "login").send_keys("cn=admin,dc=example,dc=org")
36+
self.driver.find_element(By.ID, "password").click()
37+
self.driver.find_element(By.ID, "password").send_keys("admin")
38+
self.driver.find_element(By.NAME, "submit").click()
39+
print("successfully logged")
40+
#test = self.driver.find_element(By.XPATH, "//a[@href='cmd.php?cmd=template_engine&server_id=1&dn=dc%3Dexample%2Cdc%3Dorg']")
41+
#test.click()
42+
#main = test.find_element(By.XPATH, "//a[@title='dc=example,dc=org']")
43+
#print(main.find_element(By.XPATH, "//a[contains(text(), 'child')]"))
44+
#self.driver.find_element(By.ID, "posixAccount:2").click()
45+
#self.driver.find_element(By.ID, "new_values_givenname_0").click()
46+
#self.driver.find_element(By.ID, "new_values_givenname_0").send_keys("test")
47+
#self.driver.find_element(By.ID, "new_values_sn_0").send_keys("test")
48+
#self.driver.find_element(By.ID, "new_values_uid_0").click()
49+
#self.driver.find_element(By.ID, "new_values_userpassword_0").click()
50+
#self.driver.find_element(By.ID, "new_values_userpassword_0").send_keys("test")
51+
#self.driver.find_element(By.ID, "new_values_verify_userpassword_0").click()
52+
#self.driver.find_element(By.ID, "new_values_verify_userpassword_0").send_keys("test")
53+
#self.driver.find_element(By.ID, "new_values_gidnumber_0").click()
54+
#dropdown = self.driver.find_element(By.ID, "new_values_gidnumber_0")
55+
#dropdown.find_element(By.XPATH, "//option[. = 'myGroup']").click()
56+
#self.driver.find_element(By.ID, "create_button").click()
57+
58+
testClass = TestPhpldap()
59+
60+
testClass.setup_method("")
61+
testClass.test_phpldap()
62+
testClass.teardown_method("")

Diff for: .bin/selfservice-test.py

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Generated by Selenium IDE
2+
import pytest
3+
import time
4+
import json
5+
from selenium import webdriver
6+
from selenium.webdriver.common.by import By
7+
from selenium.webdriver.common.action_chains import ActionChains
8+
from selenium.webdriver.support import expected_conditions
9+
from selenium.webdriver.support.wait import WebDriverWait
10+
from selenium.webdriver.common.keys import Keys
11+
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
12+
13+
class TestPhpldap():
14+
15+
def setup_method(self, method):
16+
op = webdriver.ChromeOptions()
17+
op.add_argument('headless')
18+
self.driver = webdriver.Chrome(options=op)
19+
self.vars = {}
20+
21+
def teardown_method(self, method):
22+
self.driver.quit()
23+
24+
def test_phpldap(self):
25+
self.driver.get("http://phpldapadmin.example.lan:8080/")
26+
print(self.driver.title)
27+
self.driver.find_element(By.LINK_TEXT, "login").click()
28+
#element = self.driver.find_element(By.LINK_TEXT, "login")
29+
#actions = ActionChains(self.driver)
30+
#actions.move_to_element(element).perform()
31+
#element = self.driver.find_element(By.CSS_SELECTOR, "body")
32+
#actions = ActionChains(self.driver)
33+
#actions.move_to_element(element, 0, 0).perform()
34+
self.driver.find_element(By.ID, "login").click()
35+
self.driver.find_element(By.ID, "login").send_keys("cn=admin,dc=example,dc=org")
36+
self.driver.find_element(By.ID, "password").click()
37+
self.driver.find_element(By.ID, "password").send_keys("admin")
38+
self.driver.find_element(By.NAME, "submit").click()
39+
print("successfully logged")
40+
#test = self.driver.find_element(By.XPATH, "//a[@href='cmd.php?cmd=template_engine&server_id=1&dn=dc%3Dexample%2Cdc%3Dorg']")
41+
#test.click()
42+
#main = test.find_element(By.XPATH, "//a[@title='dc=example,dc=org']")
43+
#print(main.find_element(By.XPATH, "//a[contains(text(), 'child')]"))
44+
#self.driver.find_element(By.ID, "posixAccount:2").click()
45+
#self.driver.find_element(By.ID, "new_values_givenname_0").click()
46+
#self.driver.find_element(By.ID, "new_values_givenname_0").send_keys("test")
47+
#self.driver.find_element(By.ID, "new_values_sn_0").send_keys("test")
48+
#self.driver.find_element(By.ID, "new_values_uid_0").click()
49+
#self.driver.find_element(By.ID, "new_values_userpassword_0").click()
50+
#self.driver.find_element(By.ID, "new_values_userpassword_0").send_keys("test")
51+
#self.driver.find_element(By.ID, "new_values_verify_userpassword_0").click()
52+
#self.driver.find_element(By.ID, "new_values_verify_userpassword_0").send_keys("test")
53+
#self.driver.find_element(By.ID, "new_values_gidnumber_0").click()
54+
#dropdown = self.driver.find_element(By.ID, "new_values_gidnumber_0")
55+
#dropdown.find_element(By.XPATH, "//option[. = 'myGroup']").click()
56+
#self.driver.find_element(By.ID, "create_button").click()
57+
58+
testClass = TestPhpldap()
59+
60+
testClass.setup_method("")
61+
testClass.test_phpldap()
62+
testClass.teardown_method("")

Diff for: .github/PULL_REQUEST_TEMPLATE.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### What this PR does / why we need it:
2+
<!--- Why is this change required? What problem does it solve? -->
3+
<!--- If it fixes an open issue, please link to the issue here. -->
4+
5+
### Pre-submission checklist:
6+
7+
* [ ] Did you explain what problem does this PR solve? Or what new features have been added?
8+
* [ ] Have you updated the readme?
9+
* [ ] Is this PR backward compatible? **If it is not backward compatible, please discuss open a ticket first**

Diff for: .github/semantic.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
titleOnly: true
2+
allowRevertCommits: true
3+
types:
4+
- feat
5+
- fix
6+
- docs
7+
- style
8+
- refactor
9+
- perf
10+
- test
11+
- build
12+
- ci
13+
- chore
14+
- revert
15+
- change

Diff for: .github/workflows/ci.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Qualif
2+
on:
3+
push:
4+
branches:
5+
- "master"
6+
pull_request:
7+
branches:
8+
- "master"
9+
jobs:
10+
qualif:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v1
15+
- name: Lint
16+
shell: bash
17+
run: |
18+
helm lint .
19+
- name: setup cluster
20+
shell: bash
21+
run: |
22+
curl -Lo /tmp/kind https://kind.sigs.k8s.io/dl/v0.10.0/kind-linux-amd64
23+
chmod +x /tmp/kind
24+
/tmp/kind create cluster --config=$GITHUB_WORKSPACE/.bin/kind-conf.yml
25+
kubectl apply -f https://projectcontour.io/quickstart/contour.yaml
26+
kubectl patch daemonsets -n projectcontour envoy -p '{"spec":{"template":{"spec":{"nodeSelector":{"ingress-ready":"true"}}}}}'
27+
- name: setup chaos mesh
28+
shell: bash
29+
run: |
30+
curl -sSL https://mirrors.chaos-mesh.org/latest/install.sh | bash -s -- --local kind
31+
- name: setup certs
32+
shell: bash
33+
run: |
34+
openssl req -x509 -newkey rsa:4096 -nodes -subj '/CN=example.com' -keyout tls.key -out tls.crt -days 365
35+
cp tls.crt ca.crt
36+
openssl dhparam -out dhparam.pem 2048
37+
kubectl create secret generic custom-cert --from-file=./tls.crt --from-file=./tls.key --from-file=./dhparam.pem --from-file=./ca.crt
38+
- name: deploy openldap-stack-ha
39+
shell: bash
40+
run: |
41+
cd "$GITHUB_WORKSPACE"
42+
helm install openldap -f .bin/myval.yaml .
43+
kubectl rollout status sts openldap-openldap-stack-ha
44+
- name: verify deployment
45+
shell: bash
46+
run: |
47+
echo "test access to openldap database"
48+
sudo apt-get install -y ldap-utils
49+
LDAPTLS_REQCERT=never ldapsearch -x -D 'cn=admin,dc=example,dc=org' -w Not@SecurePassw0rd -H ldaps://localhost:30636 -b 'dc=example,dc=org'
50+
- name: test phpldapadmin access
51+
shell: bash
52+
run: |
53+
echo "test access to phpldapadmin"
54+
echo "127.0.0.1 phpldapadmin.example ssl-ldap2.example" | sudo tee -a /etc/hosts
55+
curl phpldapadmin.example:8080
56+
- name: test self service pwd access
57+
shell: bash
58+
run: |
59+
echo "test access to ssp"
60+
curl ssl-ldap2.example:8080
61+
- name: verify certs
62+
shell: bash
63+
run: |
64+
echo "verify certificate"
65+
openssl s_client -showcerts -connect localhost:30636 </dev/null | grep "issuer=CN = example.com"
66+
- name: apply chaos tests
67+
shell: bash
68+
run: |
69+
echo "test access to openldap database"
70+
kubectl apply -f .bin/chaos.yaml
71+
- name: chaos tests
72+
shell: bash
73+
run: |
74+
echo "test access to openldap database"
75+
for i in {1..20}; do LDAPTLS_REQCERT=never ldapsearch -x -D 'cn=admin,dc=example,dc=org' -w Not@SecurePassw0rd -H ldaps://localhost:30636 -b 'dc=example,dc=org' && sleep 60 ; done
76+
77+
78+

0 commit comments

Comments
 (0)