Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities.
Writing in the front
Kubectl is a tool to operate K8S containers, here operation partners may be more clear, but as a research and development of us, we should also study, every day is actually fighting side by side with it, that is deployment service, we delete containers, in order to achieve the purpose of rapid deployment.
(Back-end engineers should know more operational skills)
Those of you who know K8S know that we pack images into a container, which is also a small operating system.
The file transfer
Usually if we do file transfer with the Linux server (regardless of the client, with the command type)
Upload the local file to the server
scp -P 58010 xxx.tar.gz [email protected]: /usr/local/data/
Copy the code
Note 58010 is the port number, xxx.tar.gz is the local file, and [email protected] is the login account and address of the server
/usr/local/data/ is the directory to transfer files to the remote server
It’s easy, and most backend engineers know this too. So let’s look at the kubectl file
Kubectl remote transmission
Tips: The container is not on a particular machine, so we must be operating on an image, not a server.
Kubectl copies local files inside the container
The command is as follows:
kubectl -n namespace cp ./file.yaml pod:/folder/file.yaml
Copy the code
Namespace: Workspace POD, which is the pod indicated by the arrow in the figure above
kubectl -n dev cp ./api.yaml config-86948c5dc5-fwvjd:/usr/local/tomcat/webapps/api.yaml
Copy the code
Dev is the namespace tool breaks, c5dc5 config – 86948 – FWVJD is pod,. / TSH – API. Yaml is to upload the file, / usr/local/tomcat/webapps/TSH – API. Yaml is the address of the remote directory
Kubectl copies the files in the container locally
kubectl cp dev/config-86948c5dc5-fwvjd:/usr/local/tomcat/webapps/api.yaml api.yaml
Copy the code
Ok, so let me just write that down. I believe you must use it in the future!!
overtones
Thank you for reading, if you feel that you have learned something, please like, follow. Also welcome to have a question we comment below exchange
Come on! See you next time!
To share with you a few I wrote in front of a few SAO operation
Talk about different strategy patterns (Bookmarks)
Copy object, this operation is a little SAO!