I deploy an mysql pod to my k8s. this is the config, I am confused about the ports, like that:
kind: Deployment
...
containers:
- ports:
- containerPort: 3306 # @1
---
apiVersion: v1
kind: Service
metadata:
name: mysql
labels:
app: mysql
spec:
selector:
app: mysql
# way 1
ports:
- port: 3306 # @2
targetPort: 3306 # @3
# way 2
type: NodePort
ports:
- port: 3306
targetPort: 3306
nodePort: 30600
@question1. who proxy this port @question2. what is this port ? I mean container has exposed the port 3306, and the service exposed also. In my single node, These don't clash? @question3. this port is mean to the port the container exposed?
question4: when I deploy this with way 1. how can I visit my mysql server From pods & my localMachine .
question5: when I deploy this with way 2.how can I visit my mysql server From pods & my localMachine .