From 5ceb6d39fd5a37d3872958089d22a4bee40a078d Mon Sep 17 00:00:00 2001 From: Michael O'Brien Date: Fri, 13 Jun 2025 09:56:18 -0400 Subject: [PATCH] Expose MySQL via NodePort --- README.md | 15 +++++++++++++++ biometric-nbi/src/kubernetes/mysql-service.yaml | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 80b9713..d735ba9 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,21 @@ Forwarding from 127.0.0.1:3306 -> 3306 Forwarding from [::1]:3306 -> 3306 ``` +If you prefer direct access without port forwarding, update `mysql-service.yaml` +to use a `NodePort` service. The example in this repository exposes port `3306` +on node port `30306`: + +``` +spec: + type: NodePort + ports: + - protocol: TCP + port: 3306 + targetPort: 3306 + nodePort: 30306 +``` +After applying the updated service you can connect using `:30306`. + ![Image](https://github.com/user-attachments/assets/943d18d8-2cfc-478e-91ed-a7cd7b1dcf23) #### Docker Desktop diff --git a/biometric-nbi/src/kubernetes/mysql-service.yaml b/biometric-nbi/src/kubernetes/mysql-service.yaml index cca4692..2f9245a 100644 --- a/biometric-nbi/src/kubernetes/mysql-service.yaml +++ b/biometric-nbi/src/kubernetes/mysql-service.yaml @@ -7,11 +7,12 @@ metadata: name: mysql namespace: mysql spec: + type: NodePort # kubectl port-forward mysql-58b7767464-dgpf4 3306:3306 ports: - protocol: TCP port: 3306 targetPort: 3306 + nodePort: 30306 selector: app: mysql - clusterIP: None \ No newline at end of file