Overview
When DKP is installed, a static user account and credentials are created that can be used to access the DKP Dashboard. These credentials are displayed using the 'dkp open dashboard' command, or by using the following command:
kubectl -n kommander get secret dkp-credentials -o go-template='Username: {{.data.username|base64decode}}{{ "\n"}}Password: {{.data.password|base64decode}}{{ "\n"}}'
D2iQ recommends that you only use these static credentials as a backup to credentials configured using an external identity provider. However, you may have a need to change the password for these credentials.
Solution
The following shell script can be used to update the secret that contains the static credentials:
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
case "$OSTYPE" in
darwin)
new_password=$(head -c45 /dev/urandom | base64 --break=0)
;;
*)
new_password=$(head -c45 /dev/urandom | base64 --wrap=0)
;;
esac
kubectl patch \
--namespace kommander \
secret/dkp-credentials \
--type='json' \
--patch="[ { \"op\" : \"replace\" , \"path\" : \"/data/password\" , \"value\" : \"$new_password\" } ]"
printf 1>&2 "Password: %s\n" "$new_password"