I’ve created a Kubernetes cluster using Rancher and used a k8s Deployment to schedule 10 instances of a simple test app (receives HTTP requests and echoes back the time). I can curl the individual pods’ addresses OK. When I add a k8s Service exposing a node port, I can curl using the service IP address and the original container port, but not the node port.
Deployment YAML:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test-deploy
spec:
replicas: 10
template:
metadata:
labels:
app: test
spec:
containers:
- name: test-pod
image: xxx/test_app
ports:
- containerPort: 888
Service YAML:
apiVersion: v1
kind: Service
metadata:
name: test-svc
labels:
app: test
spec:
type: NodePort
ports:
- port: 888
protocol: TCP
selector:
app: test