Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

5
2

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.

メンテナンス用に、Kubernetesのコンテナ内のポートにkubectlでアクセスする(ポートフォワード)

Last updated at Posted at 2018-12-10

Kubernetes上でRedisやPostgreSQL等のDBを構築した場合など、中のDBに直接アクセスしてメンテナンスを行いたい場合がある。Kubernetes内に、phpMyAdmin等のDB管理ツールを立てる場合もあるが、逐一そのようにするのは面倒が大きい。

kubectlが実行可能であれば、ローカルのポートをPodにつなぐポートフォワードができる。

kubectl port-forward pods/redis-master-765d459796-258hz 6379

この状態でローカルの6379ポートにアクセスすると、コンテナの6379にアクセスできる。ポートを変更する場合はローカルポート:Podポートのように指定する。

リファレンス先: https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/

5
2
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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?