Skip to content

Instantly share code, notes, and snippets.

@wstrange
Created January 20, 2021 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wstrange/0ce047b1adf53d89b0741b1e9c1e14b8 to your computer and use it in GitHub Desktop.
Save wstrange/0ce047b1adf53d89b0741b1e9c1e14b8 to your computer and use it in GitHub Desktop.
ldap checker pod
FROM debian:stable-slim
ENV APT_OPTS="--no-install-recommends --yes"
RUN apt-get update \
&& apt-get install -y openldap-utils jq \
&& apt-get clean \
&& rm -r /var/lib/apt/lists /var/cache/apt/archives
COPY entrypoint.sh /
ENTRYPOINT [ "/entrypoint.sh" ]
#!/usr/bin/env bash
checkLdap () {
echo "Checking ${HOST}"
# search -l 1 at most one second
# -z 1 - 1 result
# nettimeout 1 - allow 1 second max for the tcp timeout
ldapsearch -h $1 -p $2 -b $3 -D $4 -w $5 -z 1 -l 1 -s base -o nettimeout=1 "objectclass=*" > /dev/null
echo "Response is $?"
}
while true; do
checkLdap $HOST $PORT $BASE $DN $PASSWORD
sleep 5
done
apiVersion: v1
kind: Pod
metadata:
name: ldap-test
labels:
name: ldap-test
spec:
containers:
- name: ldap-test
image: "gcr.io/forgeops-public/ldap-test:latest"
resources:
limits:
memory: 100Mi
env:
- name: HOST
value: "ds-idrepo"
- name: PORT
value: "1389"
- name: DN
value: "uid=admin"
- name: BASE
value: "ou=identities"
- name: PASSWORD
value: "xxxxxx"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment