Commit 2a0e1e09 authored by HQ's avatar HQ
Browse files

Bug fixes and performance improvements

parent d74228f2
......@@ -82,19 +82,24 @@ if ($intip && $mip) {
`perl -pi -e 's/dashboardip/$daship/' /etc/apache2/sites-available/kubernetes-ssl.conf`;
}
# Get the token
my $adminuser = `KUBECONFIG=/etc/kubernetes/admin.conf kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}"`;
#my $adminuser = `KUBECONFIG=/etc/kubernetes/admin.conf kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}"`;
my $token;
$token = `KUBECONFIG=/etc/kubernetes/admin.conf kubectl -n kubernetes-dashboard get secret $adminuser -o go-template="{{.data.token | base64decode}}"` if ($adminuser);
`echo "Got admin-user: $adminuser and token: $token" >> /root/initout.log`;
#$token = `KUBECONFIG=/etc/kubernetes/admin.conf kubectl -n kubernetes-dashboard get secret $adminuser -o go-template="{{.data.token | base64decode}}"` if ($adminuser);
#`echo "Got admin-user: $adminuser and token: $token" >> /root/initout.log`;
# New method for Kubernetes 1.24: https://itnext.io/big-change-in-k8s-1-24-about-serviceaccounts-and-their-secrets-4b909a4af4e0
$token = `KUBECONFIG=/etc/kubernetes/admin.conf kubectl -n kubernetes-dashboard create token admin-user --duration=999999h`;
chomp $token;
`echo "Got admin-user token: $token" >> /root/initout.log`;
if ($token =~ /^ey/) {
`echo "$token" > /root/admin-user.token`;
`perl -pi -e 's/export KUBE_TOKEN=.*/export KUBE_TOKEN=$token/' /etc/apache2/envvars`;
`systemctl restart apache2`;
} else {
sleep 15;
$adminuser = `KUBECONFIG=/etc/kubernetes/admin.conf kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}"`;
$token = `KUBECONFIG=/etc/kubernetes/admin.conf kubectl -n kubernetes-dashboard get secret $adminuser -o go-template="{{.data.token | base64decode}}"` if ($adminuser);
`echo "Tried again and got admin-user: $adminuser and token: $token" >> /root/initout.log`;
#$adminuser = `KUBECONFIG=/etc/kubernetes/admin.conf kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}"`;
#$token = `KUBECONFIG=/etc/kubernetes/admin.conf kubectl -n kubernetes-dashboard get secret $adminuser -o go-template="{{.data.token | base64decode}}"` if ($adminuser);
$token = `KUBECONFIG=/etc/kubernetes/admin.conf kubectl -n kubernetes-dashboard create token admin-user --duration=999999h`;
`echo "Tried again and got admin-user token: $token" >> /root/initout.log`;
if ($token =~ /^ey/) {
`echo "$token" > /root/admin-user.token`;
`perl -pi -e 's/export KUBE_TOKEN=.*/export KUBE_TOKEN=$token/' /etc/apache2/envvars`;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment