Skip to content
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
15 changes: 15 additions & 0 deletions tests/templates/kuttl/ldap/00-patch-ns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# see https://github.com/stackabletech/issues/issues/566
---
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
kubectl patch namespace $NAMESPACE --patch='
{
"metadata": {
"labels": {
"pod-security.kubernetes.io/enforce": "privileged"
}
}
}'
timeout: 120
31 changes: 31 additions & 0 deletions tests/templates/kuttl/ldap/01-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: test-service-account
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: test-role
rules:
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
resourceNames:
- privileged
verbs:
- use
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: test-role-binding
subjects:
- kind: ServiceAccount
name: test-service-account
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: test-role
12 changes: 12 additions & 0 deletions tests/templates/kuttl/ldap/10-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 300
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: openldap
status:
readyReplicas: 1
replicas: 1
81 changes: 81 additions & 0 deletions tests/templates/kuttl/ldap/10-install-openldap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: openldap
labels:
app.kubernetes.io/name: openldap
spec:
selector:
matchLabels:
app.kubernetes.io/name: openldap
serviceName: openldap
replicas: 1
template:
metadata:
labels:
app.kubernetes.io/name: openldap
spec:
containers:
- name: openldap
image: bitnamilegacy/openldap:2.5
env:
- name: LDAP_ADMIN_USERNAME
value: admin
- name: LDAP_ADMIN_PASSWORD
value: admin
- name: LDAP_ENABLE_TLS
value: "yes"
- name: LDAP_TLS_CERT_FILE
value: /tls/tls.crt
- name: LDAP_TLS_KEY_FILE
value: /tls/tls.key
- name: LDAP_TLS_CA_FILE
value: /tls/ca.crt
ports:
- name: ldap
containerPort: 1389
- name: tls-ldap
containerPort: 1636
volumeMounts:
- name: tls
mountPath: /tls
startupProbe:
tcpSocket:
port: 1389
readinessProbe:
tcpSocket:
port: 1389
# See https://github.com/bitnami/containers/issues/40841#issuecomment-1649977191
securityContext:
capabilities:
drop:
- ALL
add:
- NET_BIND_SERVICE
serviceAccountName: test-service-account
volumes:
- name: tls
csi:
driver: secrets.stackable.tech
volumeAttributes:
secrets.stackable.tech/class: tls
secrets.stackable.tech/scope: pod
---
apiVersion: v1
kind: Service
metadata:
name: openldap
labels:
app.kubernetes.io/name: openldap
spec:
type: ClusterIP
ports:
- name: ldap
port: 1389
targetPort: ldap
- name: tls-ldap
port: 1636
targetPort: tls-ldap
selector:
app.kubernetes.io/name: openldap
11 changes: 11 additions & 0 deletions tests/templates/kuttl/ldap/11-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 600
---
apiVersion: batch/v1
kind: Job
metadata:
name: create-ldap-user
status:
succeeded: 1
105 changes: 105 additions & 0 deletions tests/templates/kuttl/ldap/11-create-ldap-user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
apiVersion: batch/v1
kind: Job
metadata:
name: create-ldap-user
spec:
template:
spec:
containers:
- name: create-ldap-user
image: bitnamilegacy/openldap:2.5
command:
- /bin/bash
- -euxo
- pipefail
- -c
args:
- |
ldapadd \
-D cn=admin,dc=example,dc=org \
-w admin \
-f /stackable/ldap-users/integrationtest \
|| true

ldappasswd \
-D cn=admin,dc=example,dc=org \
-w admin \
-s integrationtest \
cn=integrationtest,ou=users,dc=example,dc=org

# Check that the user works
ldapsearch \
-D cn=integrationtest,ou=users,dc=example,dc=org \
-w integrationtest \
-b ou=users,dc=example,dc=org
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: LDAPURI
value: ldaps://openldap.$(NAMESPACE).svc.cluster.local:1636/
- name: LDAPTLS_CACERT
value: /stackable/tls/ca.crt
volumeMounts:
- name: ldap-users
mountPath: /stackable/ldap-users
- name: tls
mountPath: /stackable/tls
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
resources:
requests:
memory: 128Mi
cpu: 100m
limits:
memory: 128Mi
cpu: 400m
volumes:
- name: ldap-users
configMap:
name: ldap-users
- name: tls
ephemeral:
volumeClaimTemplate:
metadata:
annotations:
secrets.stackable.tech/class: tls
spec:
storageClassName: secrets.stackable.tech
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "1"
serviceAccountName: test-service-account
restartPolicy: OnFailure
---
apiVersion: v1
kind: ConfigMap
metadata:
name: ldap-users
data:
integrationtest: |
dn: cn=integrationtest,ou=users,dc=example,dc=org
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
cn: integrationtest
uid: integrationtest
givenName: Stackable
sn: Integration-Test
mail: [email protected]
uidNumber: 16842
gidNumber: 100
homeDirectory: /home/integrationtest
loginShell: /bin/bash
userPassword: {crypt}x
shadowLastChange: 0
shadowMax: 0
shadowWarning: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: >
envsubst '$NAMESPACE' < 20_opensearch-security-config.yaml |
kubectl apply -n $NAMESPACE -f -
106 changes: 106 additions & 0 deletions tests/templates/kuttl/ldap/20_opensearch-security-config.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
apiVersion: v1
kind: Secret
metadata:
name: opensearch-security-config
stringData:
action_groups.yml: |
---
_meta:
type: actiongroups
config_version: 2
allowlist.yml: |
---
_meta:
type: allowlist
config_version: 2

config:
enabled: false
audit.yml: |
---
_meta:
type: audit
config_version: 2

config:
enabled: false
config.yml: |
---
_meta:
type: config
config_version: 2

config:
dynamic:
authc:
ldap:
http_enabled: true
transport_enabled: true
order: 1
http_authenticator:
type: basic
challenge: false
authentication_backend:
type: ldap
config:
enable_ssl: true
hosts:
- openldap.$NAMESPACE.svc.cluster.local:1636
pemtrustedcas_filepath: {{ test_scenario['values']['opensearch_home'] }}/config/tls/ca.crt
userbase: ou=users,dc=example,dc=org
username_attribute: uid
usersearch: (cn={0})
verify_hostnames: true
authz: {}
internal_users.yml: |
---
# The hash value is a bcrypt hash and can be generated with plugin/tools/hash.sh

_meta:
type: internalusers
config_version: 2

admin:
hash: $2y$10$xRtHZFJ9QhG9GcYhRpAGpufCZYsk//nxsuel5URh0GWEBgmiI4Q/e
reserved: true
backend_roles:
- admin
description: OpenSearch admin user

kibanaserver:
hash: $2y$10$vPgQ/6ilKDM5utawBqxoR.7euhVQ0qeGl8mPTeKhmFT475WUDrfQS
reserved: true
description: OpenSearch Dashboards user
nodes_dn.yml: |
---
_meta:
type: nodesdn
config_version: 2
roles.yml: |
---
_meta:
type: roles
config_version: 2
roles_mapping.yml: |
---
_meta:
type: rolesmapping
config_version: 2

all_access:
reserved: false
backend_roles:
- admin
users:
- integrationtest

kibana_server:
reserved: true
users:
- kibanaserver
tenants.yml: |
---
_meta:
type: tenants
config_version: 2
12 changes: 12 additions & 0 deletions tests/templates/kuttl/ldap/21-assert.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 600
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: opensearch-nodes-default
status:
readyReplicas: 3
replicas: 3
Loading