Skip to main content

OpenShift tips: How to recover a lost kubeadmin password for an OpenShift 4 cluster

Just in case you need it, here's how to recover a lost or forgotten kubeadmin password.
Image
Recover a lost kubeadmin password

Photo by Pixabay from Pexels

Red Hat Openshift 4 provides two different ways to install its platform: Installer-provisioned infrastructure (IPI) and User-provisioned infrastructure (UPI). Between these two, IPI is a great option for a team with public access to the Internet, because it provides a quick installation that should not take more than 30 minutes with its automated wizard.

However, it's always possible that something could go wrong or you could accidentally lose information that you need. Some information can be very important, like the admin password or cluster URL. You may forget to write down the information or lose the file with the data. So how do you recover the lost password?

Lost kubeadmin password

For example, as seen in the screenshot below, after I ran the openshift-install create cluster --dir $HOME/cluster-xxx command and went through the installation wizard, my Terminal window somehow forgot to print out the kubeadmin password.

Image
Screen showing no kubeadmin password

[ Getting started with Red Hat OpenShift Service on AWS Learning Path - Getting started with Red Hat OpenShift Service on AWS. ]

OpenShift installation log

Fortunately, there is a way to recover the information. To retrieve the password, however, the following two requirements must be satisfied:

  • You have sudo access to the OpenShift cluster.
  • The path containing the OpenShift cluster is fresh, so the necessary installation log still exists.

The file you are looking for is named .openshift_install.log and it is found in the OpenShift installation directory. It is a hidden file, as indicated with a . (dot) preceding the file name, so use the ls -la command to display it.

Here are the steps:

  1. SSH into the machine that hosts the OpenShift cluster.
  2. Type sudo -i to switch to a privileged user.
  3. cd into the directory that has the OpenShift installation.
  4. Type ls -la to see the hidden log file.
  5. View the contents of .openshift_install.log with cat or another text editor, such as vim.
Image
Log in as a privileged account and see the .openshift_install.log

For example, if you need the kubeadmin password, it should be in the .openshift_install.log file. If you want to log in with the default credential, the username is kubeadmin. The password is the one found in the log.

Image
View the kubeadmin password

Wrap up

I hope this article helps you understand how to recover the kubeadmin password for an OpenShift 4 cluster. Thank you for reading, and see you next time.

[ Getting started with containers? Check out this free course - Deploying containerized applications: A technical overview. ]

Topics:   Containers   OpenShift   Kubernetes  
Author’s photo

Bryant Son

Bryant Jimin Son is a Consultant at Red Hat, a technology company known for its Linux server and opensource contributions. More about me

Try Red Hat Enterprise Linux

Download it at no charge from the Red Hat Developer program.