▲上の「DevOpsとk8sフルスタックテクノロジー」をクリックして公式アカウントをフォローしてください
k8s クラスターで kubectl コマンドを実行するとクラスターにアクセスできません。エラーはおそらく「証明書の有効期限が切れているか、まだ有効ではありません」です。
注: 次の実験について説明がない場合、デフォルトの動作は k8s 制御ノード上で行われます。
証明書の有効期限を表示する
[root@ ~]# kubeadm 証明書のチェック-有効期限
次のように表示されます。
[check-expiration] Reading configuration from the cluster...
[check-expiration] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED
admin.conf Jan 04, 2024 13:49 UTC 363d ca no
apiserver Jan 04, 2024 13:48 UTC 363d ca no
apiserver-etcd-client Jan 04, 2024 13:49 UTC 363d etcd-ca no
apiserver-kubelet-client Jan 04, 2024 13:48 UTC 363d ca no
controller-manager.conf Jan 04, 2024 13:49 UTC 363d ca no
etcd-healthcheck-client Jan 04, 2024 13:49 UTC 363d etcd-ca no
etcd-peer Jan 04, 2024 13:49 UTC 363d etcd-ca no
etcd-server Jan 04, 2024 13:49 UTC 363d etcd-ca no
front-proxy-client Jan 04, 2024 13:49 UTC 363d front-proxy-ca no
scheduler.conf Jan 04, 2024 13:49 UTC 363d ca no
CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
ca Jan 01, 2033 13:48 UTC 9y no
etcd-ca Jan 01, 2033 13:49 UTC 9y no
front-proxy-ca Jan 01, 2033 13:49 UTC 9y no
すべての証明書を更新する
kubeadm certs renew all コマンドを使用します。
[root@xianchaomaster1~]# kubeadm certs renew all
[renew] Reading configuration from the cluster...
[renew] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself renewed
certificate for serving the Kubernetes API renewed
certificate the apiserver uses to access etcd renewed
certificate for the API server to connect to kubelet renewed
certificate embedded in the kubeconfig file for the controller manager to use renewed
certificate for liveness probes to healthcheck etcd renewed
certificate for etcd nodes to communicate with each other renewed
certificate for serving etcd renewed
certificate for the front proxy client renewed
certificate embedded in the kubeconfig file for the scheduler manager to use renewed
Done renewing certificates. You must restart the kube-apiserver, kube-controller-manager, kube-scheduler and etcd, so that they can use the new certificates.
証明書が更新されたかどうかを確認する
または、kubeadm certs check-expiration を使用して、証明書の有効期限が更新されているかどうかを確認します。
[check-expiration] Reading configuration from the cluster...
[check-expiration] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED
admin.conf Jan 06, 2024 14:16 UTC 364d ca no
apiserver Jan 06, 2024 14:16 UTC 364d ca no
apiserver-etcd-client Jan 06, 2024 14:16 UTC 364d etcd-ca no
apiserver-kubelet-client Jan 06, 2024 14:16 UTC 364d ca no
controller-manager.conf Jan 06, 2024 14:16 UTC 364d ca no
etcd-healthcheck-client Jan 06, 2024 14:16 UTC 364d etcd-ca no
etcd-peer Jan 06, 2024 14:16 UTC 364d etcd-ca no
etcd-server Jan 06, 2024 14:16 UTC 364d etcd-ca no
front-proxy-client Jan 06, 2024 14:16 UTC 364d front-proxy-ca no
scheduler.conf Jan 06, 2024 14:16 UTC 364d ca no
CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
ca Jan 01, 2033 13:48 UTC 9y no
etcd-ca Jan 01, 2033 13:49 UTC 9y no
front-proxy-ca Jan 01, 2033 13:49 UTC 9y no
CA 証明書の有効期限がまだ 9 年 (当初は 10 年) であることがわかります。これは、k8s クラスターが 1 年間デプロイされていることを示し、サービス証明書の有効期限は 364 日で、更新されたばかりであることを示しています。
素晴らしい記事の推薦
2022 年の Kubernetes に関する 11 の統計をチェックしてください。
Kuberentes での GitOps ベスト プラクティス
Kubernetes の一般的な日常トラブルシューティング ガイド|乾物品の共有|あらゆる種類の基本的な担当者が学習するのに適しています
K8S 大規模クラスタ最適化ソリューションに関する一連の記事 - 第 1 回の記事
オンライン問題解決 - ソケット: 開いているファイルが多すぎます (開いているファイルが多すぎます)
Jenkins は ssh を使用して git リポジトリからコードをプルします
別のコンテナから Docker コンテナ内の MySQL データベースにアクセスできない | 解決策
CentOS 8/7 の廃止が発表された後、CentOS 8/7 に代わる最良の選択肢は何ですか? |個人的にはrocky linuxをお勧めします
作成者 WeChat: luckylucky421302
コレクションをライトアップすると、サーバーは 10 年間ダウンしません