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

About patching pod spec with additional volumes and volumeMounts #198

Open
mighty1231 opened this issue Mar 2, 2023 · 0 comments
Open

Comments

@mighty1231
Copy link

mighty1231 commented Mar 2, 2023

How to patch adding volumes and volumeMounts?

What I tried?

$ cat patch.yaml
- op: add
  path: /spec/template/spec/containers/0/volumeMounts
  value:
    - name: trace-result
      mountPath: /tmp/results
- op: add
  path: /spec/template/spec/volumes
  value:
    - name: trace-result
      hostPath:
        path: /tmp/trace-results
        type: DirectoryOrCreate
$ kubectl trace run pod/some-pod \
  --patch-type json \
  --patch patch.yaml \
  -f some.bt --attach

Expected Pod Spec VolumeMounts

$ kubectl get pod kubectl-trace-299c5a64-0ec0-4846-9960-1cb2a4275a05--1-ct4d2 -o jsonpath="{.spec.containers[0].volumeMounts}" | yq . -P
- mountPath: /programs
  name: program
  readOnly: true
- mountPath: /sys
  name: sys
  readOnly: true
- mountPath: /usr-host
  name: usr-host
  readOnly: true
- mountPath: /lib/modules
  name: modules-host
  readOnly: true
- name: trace-result # Here I added
  mountPath: /tmp/results
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
  name: kube-api-access-95fr5
  readOnly: true

Actual Results for Pod Spec VolumeMounts

$ kubectl get pod kubectl-trace-299c5a64-0ec0-4846-9960-1cb2a4275a05--1-ct4d2 -o jsonpath="{.spec.containers[0].volumeMounts}" | yq . -P
- mountPath: /tmp/results
  name: trace-result
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
  name: kube-api-access-lsmjb
  readOnly: true

Where the items program, sys, usr-host, modules-host has gone? I think it replace d items, instead of add which I wrote as the value of op item in patch.yaml.

I just represented for volumeMounts here, but volumes also works in the same way.

Alternative Method?

I tried to fix container name of kubectl-trace pod and tried strategic patch, with creating new PR, but it breaks some integration test - failing TestKubectlTraceSuite/TestDeploymentTarget. Does anyone can help me how to deal integration tests?

Additional feature request

How about adding --dry-run option on kubectl-trace run, to check which resources are going to be deployed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant