title: Access redis by service name in Kubernetes
body: <p>I created a redis deployment and service in kubernetes,
  I can access redis from another pod by service ip, but I can't access it by service name</p>
  <p>the redis yaml</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: redis-deployment
    namespace: myapp-ns
  spec:
    replicas: 1
    selector:
      matchLabels:
        component: redis
    template:
      metadata:
        labels:
          component: redis
      spec:
        containers:
          - name: redis
            image: redis
            ports:
              - containerPort: 6379
  ---
  apiVersion: v1
  kind: Service
  metadata:
    name: redis
    namespace: myapp-ns
  spec:
    type: ClusterIP
    selector:
      component: redis
    ports:
      - port: 6379
        targetPort: 6379
  </code></pre>