i'm running an on-prem instance of kubernetes 1.16.2 on centos7. i have cert-manager, dex and gangway installed and apparently working. what i'm having problems with is kubectl.
so i have dex running on it's own ingress using letsencrypt certs and ldap on its' backend to our local authn. and gangway configured to use this instance of dex.
i gather together a letsencrypt.pem CA with
curl https://letsencrypt.org/certs/isrgrootx1.pem.txt > isrgrootx1.pem.txt
curl https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem.txt > lets-encrypt-x3-cross-signed.pem.txt
cat isrgrootx1.pem.txt lets-encrypt-x3-cross-signed.pem.txt > /etc/pki/ca-trust/source/anchors/letsencrypt.pem
dex, configured with these extra nginx ingress annotations,
cert-manager.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
seems to work okay:
$ curl -v -L --cacert /etc/pki/ca-trust/source/anchors/letsencrypt.pem https://dex.mydomain.com/.well-known/openid-configuration
* About to connect() to dex.mydomain.com port 443 (#0)
* Trying x.y.z.a...
* Connected to dex.mydomain.com (x.y.z.a) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/ca-trust/source/anchors/letsencrypt.pem
CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate:
* subject: CN=dex.mydomain.com
* start date: Oct 27 04:33:31 2019 GMT
* expire date: Jan 25 04:33:31 2020 GMT
* common name: dex.mydomain.com
* issuer: CN=Let's Encrypt Authority X3,O=Let's Encrypt,C=US
> GET /.well-known/openid-configuration HTTP/1.1
> User-Agent: curl/7.29.0
> Host: dex.mydomain.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: openresty/1.15.8.2
< Date: Sun, 27 Oct 2019 06:55:30 GMT
< Content-Type: application/json
< Content-Length: 774
< Connection: keep-alive
< Vary: Accept-Encoding
< Strict-Transport-Security: max-age=15724800; includeSubDomains
<
{
"issuer": "https://dex.mydomain.com",
"authorization_endpoint": "https://dex.mydomain.com/auth",
"token_endpoint": "https://dex.mydomain.com/token",
"jwks_uri": "https://dex.mydomain.com/keys",
"userinfo_endpoint": "https://dex.mydomain.com/userinfo",
"response_types_supported": [
"code"
],
"subject_types_supported": [
"public"
],
"id_token_signing_alg_values_supported": [
"RS256"
],
"scopes_supported": [
"openid",
"email",
"groups",
"profile",
"offline_access"
],
"token_endpoint_auth_methods_supported": [
"client_secret_basic"
],
"claims_supported": [
"aud",
"email",
"email_verified",
"exp",
"iat",
"iss",
"locale",
"name",
"sub"
]
* Connection #0 to host dex.mydomain.com left intact
i then edit my kubeapi manifest on my kubernetes master node by adding the following containers.command line:
- --oidc-issuer-url=https://dex.mydomain.com
- --oidc-ca-file=/etc/pki/ca-trust/source/anchors/letsencrypt.pem
- --oidc-client-id=oidc-auth-client
- --oidc-username-claim=email
- --oidc-groups-claim=groups
i wait for the kubernetes master pods to restart themselves. everything comes back up okay. and i double check that /etc/pki/ca-trust/source/anchors/letsencrypt.pem
is accessible within the kube-apiserver-k8s
pod.
i configure gangway without a trustedCAPath
and i proceed to goto my gangway ingress and i'm presented with the dex authentication page. I choose LDAP, enter my enterprise account details and then gangway proceeds with the expected:
echo "-----BEGIN CERTIFICATE-----
MIICyDCCAbCgAwIBAgIBADANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwprdWJl
cm5ldGVzMB4XDTE5MTAxNDE5MTAyMFoXDTI5MTAxMTE5MTAyMFowFTETMBEGA1UE
AxMKa3ViZXJuZXRlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJac
bCrqxhyd70KzLyvFZ9Ew6kZfrcV7LVI73jdP2Tr9wstE3T3SgwHF8B23zJTFXqjv
W1wGBIIXu/GSIsGuotkyggUMrXDJgakm+SeNeIODsqycJQbyIvnUy++PHGPXHU+p
Wuh8fvNuK51kwbn663ZFZDRrRoL3/zptrhOm3dgAomCqW8BBrQWeW1lOIk2M8NOR
6iqkJ97nSmUAMM0pKGbyQcy3xHFjPr9nLjInC+R70DoaIZtB4sDeBkHpTkVGOEDn
FacnxkhcXt/LYGZNMjJKbrpKIlx8TVSTPR57AfIRfQsnJ59p6M0pnY5TFm2eGd0L
QJG0/GpExZM47PZnwFcCAwEAAaMjMCEwDgYDVR0PAQH/BAQDAgKkMA8GA1UdEwEB
/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAAmc59zdag+ARkBDA55nxGC2qCaY
DDhfR/FUghlMEkiBs+Ys8o0ndnL/2lorcFOiquikP/fV6SMMZOr17OQw+C0Hh6kb
H6f5Dm8e/Y2C6Ku5ZTvGyU+CYDtHS4nejZ2Z1a8ZxKpDfUisgrFqB42+imCeK7uS
of2WgVLoWftjUNOebsT8di0L1j7vpQPOh+doQqh5kKEQwwJ2sK22NJDRa6rPqQ/t
F5UHkQcrJUdOZq/ZXtqEu2uFsbJc85tEoVK3l2xL4AoZbcE3K0vjgGpxtjk5LwdY
LSrEoraw1hxeFIA7hDBxm71y7eT5ZTB967cLOXsuMe/l4keMgpOy8KHO+xY=
-----END CERTIFICATE-----
" \ > ca-k8s-cluster.pem
kubectl config set-cluster k8s-cluster --server=https://k8s-login.mydomain.com/ --certificate-authority=ca-k8s-cluster.pem --embed-certs
kubectl config set-credentials me@mydomain.com \
--auth-provider=oidc \
--auth-provider-arg='idp-issuer-url=https://dex.mydomain.com' \
--auth-provider-arg='client-id=oidc-auth-client' \
--auth-provider-arg='client-secret=wqTkyx6vtpH56FI9K3DE+IaFuwTVToJ5f3CBAuidTtU=' \
--auth-provider-arg='refresh-token=Chl2bWtrYTJsdnlvZWt4dW9raGc3aGxrcnpxEhlvdmlwcWZ2c3dsZGQ0d3dzd3M3a2ZmNHVq' \
--auth-provider-arg='id-token=eyJhbGciOiJSUzI1NiIsImtpZCI6ImFlZDFlMzYxY2NmMjY4NzI3MDVjYTBmNDcxYzFlMDgzZGQ1MjA4YWUifQ.eyJpc3MiOiJodHRwczovL2RleC5zbGFjLnN0YW5mb3JkLmVkdSIsInN1YiI6IkNnTjVkR3dTQkd4a1lYQSIsImF1ZCI6Im9pZGMtYXV0aC1jbGllbnQiLCJleHAiOjE1NzIyNDQ3ODYsImlhdCI6MTU3MjE1ODM4NiwiYXRfaGFzaCI6IlVEdUxfNFdGb3JTRTZhSzNzY0wtQ0EiLCJlbWFpbCI6Inl0bEBzbGFjLnN0YW5mb3JkLmVkdSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJuYW1lIjoiWWVlIFRpbmcgTGkifQ.Qyjf_IXxyHX7-Z8uLHNxCfC7ne0fZfCk4XoyVD_tom-b9bLf72-p1IxW8HPLo6QgCcnH9QFw3X4XKpFU7sjXZTwu59CxkCfQSG1XKHIKrzUbX7g3c4ZX1b7r7tTnAmGXTj-nG15crYnBcJjgFJRac_qKjqJUBED1_RUjKXzjpQaSlhmsnu8roRVcUJvHnsORHZlSF2kOYlLFlW2fi8cYa3JXISBhY2vzUYJmwopFF8LP3C_GrzrjEsql0984yFDHYNGKtnVhBRCFDBEmBEc9OgxEi8OXuN93pKu-ApNiagaoVBprgWzgl2eijogkCrHn_T7NcXBpx211V1YzXs_-_w'
kubectl config set-context k8s-cluster --cluster=k8s-cluster --user=me@mydomain.com
kubectl config use-context k8s-cluster
rm ca-k8s-cluster.pem
which i dutifully paste into my terminal. however, when i attempt (without setting up any RBAC roles for myself), i get
$ kubectl get pods
Unable to connect to the server: x509: certificate signed by unknown authority
i also try removing the --oidc-ca-file
from kubeapi, but i get the same error.
i also tried adding
--auth-provider-arg='idp-certificate-authority=/etc/pki/ca-trust/source/anchors/letsencrypt.pem'
to my kubectl config
for the credentials - but to no avail.
i also tried:
$ kubectl --insecure-skip-tls-verify=true get pods
error: yaml: line 13: mapping values are not allowed in this context
i see nothing out of the ordinary in the kupeapi logs and i'm completely at a loss as to what to try next. any suggestions?
grrr.... i solved it. its all in the line:
kubectl config set-cluster k8s-cluster --server=https://k8s-login.mydomain.com/ --certificate-authority=ca-k8s-cluster.pem --embed-certs
the --server
in question should be the kubeapi endpoint, not my gangway server! i traced this back to a duplication of my apiServerURL
in the gangway configmap.