Skip to content

Commit 887db79

Browse files
Merge pull request #29 from ObrienlabsDev/codex/expose-3306-port-as-nodeport-in-yaml
Expose MySQL on NodePort
2 parents 09fa700 + 5ceb6d3 commit 887db79

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ Forwarding from 127.0.0.1:3306 -> 3306
5252
Forwarding from [::1]:3306 -> 3306
5353
```
5454

55+
If you prefer direct access without port forwarding, update `mysql-service.yaml`
56+
to use a `NodePort` service. The example in this repository exposes port `3306`
57+
on node port `30306`:
58+
59+
```
60+
spec:
61+
type: NodePort
62+
ports:
63+
- protocol: TCP
64+
port: 3306
65+
targetPort: 3306
66+
nodePort: 30306
67+
```
68+
After applying the updated service you can connect using `<node-ip>:30306`.
69+
5570
![Image](https://github.com/user-attachments/assets/943d18d8-2cfc-478e-91ed-a7cd7b1dcf23)
5671

5772
#### Docker Desktop

biometric-nbi/src/kubernetes/mysql-service.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ metadata:
77
name: mysql
88
namespace: mysql
99
spec:
10+
type: NodePort
1011
# kubectl port-forward mysql-58b7767464-dgpf4 3306:3306
1112
ports:
1213
- protocol: TCP
1314
port: 3306
1415
targetPort: 3306
16+
nodePort: 30306
1517
selector:
1618
app: mysql
17-
clusterIP: None

0 commit comments

Comments
 (0)