# Problems using Kubernetes Services

**URL:** https://forums.suse.com/t/problems-using-kubernetes-services/7366
**Category:** Rancher 1.x
**Created:** [September 20, 2017, 12:35pm UTC](https://forums.suse.com/t/problems-using-kubernetes-services/7366 "2017-09-20T12:35:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ronidaho](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/ronidaho/32/2845_2.png) [@ronidaho](https://forums.suse.com/u/ronidaho)
#### Post date: [September 20, 2017, 12:35pm UTC](https://forums.suse.com/t/problems-using-kubernetes-services/7366/1 "2017-09-20T12:35:01Z")

</div>

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
```

---

<div class="post-metadata">

### Author: ![shubbard343](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@shubbard343](https://forums.suse.com/u/shubbard343)
#### Post date: [September 20, 2017, 5:50pm UTC](https://forums.suse.com/t/problems-using-kubernetes-services/7366/2 "2017-09-20T17:50:01Z")

</div>

You are missing the nodePort setting in the ports section. The ports: option is the port that the service is available internally in Kubernetes.

```
apiVersion: v1
kind: Service
metadata:
  name: test-svc
  labels:
    app: test
spec:
  type: NodePort
  ports:
  - port: 888
    nodePort: 40888 < This is the port that is open to the outside on each host.
    protocol: TCP
  selector:
    app: test
```

---

<div class="post-metadata">

### Author: ![ronidaho](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/ronidaho/32/2845_2.png) [@ronidaho](https://forums.suse.com/u/ronidaho)
#### Post date: [September 21, 2017, 6:49am UTC](https://forums.suse.com/t/problems-using-kubernetes-services/7366/3 "2017-09-21T06:49:01Z")

</div>

Thanks, but I tried setting that - to 30001 - doesn’t work.

If you leave the nodePort specification out then one is assigned, in my case 30252, which can be obtained with:

```
kubectl describe service <name>

```

Still doesn’t work.
