I created a nginx service with 2 pods on a 2-node k8s cluster. The yaml files:
cat nginx-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
cat nginx-service.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-nodeport
spec:
type: NodePort
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 30080
selector:
app: nginx
somehow I can only run curl http:// on the nodes (not the master). Also the only half of the time the curl http:// would return. Looks to me that I only get the the result when the http is served from the node where I can the curl command.
Any help is appreciated/
What is the url you are trying to hit? You should be okay if you’re using host:nodeport . If that isn’t working you may want to check your firewall settings.
Normally you would just use the ip of one of the nodes or the load balancer plus the node port the service is being exposed on and things should work good. nodeip:nodeport
If you are trying to hit port 80 you’ll get a different behaviour.