I am writing a GitLab-ci.yaml file for my application and in that I have to run the kubectl command to get all pods after I ran the command I got the names of the pods which I need but ow the thing is I have to run kubectl cp command and need to copy a file into all three pods but I don't know the way to perform this action.
If anyone knows the way to do this activity then please reply.
Thanks
CodePudding user response:
job:
script:
- |
for pod in $(kubectl get po -o jsonpath='{.items[*].metadata.name} -n your-namespace')
do
kubectl cp $(pwd)/some-file.txt your-namespace/$pod:/
done
CodePudding user response:
deploy:
image:
name: bitnami/kubectl:latest
entrypoint: ['']
script:
- kubectl config get-contexts
- kubectl config use-context path/to/agent/repository:agent-name
- kubectl get pods