Cause of the problem : When initially using the openshift cluster, it is inevitable to use the system administrator to operate
Problem status : When logging in using system:admin, an error occurserror: username system:admin is invalid for basic auth
as follows:
[root@cpe-172-250-210-30 openshift-server-v3.11.0]# oc login -u system:admin
Authentication required for https://172.250.210.30:8443 (openshift)
Username: system:admin
Password:
error: username system:admin is invalid for basic auth
Cause of the problem : This is because system:admin
the system administrator logs in with 密钥证书
the username and cannot identify the certificate location, so he cannot log in.
Solution : At this time, you only need to manually configure the environment variables of the certificate and tell the cluster administrator where the key is.
$ export KUBECONFIG=/opt/openshift.local.clusterup/openshift-apiserver/admin.kubeconfig
Find the admin.kubeconfig file according to the openshift environment you installed. It is usually in the installation directory (you can use this to find it in the system: find / -name admin.kubeconfig). This is an environment variable
temporarily used in the current session. Reconnect via ssh to a new session and it will disappear.
You can also add configuration directly in /etc/profile
$ vim /etc/profile
KUBECONFIG=/opt/openshift.local.clusterup/openshift-apiserver/admin.kubeconfig
$ source /etc/profile
After configuring the environment variables of the key, you can log in normally.
If necessary, after system:admin can log in, grant administrator rights to an ordinary user. You can log in with either a key or a password.
赋予普通用户管理员权限(命令最后的admin是要配置的用户)
oc adm policy add-cluster-role-to-user cluster-admin admin
[root@cpe-172-250-210-30 ~]# oc adm policy add-cluster-role-to-user cluster-admin admin
[root@cpe-172-250-210-30 ~]# oc login -u admin -p admin
Login successful.
You have access to the following projects and can switch between them with 'oc project <projectname>':
* default
kube-dns
kube-proxy
kube-public
kube-system
myproject
openshift
openshift-apiserver
openshift-controller-manager
openshift-core-operators
openshift-infra
openshift-node
openshift-service-cert-signer
openshift-web-console
test
Using project "default".
End……