Created
January 20, 2021 15:51
-
-
Save wstrange/0ce047b1adf53d89b0741b1e9c1e14b8 to your computer and use it in GitHub Desktop.
ldap checker pod
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
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" ] |
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
#!/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 |
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
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