Memecahkan masalah autentikasi identitas workload terkelola untuk GKE

Untuk mendiagnosis dan menyelesaikan error identitas workload terkelola umum di Google Kubernetes Engine (GKE), periksa peristiwa Pod, workload identity pool, konfigurasi penerbitan sertifikat, dan resource Certificate Authority Service. Pemeriksaan ini membantu Anda menyelesaikan masalah deployment Pod, penerbitan sertifikat X.509, dan update certificate authority (CA).

Jika Pod workload GKE gagal di-deploy dengan sertifikat yang terpasang, gunakan perintah berikut untuk memeriksa status Pod:

kubectl describe pod POD_NAME -n POD_NAMESPACE

Output perintah mencakup peristiwa Pod yang dihasilkan oleh kubelet dan gke-spiffe-controller. Tinjau peristiwa ini untuk mengetahui pesan error tertentu, yang mungkin mencakup salah satu hal berikut:

PermissionDenied error

Bagian ini menjelaskan error yang menampilkan kode error RPC PermissionDenied.

PRIVATE_CA_AUTHORIZATION_FAILURE

Error ini terlihat mirip dengan yang berikut ini:

Permission denied while issuing the certificate: failed to issue the certificate from the GKE Auth: rpc error: code = PermissionDenied desc = Permission 'privateca.caPools.get' denied on resource 'privateca.googleapis.com/projects/CA_POOL_PROJECT_NUMBER/locations/REGION/caPools/CA_POOL_ID' (or it may not exist). Ensure that the CaPool exists and you have authorized the Managed Workload Identity to request certificates from the CaPool.

Error ini terjadi karena workload identity pool tidak memiliki peran CA Service Workload Certificate Requester (roles/privateca.workloadCertificateRequester) di subordinate CA pool atau karena kumpulan CA tidak ada.

Untuk mengatasi error ini, berikan peran ke pool:

gcloud privateca pools add-iam-policy-binding SUBORDINATE_CA_POOL_ID \
   --project=CA_POOL_PROJECT_ID \
   --location=REGION \
   --role=roles/privateca.workloadCertificateRequester \
   --member="principal://iam.googleapis.com/projects/WIP_PROJECT_NUMBER/name/locations/global/workloadIdentityPools/TRUST_DOMAIN_NAME"

Ganti kode berikut:

  • SUBORDINATE_CA_POOL_ID: ID kumpulan CA subordinat
  • CA_POOL_PROJECT_ID: project ID kumpulan CA
  • REGION: region subordinate CA
  • WIP_PROJECT_NUMBER: nomor project dari project workload identity pool
  • TRUST_DOMAIN_NAME: nama domain kepercayaan. Bergantung pada jenis pool Anda, format nama sebagai berikut:
    • Kumpulan yang dikelola Google: PROJECT_ID.svc.id.goog
    • Kumpulan yang dikelola sendiri: POOL_NAME.global.POOL_HOST_PROJECT_NUMBER.workload.id.goog

WORKLOAD_IDENTITY_NOT_FOUND, WORKLOAD_POOL_NOT_FOUND, atau WORKLOAD_NAMESPACE_NOT_FOUND

Error ini terlihat mirip dengan yang berikut ini:

failed to issue the certificate from the GKE Auth: rpc error: code = PermissionDenied desc = Permission denied on resource 'projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_NAME/... (or it may not exist).

Error ini dipetakan ke WORKLOAD_IDENTITY_NOT_FOUND, WORKLOAD_POOL_NOT_FOUND, atau WORKLOAD_NAMESPACE_NOT_FOUND. Error ini terjadi jika workload identity pool, namespace workload identity pool, atau resource identitas terkelola tidak ada, atau jika dinonaktifkan atau dihapus. Perhatikan bahwa error ini menampilkan PermissionDenied, bukan NotFound, untuk menghindari kebocoran ketidakberadaan resource.

Untuk mengatasi error ini, verifikasi keberadaan dan status workload identity pool Anda serta sub-resource-nya di IAM. Pastikan grup lokasi dikonfigurasi dengan benar dan tidak dinonaktifkan atau dihapus.

FailedPrecondition error

Bagian ini menjelaskan error yang menampilkan kode error RPC FailedPrecondition, yang biasanya menunjukkan konfigurasi yang tidak ada atau salah.

WORKLOAD_IDENTITY_INVALID_CONFIGURATION

Deskripsi Pod dapat menyertakan salah satu pesan berikut:

failed to issue the certificate from the GKE Auth: rpc error: code = FailedPrecondition desc = There are no CaPools configured for certificate issuance. Ensure you have added certificate issuance configuration to the workload identity pool 'projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/WI_POOL_NAME', which contains at least one CaPool.

atau

failed to issue the certificate from the GKE Auth: rpc error: code = FailedPrecondition desc = Missing Certificate issuance configuration in the Trust Domain. Ensure you have added certificate issuance configuration to the workload identity pool 'projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/WI_POOL_NAME' which contains at least one CaPool.

Error ini (WORKLOAD_IDENTITY_INVALID_CONFIGURATION) terjadi karena workload identity pool tidak dikonfigurasi dengan konfigurasi penerbitan sertifikat (CIC) atau karena CIC yang dikonfigurasi tidak berisi setidaknya satu kumpulan CA.

Untuk mengatasi error ini, buat CIC yang berisi setidaknya satu kumpulan CA dan gunakan untuk memperbarui workload identity pool.

CERTIFICATE_AUTHORITY_NOT_FOUND

