K8s - Service - NodePort
2022-02-07 00:00:00
Create pod & service
Get IP of node
IP of node is underINTERNAL-IP
for example (in my case) 192.168.49.2
Get Port
Port of service is underPORT(S)
for example (in my case) 80:30008/TCP
URL
Go to 192.168.49.2:30008
you should be able to see Welcome to nginx!
pod-definition.yml
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
service-definition.yml
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
type: NodePort
ports:
- targetPort: 80
port: 80
nodePort: 30008
selector:
app: myapp
type: front-end