尝试用单节点的方式部署openshift(通过oc cluster up部署的集群。),后来不知道什么原因,不能用system:admin登录了,有可能是直接重新部署的问题。

尝试登录提示错误:

1
2
3
4
5
[root@openshift ~]# oc login -u system:admin
Authentication required for https://10.25.0.74:8443 (openshift)
Username: system:admin
Password:
error: username system:admin is invalid for basic auth

实际system:admin通过证书认证的,默认是放在admin.kubeconfig文件中的,通过KUBECONFIG环境变量指定这个文件。

我的环境里部署后集群的数据放在目录openshift.local.clusterup,设置KUBECONFIG:

1
export KUBECONFIG=/root/openshift.local.clusterup/kube-apiserver/admin.kubeconfig

再次登录:

1
2
3
4
5
# oc login -u system:admin
Logged into "https://localhost:8443" as "system:admin" using existing credentials.

You have access to the following projects and can switch between them with 'oc project <projectname>':
...

参考: https://bugzilla.redhat.com/show_bug.cgi?id=1268126#c9