0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

k8sクラスター内からしか接続できないDBに繋ぎたい

Posted at

環境

  • macOS

内容

開発環境のDBはk8sのクラスター内からしか接続できないが、デバッグのためローカル環境から参照したい

手順

# プロキシ用のpodを作成する
kubectl run mysql-proxy --image=alpine/socat --restart=Never --command -- socat TCP-LISTEN:3306,fork TCP:{DBのアドレス}:3306

# ポートフォワーディングで接続する
kubectl port-forward pod/mysql-proxy 33306:3306
mysql -h 127.0.0.1 -P 33306 -u {DBのユーザー} -p

# 使わなくなったpodを消す
kubectl delete pod mysql-proxy
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?