kubectl

Description

Mind Map on kubectl, created by Luiz Eduardo on 19/03/2022.
Luiz  Eduardo
Mind Map by Luiz Eduardo, updated more than 1 year ago
Luiz  Eduardo
Created by Luiz Eduardo over 2 years ago
323
0

Resource summary

kubectl

Annotations:

  • https://kubernetes.io/docs/reference/kubectl/cheatsheet/https://kubernetes.io/docs/reference/kubectl/ https://kubernetes.io/docs/reference/kubectl/
  1. Useful
    1. kubectl create

      Annotations:

      • Run kubectl create to see a list of objects that can be created with imperative commands.
      1. kubectl create deployment my-deployment --image=nginx

        Annotations:

        • Create a deployment imperatively.
        1. kubectl create deployment my-deployment --image=nginx --dry-run -o yaml

          Annotations:

          • Do a dry run to get some sample yaml without creating the object.
          1. kubectl create deployment my-deployment --image=nginx --dry-run -o yaml > deployment.yml

            Annotations:

            • Save the yaml to a file.
            1. kubectl create -f deployment.yml

              Annotations:

              • Create the object using the file.
              1. kubectl scale deployment my-deployment replicas=5 --record

                Annotations:

                • Scale a deployment and record the command.
                1. kubectl describe deployment my-deployment
                  1. kubectl apply -f FILENAME [flags]
                    1. kubectl drain NODE [options]
                      1. kubectl delete (-f FILENAME | TYPE [NAME | /NAME | -l label | --all]) [flags]
                        1. kubectl describe (-f FILENAME | TYPE [NAME_PREFIX | /NAME | -l label]) [flags]
                          1. kubectl exec POD [-c CONTAINER] [-i] [-t] [flags] [-- COMMAND [args...]]
                            1. kubectl expose
                              1. kubectl label
                                1. kubectl logs POD [-c CONTAINER] [--follow] [flags]
                                  1. kubectl port-forward POD [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N] [flags]
                                    1. kubectl uncordon NODE [options]
                                      1. kubectl version [--client] [flags]
                                        1. kubectl api-resources
                                          1. kubectl get pods <pod-name> --server-print=false
                                            1. kubecyl apply
                                              1. kubectl apply -f example-service.yaml

                                                Annotations:

                                                • # Create a service using the definition in example-service.yaml.
                                                1. kubectl apply -f example-controller.yaml

                                                  Annotations:

                                                  • # Create a replication controller using the definition in example-controller.yaml.
                                                  1. kubectl apply -f <directory>

                                                    Annotations:

                                                    • # Create the objects that are defined in any .yaml, .yml, or .json file within the &lt;directory&gt; directory.
                                                  2. kubectl get
                                                    1. kubectl get pods -o wide
                                                      1. kubectl get replicationcontroller <rc-name>

                                                        Annotations:

                                                        • # List the replication controller with the specified name in plain-text output format. Tip: You can shorten and replace the 'replicationcontroller' resource type with the alias 'rc'.
                                                        1. kubectl get rc,services

                                                          Annotations:

                                                          • # List all replication controllers and services together in plain-text output format.
                                                          1. kubectl get ds

                                                            Annotations:

                                                            • # List all daemon sets in plain-text output format.
                                                            1. kubectl get pods --field-selector=spec.nodeName=server01

                                                              Annotations:

                                                              • # List all pods running on node server01
                                                              1. kubectl get pods -n kube-system
                                                                1. kubectl get pods -n kube-system --selector k8s-app=calico-node
                                                                  1. kubectl get pv

                                                                    Annotations:

                                                                    • kubectl get pv -o yaml&nbsp; _____to get the values and sort them&nbsp; --sort-by=.spec....
                                                                    1. kubectl get pv --sort-by=.spec.capacity.storage
                                                                  2. kubectl config get-contexts
                                                                    1. kubectl config current-context
                                                                      1. kubectl config use-context my-cluster-name
                                                                        1. kubectl config set-context --current --namespace=ggckad-s2
                                                                          1. kubectl config set-context gce --user=cluster-admin --namespace=foo \ && kubectl config use-context gce
                                                                            1. kubectl get pods -n beebox-mobile --kubeconfig /home/cloud_user/dev-k8s-config
                                                                              1. kubectl top po -n beebox-mobile --sort-by=cpu --selector=app=auth > /home/cloud_user/cpu-pod-name.txt
                                                                              2. output systax
                                                                                1. kubectl [command] [TYPE] [NAME] -o <output_format>

                                                                                  Annotations:

                                                                                  • The default output format for all&nbsp;kubectl&nbsp;commands is the human readable plain-text format. To output details to your terminal window in a specific format, you can add either the&nbsp;-o&nbsp;or&nbsp;--output&nbsp;flags to a supported&nbsp;kubectl&nbsp;command.
                                                                                  1. Output format
                                                                                    1. -o custom-columns=<spec>

                                                                                      Annotations:

                                                                                      • Print a table using a comma separated list of&nbsp;custom columns.
                                                                                      1. kubectl get pods <pod-name> -o custom-columns=NAME:.metadata.name,RSRC:.metadata.resourceVersion
                                                                                      2. -o custom-columns-file=<filename>

                                                                                        Annotations:

                                                                                        • Print a table using the&nbsp;custom columns&nbsp;template in the&nbsp;&lt;filename&gt;&nbsp;file.
                                                                                        1. kubectl get pods <pod-name> -o custom-columns-file=template.txt

                                                                                          Annotations:

                                                                                          • where the&nbsp;template.txt&nbsp;file contains: NAME RSRC metadata.name metadata.resourceVersion
                                                                                        2. -o json

                                                                                          Annotations:

                                                                                          • Output a JSON formatted API object.
                                                                                          1. -o jsonpath=<template>

                                                                                            Annotations:

                                                                                            • Print the fields defined in a&nbsp;jsonpath&nbsp;expression.
                                                                                            1. -o jsonpath-file=<filename>
                                                                                              1. -o name
                                                                                                1. -o wide
                                                                                                  1. -o yaml
                                                                                                    1. kubectl get pod web-pod-13je7 -o yaml
                                                                                                2. kubectl get clusterrolebindings
                                                                                                  Show full summary Hide full summary

                                                                                                  Similar

                                                                                                  English Vocabulary
                                                                                                  Niat Habtemariam
                                                                                                  Korean Grammar Basics
                                                                                                  Eunha Seo
                                                                                                  P2 Radioactivity and Stars
                                                                                                  dfreeman
                                                                                                  Mapa Conceptual de Liderazgo
                                                                                                  gabbi.mendoza
                                                                                                  Biology (B2)
                                                                                                  anjumn10
                                                                                                  GCSE History – The early years and the Weimar Republic 1918-1923
                                                                                                  Ben C
                                                                                                  Poetry revision quiz
                                                                                                  Sarah Holmes
                                                                                                  Contract Law
                                                                                                  sherhui94
                                                                                                  Meteorologia II
                                                                                                  Adriana Forero
                                                                                                  1PR101 2.test - Část 8.
                                                                                                  Nikola Truong
                                                                                                  TISSUE TYPES
                                                                                                  Missi Shoup