Conjur - Kubernetes Authentication Error
Symptom
Authentication failure when the Kubernetes/OpenShift POD is performing authentication with Conjur Node, the Conjur node as part of the authentication procedure connects to the Kubernetes/OpenShift cluster but it is failing.
Error on Conjur Side:
CONJ00048I Authentication Error: #<Kubeclient::HttpError: HTTP status code 401, Unauthorized for GET https://<kubernets-api-url>/api/v1>
Environment
13.0;13.2;13.1;13.3;13.4;13.5 Conjur Server
Kubernetes/OpenShift
Cause
This occurs as Conjur node is unable to connect to the Kubernetes/OpenShift cluster using the service account token to get cluster information.
Resolution
As the issue is related to service account token, test the current service account token in conjur "conjur/authn-k8s/dev-cluster/kubernetes/service-account-token" as per below:
curl --cacert "<kubernetes-ca-cert>.cer" <kubernetes-api-url> --header "Authorization: Bearer <service-account-token>"
If working you should see the following output:
curl --cacert "<kubernetes-ca-cert>.cer" <kubernetes-api-url> --header "Authorization: Bearer <service-account-token>"
{
"paths": [
"/api",
"/api/v1",
"/apis",
"/apis/",
If the 401 error is received, the service account token is incorrect, please check with Kubernetes/OpenShift team for the service account token in might be required to be recreated. After which test the curl command again and update the server account token ( conjur/authn-k8s/dev-cluster/kubernetes/service-account-token) in Conjur side as well.
If 403 error is received, the service account token is the curl command is not correctly formatted.