Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link volume from existing container to another container in a pod #6120

Closed
oba11 opened this issue Mar 27, 2015 · 8 comments
Closed

link volume from existing container to another container in a pod #6120

oba11 opened this issue Mar 27, 2015 · 8 comments
Assignees
Labels
kind/support Categorizes issue or PR as a support question.

Comments

@oba11
Copy link

oba11 commented Mar 27, 2015

I have 2 containers in a pod.
I have some files in container a that needs to be accessed by container b
I'm not sure how I can achieve this.

containers:
  - name: conatainer-a
    volumeMounts:
      - name: www-data
        mountPath: /data
  - name: conatainer-b
    volumeMounts:
      - name: www-data
        mountPath: /data/shared
        readOnly: true
volumes:
  - name: www-data

The contents of /data in container a becomes empty which has the content to be shared.

@thockin
Copy link
Member

thockin commented Mar 28, 2015

We so not have a way to link data from one container into another. To do
this introduces some ordering and dependencies that we would rather not
tackle.

Instead, you can publish the data to the shared volume and see it in both
containers.

What is running in your container-a?
On Mar 27, 2015 4:34 PM, "Oluwaseun Obajobi" notifications@github.com
wrote:

I have 2 containers in a pod.
I have some files in container a that needs to be accessed by container b
I'm not sure how I can achieve this.

containers:

  • name: conatainer-a
    volumeMounts:
    • name: www-data
      mountPath: /data
  • name: conatainer-b
    volumeMounts:
    • name: www-data
      mountPath: /data/shared
      readOnly: true
      volumes:
  • name: www-data

The contents of /data in container a becomes empty which has the content
to be shared.


Reply to this email directly or view it on GitHub
#6120.

@oba11
Copy link
Author

oba11 commented Mar 29, 2015

Thanks @thockin
Not sure how to publish the data to the shared volume which can be accessible by both containers.
container-a only has ssl key which I dont want in the project commit of container-b
Thanks again @thockin

@thockin
Copy link
Member

thockin commented Mar 29, 2015

Publish means "copy" here. I dont know if there is a lighter weight way
at the moment.
On Mar 28, 2015 11:00 PM, "Oluwaseun Obajobi" notifications@github.com
wrote:

Thanks @thockin https://github.com/thockin
Not sure how to publish the data to the shared volume which can be
accessible by both containers.
container-a only has ssl key which I dont want in the project commit of
container-b
Thanks again @thockin https://github.com/thockin


Reply to this email directly or view it on GitHub
#6120 (comment)
.

@thockin thockin added kind/support Categorizes issue or PR as a support question. and removed kind/support Categorizes issue or PR as a support question. priority/support labels May 19, 2015
@mingfang
Copy link

mingfang commented Aug 6, 2015

+1

@goltermann
Copy link
Contributor

We’re going through old support issues and asking everyone to direct your questions to stackoverflow.

We are trying to consolidate the channels to which questions for help/support are posted so that we can improve our efficiency in responding to your requests, and to make it easier for you to find answers to frequently asked questions and how to address common use cases.

We regularly see messages posted in multiple forums, with the full response thread only in one place or, worse, spread across multiple forums. Also, the large volume of support issues on github is making it difficult for us to use issues to identify real bugs.

The Kubernetes team scans stackoverflow on a regular basis, and will try to ensure your questions don't go unanswered.

@warmchang
Copy link
Contributor

+1

1 similar comment
@NandoSangenetto
Copy link

+1

@toms-place
Copy link

toms-place commented Jul 6, 2023

I just came across this issue, because I had the same problem and crafted a solution using shareProcessNamespace.

see my answer here: https://stackoverflow.com/a/76629218/8079928

or this gist:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: datasharing
spec:
  selector:
    matchLabels:
      app: datasharing
  template:
    metadata:
      labels:
        app: datasharing
    spec:
      shareProcessNamespace: true
      containers:
        - name: data
          image: ubuntu
          imagePullPolicy: IfNotPresent
          command: ["/bin/bash", "-c"]
          args: ["trap 'echo signal;exit 0' SIGINT; sleep infinity"]
          resources:
            limits:
              memory: "128Mi"
              cpu: "500m"
          lifecycle:
            postStart:
              exec:
                command:
                  - /bin/sh
                  - -c
                  - mkdir -p /DATA && touch /DATA/empty_test_file
        - name: nginx
          image: nginx:stable
          imagePullPolicy: IfNotPresent
          resources:
            limits:
              memory: "128Mi"
              cpu: "500m"
          ports:
            - containerPort: 8080
          env:
            - name: GET_DATA_PROC_DIR
              value: 'find /proc -maxdepth 1 -type d -regex "/proc/[0-9]*" | head -2 | tail -1'
          lifecycle:
            postStart:
              exec:
                command:
                  - /bin/sh
                  - -c
                  - ln -s $(eval $GET_DATA_PROC_DIR)/root/DATA /mnt/DATA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

8 participants