免責事項: これは英文の記事 SSL certificates specified in additionalTrustedCAs are not trusted in a RHEL-based VKS cluster. の日本語訳です。記事はベストエフォートで翻訳を進めているため、ローカライズコンテンツは最新情報ではない可能性があります。最新情報は英語版の記事を参照してください。
RHEL ベースの VKS クラスタでは、以下のように additionalTrustedCAs の下に SSL/TLS サーバー証明書を指定しても、実際のワーカーノードでは証明書が信頼されません。
$ kubectl get cluster ##CLUSTER_NAME## -o yaml
...
- name: osConfiguration
value:
trust:
additionalTrustedCAs:
- caCert:
secretRef:
key: sample-ssl
name: sample-ssl-secret
...
Pod イメージにプライベートレジストリを使用している場合、イメージのプル時に "certificate signed by unknown authority" (証明書は不明な認証局により署名されています) というエラーが発生し、Pod のデプロイが失敗します。
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 21m default-scheduler Successfully assigned default/sample-deployment-######## to ########
Normal Pulling 18m (x5 over 21m) kubelet Pulling image "registry.example.com/library/sample:v1"
Warning Failed 18m (x5 over 21m) kubelet Failed to pull image "registry.example.com/library/sample:v1": failed to pull and unpack image "registry.example.com/library/sample:v1": failed to resolve image: failed to do request: Head "https://registry.example.com/v2/library/sample/manifests/v1": tls: failed to verify certificate: x509: certificate signed by unknown authority
Warning Failed 18m (x5 over 21m) kubelet Error: ErrImagePull
さらに、ワーカーノード上で curl コマンドを実行してその SSL 証明書を使用するサーバにアクセスすると、次のエラーが発生します。
$ curl -I https://registry.example.com
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.この問題は、RHEL の証明書インストールプロセスがサーバ (リーフ) 証明書をスキップするために発生します。
additionalTrustedCAs で証明書を定義すると、VKS クラスタはそれらを RHEL ベースのワーカーノードの /etc/pki/ca-trust/source/anchors/machine-agent.crt に配置し update-ca-trust コマンドを実行することで、システム全体で CA 証明書を信頼するようになります。証明書の Basic Constraints に CA:TRUE が含まれていない場合、RHEL はそれを信頼された証明書ストアに追加しないため、サーバー証明書は信頼されません。
この問題を解決するには、additionalTrustedCAs が参照する Secret に、サーバー証明書ではなく CA 証明書を指定します。
base64 -w 0 CA.crt | base64 -w 0
apiVersion: v1
data:
##KEY_NAME##: |
<ステップ 1. で生成された文字列をここに貼付します。>
kind: Secret
metadata:
name: ##SECRET_NAME##
namespace: ##NAMESPACE##
type: Opaque
- name: osConfiguration
value:
trust:
additionalTrustedCAs:
- caCert:
secretRef:
key: ##KEY_NAME##
name: ##SECRET_NAME##
curl -I https://server.example.com