Skip to content
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

k8s token refresh helper #3190

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions packaging/files/crontab
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
0 */2 * * * root [ -f /opt/ood/nginx_stage/sbin/nginx_stage ] && /opt/ood/nginx_stage/sbin/nginx_stage nginx_clean 2>&1 | logger -t nginx_clean
0 */8 * * * root [ -f /opt/ood/utils/k8s_token_refresh ] && /opt/ood/utils/k8s_token_refresh | logger -t ood_k8s_refresh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The packaging systems need to create /opt/ood/utils. This location is really just a best guess as to where we should put this.

15 changes: 15 additions & 0 deletions packaging/files/k8s_token_refresh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

if command -v kubectl >/dev/null 2>&1;
then
CMD_USER=$(whoami)
if [ "$CMD_USER" == "root" ]; then
TOKEN=$(kubectl create token ondemand --namespace=ondemand --duration 9h)
kubectl config set-credentials ondemand@kubernetes --token=$TOKEN
else
>&2 echo "this program needs to run as 'root' and you are $CMD_USER."
exit 1
fi
fi