Summary of Common KUBECTL commands

Source: Internet
Author: User

Command KUBECTLKUBECTL output format
    • Show pod for more information
      kubectl get pod <pod-name> -o wide
    • Show pod details in YAML format
      kubectl get pod <pod-name> -o yaml
Kubectl Operation Example 1. Create a Resource object
    • Create service and RC at once based on Yaml configuration file
      kubectl create -f my-service.yaml -f my-rc.yaml
    • <directory>create operations based on the definition of all. Yaml,. yml,. json files in the directory
      kubectl create -f <directory>
2. View Resource Objects
    • View All Pod Listings
      kubectl get pods
    • View RC and Service lists
      kubectl get rc,service
3. Describe the resource object
    • Show Node's details
      kubectl describe nodes <node-name>
    • Show pod Details
      kubectl describe pods/<pod-name>
    • Display information for pods managed by RC
      kubectl describe pods <rc-name>
4. Delete a Resource object
    • Delete pod based on the name of the POD.YAML definition
      kubectl delete -f pod.yaml
    • Remove all pods and service that contain a label
      kubectl delete pods,services -l name=<label-name>
    • Delete all Pods
      kubectl delete pods --all
5. Command to execute a container
    • The data command to execute the pod, which is performed by default with the first container in the pod
      kubectl exec <pod-name> data
    • Specify a container in the pod to execute the data command
      kubectl exec <pod-name> -c <container-name> data
    • Use bash to get a TTY for a container in the pod, equivalent to the login container
      kubectl exec -it <pod-name> -c <container-name> bash
6.Pod expansion and contraction capacity
    • Perform an operation that expands the capacity of the indent pod
      kubectl scale rc redis --replicas=3

      We need to confirm that the number of replicas defined in the RC configuration file, when we execute the above command result is greater than the number of replicas, then we execute the command equivalent to the expansion operation, conversely, we can understand that the amount we fill is the number of pods we need. It is important to note that when we need to do a permanent expansion, don't forget to modify the number of replicas in the RC configuration file.

7.Pod Roll-up upgrade
      • Perform a rolling upgrade operation
        kubectl rolling-update redis -f redis-rc.update.yaml

        It is important to note that when we rolling-update need to prepare a new RC configuration file and a Configmap configuration file before executing the command, the RC configuration file needs to specify the name of the image to be used after the upgrade, or you can kubeclt rolling-update redis --image=redis-2.0 upgrade directly by specifying the image name directly.

Source: https://www.cnblogs.com/Cherry-Linux/p/7866427.html

Summary of Common KUBECTL commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.