2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rancherで立てたKubernetesに直接kubectl接続する

Posted at

Rancherを利用すると、Kubernetesクラスタを容易に構築・管理できるが
こんな疑問が。

・もしRancherサーバが死んだらどうなる?

・Rancherで立てたKubernetesクラスタには直接アクセスできる?

答えは

・Rancherサーバが死んでも、Rancherで立てたk8sクラスタは死なない
 ※ホストサーバが異なる事が前提

・Rancherで立てたKubernetesクラスタへはkubectlで直接アクセスできる

※v2.3.0以上で検証しました。古いバージョンではその限りではないようです。

参考:
https://rancher.com/docs/rancher/v2.x/en/cluster-admin/cluster-access/kubeconfig/#accessing-rancher-launched-kubernetes-clusters-without-rancher-server-running

Rancherで立てたKubernetesに直接kubectl接続

Rancherでk8sクラスタを立てると、直接アクセス可能なエンドポイントをデフォルトで生成してくれる。

ただし、RancherがRKEで立てたものが対象で、EKSなどで立てたものは知らん。とのこと。

The authorized cluster endpoint only works on Rancher-launched Kubernetes clusters. In other words, it only works in clusters where Rancher used RKE to provision the cluster. It is not available for clusters in a hosted Kubernetes provider, such as Amazon’s EKS.

具体的には、

① k8sクラスタにアクセスしたいサーバにkubectlをinstall
② ~/.kube/config に、Rancherで立てたk8sのkubeconfigファイルをコンソールからコピペ
③contextオプションでクラスタ名を指定してkubectl接続

kubectl --context [クラスタ名] get pod

※クラスタ名は .kube/config 参照

試しに、Rancher Serverを停止させて、k8sクラスタへの接続を確認したところ
正常に動作していた。
また、Rancher Serverを再起動させると、Rancher側も復活。

ちなみに、Production環境のRancher ServerはHAが推奨されている
それは、k8sを管理するRancher Serverをk8sで立てる というややニワタマ的手法 w
https://rancher.com/docs/rancher/v2.x/en/installation/k8s-install/

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?