kubectl接続エラーの原因と対処法
冒頭まとめ kubectl get podsなどを実行したとき、次のエラーが出ることがあります。 Unable to connect to the server: dial tcp: lookup api.example.com: no such host The connection to the server 127.0.0.1:6443 was refused - did you specify the right host or port? どちらもkubectlからKubernetes APIサーバーへ接続できていません。ただし、直す場所は後半の文言によって異なります。 後半の文言 最初に疑う場所 connection refused APIサーバーの停止、ホスト、ポート no such host DNS、VPN、kubeconfig内のホスト名 i/o timeout、TLS handshake timeout 経路、VPN、ファイアウォール、負荷 x509:、tls: CA証明書、接続先名、証明書の期限 no configuration has been provided kubeconfigの有無と読み込み元 最初に、kubectlが選んでいるcontextとAPIサーバーのURLを確認してください。 kubectl config current-context kubectl config view --minify kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}{"\n"}' 想定外のクラスターが表示された場合は、ネットワークを調べる前にkubeconfigの読み込み元を直します。 ...