Error ini terlihat mirip dengan yang berikut ini:

failed to issue the certificate from the GKE Auth: rpc error: code = FailedPrecondition desc = Failed to request certificates from the CaPool... There are no enabled CAs in the CaPool. Ensure that there is at least one enabled Certificate Authority to issue a certificate.

Error ini (CERTIFICATE_AUTHORITY_NOT_FOUND) menunjukkan bahwa Certificate Authority tidak dapat ditemukan untuk penerbitan sertifikat di kumpulan CA yang dikonfigurasi pelanggan.

Untuk mengatasi error ini, pastikan Certificate Authority ada di kumpulan CA yang dikonfigurasi dan diaktifkan untuk penerbitan sertifikat.

CA_POOL_REGION_MISMATCH

Error ini terlihat mirip dengan yang berikut ini:

failed to issue the certificate from the GKE Auth: rpc error: code = FailedPrecondition desc = Unable to find a CaPool in the workload's region. Ensure you have setup a subordinate CaPool in 'WORKLOAD_REGION' and added it to the certificate issuance configuration of the Workload Identity Pool...

Error ini (CA_POOL_REGION_MISMATCH) menunjukkan bahwa tidak ada kumpulan CA yang dikonfigurasi untuk region tertentu workload.

Untuk mengatasi error ini, konfigurasikan kumpulan CA tambahan untuk region workload di workload identity pool atau deploy workload di region yang sudah memiliki kumpulan CA yang dikonfigurasi.

ResourceExhausted error

Bagian ini menjelaskan error yang menampilkan kode error RPC ResourceExhausted.

PRIVATE_CA_QUOTA_EXCEEDED

Error ini terlihat mirip dengan yang berikut ini:

failed to issue the certificate from the GKE Auth: rpc error: code = ResourceExhausted desc = Quota exceeded for quota metric 'QUOTA_METRIC' and limit 'QUOTA_LIMIT' of service 'privateca.googleapis.com' for consumer 'project_number:PROJECT_NUMBER'.

Error ini (PRIVATE_CA_QUOTA_EXCEEDED) terjadi saat Anda mengonfigurasi workload identity pool untuk menggunakan CA kustom, dan upaya untuk menerbitkan sertifikat telah melebihi kuota atau batas yang ditetapkan terkait dengan CA Service. Error ini tidak terjadi jika Anda menggunakan CA default yang dikelola Google.

  • QUOTA_METRIC dan QUOTA_LIMIT: Metrik dan batas kuota tertentu yang terlampaui. Misalnya, privateca.googleapis.com/enterprise_certificate_issuance dan CertsPerEnterpriseCaPerMinute.

Untuk mengatasi error ini, tinjau kuota dan batas CA Service Anda di konsol Google Cloud , dan minta penambahan kuota jika perlu.

InvalidArgument error

Bagian ini menjelaskan error yang menampilkan kode error RPC InvalidArgument.

PRIVATE_CA_KEY_ALGORITHM_MISMATCH

Error ini terlihat mirip dengan yang berikut ini:

failed to issue the certificate from the GKE Auth: rpc error: code = InvalidArgument desc = Public key algorithm is not permitted by the CaPool's issuance policy. Ensure that the requested keyAlgorithm 'KEY_ALGO_IN_CSR' is permitted by the CAs in the CaPool 'privateca.googleapis.com/projects/PROJECT_NAME/locations/WORKLOAD_REGION/caPools/CA_POOL_NAME'.

Error ini (PRIVATE_CA_KEY_ALGORITHM_MISMATCH) menunjukkan bahwa algoritma kunci yang ditentukan dalam permintaan sertifikat tidak kompatibel dengan batasan kumpulan CA yang dikonfigurasi. Hal ini hanya terjadi jika Anda mengonfigurasi algoritma kunci kustom dalam konfigurasi penerbitan sertifikat (CIC) dan memperbarui workload identity pool.

Untuk mengatasi error ini, pastikan algoritma yang dikonfigurasi di CIC workload identity pool kompatibel dengan algoritma yang didukung oleh kebijakan penerbitan kumpulan CA.

Unknown error

Bagian ini menjelaskan error yang menampilkan kode error RPC Unknown.

UNKNOWN_PRIVATE_CA_CLIENT_ERROR

Error ini terlihat mirip dengan yang berikut ini:

failed to issue the certificate from the GKE Auth: rpc error: code = Unknown desc = Failed to get certificates using the CaPool... PRIVATE_CA_ERROR_MESSAGE

Error ini (UNKNOWN_PRIVATE_CA_CLIENT_ERROR) menunjukkan bahwa error klien yang tidak diketahui, seperti argumen tidak valid yang diberikan ke API, telah terjadi saat memanggil CA Service.

Untuk mengatasi error ini, tinjau pesan error spesifik yang ditampilkan dari CA Service API untuk mengidentifikasi argumen yang tidak valid atau masalah konfigurasi sisi klien dan perbaiki.

Latensi propagasi paket kepercayaan

Saat Anda memperbarui atau merotasi CA yang dikelola sendiri, ada latensi propagasi sekitar 5 menit sebelum update diterapkan di "cluster GKE". Hal ini karena gke-spiffe-controller memeriksa keanggotaan dan mengambil paket kepercayaan setiap lima menit.

Latensi ini tidak terjadi jika Anda menggunakan CA yang dikelola Google.

Jika Anda mengupdate CA yang dikelola sendiri, tunggu setidaknya lima menit hingga perubahan diterapkan.