Communication between 2 pods in Kubernetes

9/4/2017

I created 2 pods with the following yaml :

{
  "kind": "Pod",
  "apiVersion": "v1",
  "metadata": {
    "name":nginx-123,
    "labels": {
      "name": nginx-123
    }
  },
  "spec": {
    "containers": [
      {
        "name": nginx-123,
        "image":nginx,
        "ports": [
          {
            "containerPort": 80
          }
        ]
      }
    ]
  }
}

I would like to transfer data between the 2 pods in order to see the UI changes.. Any idea ?

-- Natezone
automation
kubernetes
yaml

1 Answer

9/4/2017

You can use kubectl cp to copy files and directories between pods.

However in your case you probably want to create two deployments and copy files from pods of one deployments to pods of another deployment. Otherwise the service could point to the same pods.

-- Sebastien Goasguen
Source: StackOverflow