<p>kubernetes version: 1.5.2<br>
os: centos 7<br>
etcd version: 3.4.0  </p>

<p>First, I create an etcd pod, the etcd dockerfile and etcd pod YAML file like this:<br>
etcd dockerfile:</p>

<pre><code>FROM alpine

COPY . /usr/bin
WORKDIR /usr/bin

CMD etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379

EXPOSE 2379
</code></pre>

<p>pod yaml file</p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: etcd
  namespace: storageplatform
  labels:
    app: etcd
spec:
  containers:
    - name: etcd
      image: "karldoenitz/etcd:3.4.0"
      ports:
        - containerPort: 2379
          hostPort: 12379
</code></pre>

<p>After created the docker image and push to dockerhub, I run the command <code>kubectl apply -f etcd.yaml</code> to create the etcd pod.
The ip of etcd pod is <code>10.254.140.117</code>, I ran the command use <code>ETCDCTL_API=3 etcdctl --endpoints=175.24.47.64:12379 put 1 1</code> and got <code>OK</code>.<br>
My service yaml:  </p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: storageservice
  namespace: storageplatform
spec:
  type: NodePort
  ports:
    - port: 12379
      targetPort: 12379
      nodePort: 32379
  selector:
    app: etcd
</code></pre>

<p>apply the yaml file to create the service.run the command <code>kubectl get services -n storageplatform</code>, I got these infomation.  </p>

<pre><code>NAMESPACE         NAME                   CLUSTER-IP       EXTERNAL-IP   PORT(S)           AGE
storageplatform   storageservice         10.254.140.117   &lt;nodes&gt;       12379:32379/TCP   51s
</code></pre>

<p>After all, I run the command </p>

<pre class="lang-sh prettyprint-override"><code>ETCDCTL_API=3 etcdctl --endpoints=10.254.140.117:32379 get 1
</code></pre>

<p>or</p>

<pre class="lang-sh prettyprint-override"><code>ETCDCTL_API=3 etcdctl --endpoints={host-ip}:32379 get 1
</code></pre>

<p>I got <code>Error: context deadline exceeded</code>.</p>

<p>What's the matter? How to make the service useful?</p>

<p>You defined a service that is available inside the kubernetes network using the service name/ip (10.254.140.117 ) and the service port (12379) and which is available on ALL nodes of the kubernetes cluster even outside the kubernetes network with the node port (32379)</p>

<p>You need to fix the service in order to map to the correct container port: <code>targetPort</code> must match the pod <code>containerPort</code> (and the port in the dockerfile).</p>

<p>If the error <code>Error: context deadline exceeded</code> persits, it hints at a communication problem. This can be explained when using the internal service ip with the external node port (your first get 1). For the node port (your second command) I assume that either the etcd pod is not running properly, or the port is firewalled on the node.</p>
