Kubernetes Lab -Day6 Suresh

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

[root@sureshmaster ~]# mkdir suresh
[root@sureshmaster ~]# cd suresh
[root@sureshmaster suresh]# vi pod.yaml
[root@sureshmaster suresh]# ls
pod.yaml
[root@sureshmaster suresh]# kubectl get ns
NAME              STATUS   AGE
default           Active   2d21h
kube-node-lease   Active   2d21h
kube-public       Active   2d21h
kube-system       Active   2d21h
[root@sureshmaster suresh]# kubectl create ns suresh
namespace/suresh created
[root@sureshmaster suresh]# kubectl get ns
NAME              STATUS   AGE
default           Active   2d21h
kube-node-lease   Active   2d21h
kube-public       Active   2d21h
kube-system       Active   2d21h
suresh            Active   4s
[root@sureshmaster suresh]# kubectl get pods
No resources found in default namespace.
[root@sureshmaster suresh]# kubectl get pods -n=suresh
No resources found in suresh namespace.
[root@sureshmaster suresh]# kubectl get pods -n=dev
No resources found in dev namespace.
[root@sureshmaster suresh]# kubectl create -f pod.yaml
pod/nodehelloworld.example.com created
[root@sureshmaster suresh]# kubectl create -f pod.yaml -n=suresh
pod/nodehelloworld.example.com created
[root@sureshmaster suresh]# kubectl get pods -n=suresh
NAME                         READY   STATUS    RESTARTS   AGE
nodehelloworld.example.com   1/1     Running   0          9s
[root@sureshmaster suresh]# kubectl get pods -n=suresh
NAME                         READY   STATUS    RESTARTS   AGE
nodehelloworld.example.com   1/1     Running   0          14s
[root@sureshmaster suresh]# kubectl get pods
NAME                         READY   STATUS    RESTARTS   AGE
nodehelloworld.example.com   1/1     Running   0          37s
[root@sureshmaster suresh]# kubectl get pods -n=suresh,dev
No resources found in suresh,dev namespace.
[root@sureshmaster suresh]# kubectl get pods -all-namespaces
Error: unknown shorthand flag: 'a' in -all-namespaces
See 'kubectl get --help' for usage.
[root@sureshmaster suresh]# kubectl get pods --all-namespaces
NAMESPACE     NAME                                   READY   STATUS    RESTARTS   AGE
default       nodehelloworld.example.com             1/1     Running   0          81s
kube-system   coredns-558bd4d5db-48jwt               1/1     Running   0          2d21h
kube-system   coredns-558bd4d5db-ntpbc               1/1     Running   0          2d21h
kube-system   etcd-sureshmaster                      1/1     Running   0          2d21h
kube-system   kube-apiserver-sureshmaster            1/1     Running   0          2d21h
kube-system   kube-controller-manager-sureshmaster   1/1     Running   0          2d21h
kube-system   kube-proxy-9vtq5                       1/1     Running   0          2d21h
kube-system   kube-proxy-lv4nr                       1/1     Running   0          2d21h
kube-system   kube-scheduler-sureshmaster            1/1     Running   0          2d21h
kube-system   weave-net-9h6nd                        2/2     Running   1          2d21h
kube-system   weave-net-pbc92                        2/2     Running   0          2d21h
suresh        nodehelloworld.example.com             1/1     Running   0          62s
[root@sureshmaster suresh]# kubectl get pods -o wide
NAME                         READY   STATUS    RESTARTS   AGE   IP          NODE           NOMINATED NODE   READINESS GATES
nodehelloworld.example.com   1/1     Running   0          99s   10.44.0.1   sureshworker   <none>           <none>
[root@sureshmaster suresh]# ping 10.44.0.1
PING 10.44.0.1 (10.44.0.1) 56(84) bytes of data.
64 bytes from 10.44.0.1: icmp_seq=1 ttl=64 time=1.38 ms
64 bytes from 10.44.0.1: icmp_seq=2 ttl=64 time=0.636 ms
64 bytes from 10.44.0.1: icmp_seq=3 ttl=64 time=0.627 ms
64 bytes from 10.44.0.1: icmp_seq=4 ttl=64 time=0.751 ms
64 bytes from 10.44.0.1: icmp_seq=5 ttl=64 time=0.620 ms
64 bytes from 10.44.0.1: icmp_seq=6 ttl=64 time=1.14 ms
64 bytes from 10.44.0.1: icmp_seq=7 ttl=64 time=0.573 ms
64 bytes from 10.44.0.1: icmp_seq=8 ttl=64 time=0.619 ms
64 bytes from 10.44.0.1: icmp_seq=9 ttl=64 time=1.20 ms
64 bytes from 10.44.0.1: icmp_seq=10 ttl=64 time=0.813 ms
64 bytes from 10.44.0.1: icmp_seq=11 ttl=64 time=1.13 ms
64 bytes from 10.44.0.1: icmp_seq=12 ttl=64 time=0.548 ms
64 bytes from 10.44.0.1: icmp_seq=13 ttl=64 time=1.23 ms
64 bytes from 10.44.0.1: icmp_seq=14 ttl=64 time=0.665 ms
64 bytes from 10.44.0.1: icmp_seq=15 ttl=64 time=1.16 ms
64 bytes from 10.44.0.1: icmp_seq=16 ttl=64 time=0.917 ms
64 bytes from 10.44.0.1: icmp_seq=17 ttl=64 time=0.528 ms
64 bytes from 10.44.0.1: icmp_seq=18 ttl=64 time=0.785 ms
64 bytes from 10.44.0.1: icmp_seq=19 ttl=64 time=1.13 ms
64 bytes from 10.44.0.1: icmp_seq=20 ttl=64 time=0.612 ms
64 bytes from 10.44.0.1: icmp_seq=21 ttl=64 time=0.865 ms
64 bytes from 10.44.0.1: icmp_seq=22 ttl=64 time=0.679 ms
64 bytes from 10.44.0.1: icmp_seq=23 ttl=64 time=0.604 ms
64 bytes from 10.44.0.1: icmp_seq=24 ttl=64 time=0.637 ms
64 bytes from 10.44.0.1: icmp_seq=25 ttl=64 time=1.19 ms
64 bytes from 10.44.0.1: icmp_seq=26 ttl=64 time=0.500 ms
64 bytes from 10.44.0.1: icmp_seq=27 ttl=64 time=0.930 ms
64 bytes from 10.44.0.1: icmp_seq=28 ttl=64 time=0.641 ms
64 bytes from 10.44.0.1: icmp_seq=29 ttl=64 time=0.801 ms
64 bytes from 10.44.0.1: icmp_seq=30 ttl=64 time=0.624 ms
64 bytes from 10.44.0.1: icmp_seq=31 ttl=64 time=0.735 ms
64 bytes from 10.44.0.1: icmp_seq=32 ttl=64 time=1.15 ms
64 bytes from 10.44.0.1: icmp_seq=33 ttl=64 time=1.03 ms
64 bytes from 10.44.0.1: icmp_seq=34 ttl=64 time=0.644 ms
64 bytes from 10.44.0.1: icmp_seq=35 ttl=64 time=0.894 ms
64 bytes from 10.44.0.1: icmp_seq=36 ttl=64 time=0.610 ms
64 bytes from 10.44.0.1: icmp_seq=37 ttl=64 time=0.612 ms
64 bytes from 10.44.0.1: icmp_seq=38 ttl=64 time=0.910 ms
64 bytes from 10.44.0.1: icmp_seq=39 ttl=64 time=0.955 ms
64 bytes from 10.44.0.1: icmp_seq=40 ttl=64 time=0.847 ms
64 bytes from 10.44.0.1: icmp_seq=41 ttl=64 time=1.19 ms
64 bytes from 10.44.0.1: icmp_seq=42 ttl=64 time=1.23 ms
64 bytes from 10.44.0.1: icmp_seq=43 ttl=64 time=1.10 ms
64 bytes from 10.44.0.1: icmp_seq=44 ttl=64 time=0.915 ms
64 bytes from 10.44.0.1: icmp_seq=45 ttl=64 time=1.05 ms
64 bytes from 10.44.0.1: icmp_seq=46 ttl=64 time=0.462 ms
64 bytes from 10.44.0.1: icmp_seq=47 ttl=64 time=0.979 ms
64 bytes from 10.44.0.1: icmp_seq=48 ttl=64 time=0.841 ms
64 bytes from 10.44.0.1: icmp_seq=49 ttl=64 time=1.13 ms
64 bytes from 10.44.0.1: icmp_seq=50 ttl=64 time=0.605 ms
64 bytes from 10.44.0.1: icmp_seq=51 ttl=64 time=1.02 ms
64 bytes from 10.44.0.1: icmp_seq=52 ttl=64 time=1.24 ms
64 bytes from 10.44.0.1: icmp_seq=53 ttl=64 time=1.13 ms
64 bytes from 10.44.0.1: icmp_seq=54 ttl=64 time=1.36 ms
64 bytes from 10.44.0.1: icmp_seq=55 ttl=64 time=1.12 ms
64 bytes from 10.44.0.1: icmp_seq=56 ttl=64 time=1.16 ms
64 bytes from 10.44.0.1: icmp_seq=57 ttl=64 time=0.920 ms
64 bytes from 10.44.0.1: icmp_seq=58 ttl=64 time=0.632 ms
64 bytes from 10.44.0.1: icmp_seq=59 ttl=64 time=1.19 ms
64 bytes from 10.44.0.1: icmp_seq=60 ttl=64 time=0.523 ms
64 bytes from 10.44.0.1: icmp_seq=61 ttl=64 time=1.14 ms
64 bytes from 10.44.0.1: icmp_seq=62 ttl=64 time=0.824 ms
64 bytes from 10.44.0.1: icmp_seq=63 ttl=64 time=1.25 ms
64 bytes from 10.44.0.1: icmp_seq=64 ttl=64 time=0.612 ms
64 bytes from 10.44.0.1: icmp_seq=65 ttl=64 time=0.828 ms
64 bytes from 10.44.0.1: icmp_seq=66 ttl=64 time=0.601 ms
64 bytes from 10.44.0.1: icmp_seq=67 ttl=64 time=0.584 ms
64 bytes from 10.44.0.1: icmp_seq=68 ttl=64 time=0.525 ms
64 bytes from 10.44.0.1: icmp_seq=69 ttl=64 time=0.912 ms
64 bytes from 10.44.0.1: icmp_seq=70 ttl=64 time=0.912 ms
64 bytes from 10.44.0.1: icmp_seq=71 ttl=64 time=1.00 ms
64 bytes from 10.44.0.1: icmp_seq=72 ttl=64 time=1.19 ms
64 bytes from 10.44.0.1: icmp_seq=73 ttl=64 time=1.08 ms
64 bytes from 10.44.0.1: icmp_seq=74 ttl=64 time=1.16 ms
64 bytes from 10.44.0.1: icmp_seq=75 ttl=64 time=0.940 ms
64 bytes from 10.44.0.1: icmp_seq=76 ttl=64 time=0.642 ms
64 bytes from 10.44.0.1: icmp_seq=77 ttl=64 time=1.03 ms
64 bytes from 10.44.0.1: icmp_seq=78 ttl=64 time=0.795 ms
64 bytes from 10.44.0.1: icmp_seq=79 ttl=64 time=0.909 ms
64 bytes from 10.44.0.1: icmp_seq=80 ttl=64 time=0.729 ms
64 bytes from 10.44.0.1: icmp_seq=81 ttl=64 time=0.899 ms
64 bytes from 10.44.0.1: icmp_seq=82 ttl=64 time=0.582 ms
64 bytes from 10.44.0.1: icmp_seq=83 ttl=64 time=0.610 ms
64 bytes from 10.44.0.1: icmp_seq=84 ttl=64 time=0.615 ms
64 bytes from 10.44.0.1: icmp_seq=85 ttl=64 time=0.629 ms
64 bytes from 10.44.0.1: icmp_seq=86 ttl=64 time=0.691 ms
64 bytes from 10.44.0.1: icmp_seq=87 ttl=64 time=0.760 ms
^C
--- 10.44.0.1 ping statistics ---
87 packets transmitted, 87 received, 0% packet loss, time 86084ms
rtt min/avg/max/mdev = 0.462/0.865/1.388/0.245 ms
[root@sureshmaster suresh]# kubectl get pods
NAME                         READY   STATUS    RESTARTS   AGE
nodehelloworld.example.com   1/1     Running   0          3m28s
[root@sureshmaster suresh]# kubectl edit pod nodehelloworld.example.com
pod/nodehelloworld.example.com edited
[root@sureshmaster suresh]# kubectl edit pod --show-labels
Error: unknown flag: --show-labels
See 'kubectl edit --help' for usage.
[root@sureshmaster suresh]# kubectl get  pod --show-labels
NAME                         READY   STATUS    RESTARTS   AGE     LABELS
nodehelloworld.example.com   1/1     Running   0          4m59s   app=helloworld,server=apiserver
[root@sureshmaster suresh]# kubectl -h
kubectl controls the Kubernetes cluster manager.

 Find more information at: https://kubernetes.io/docs/reference/kubectl/overview/

Basic Commands (Beginner):
  create        Create a resource from a file or from stdin.
  expose        Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
  run           Run a particular image on the cluster
  set           Set specific features on objects

Basic Commands (Intermediate):
  explain       Documentation of resources
  get           Display one or many resources
  edit          Edit a resource on the server
  delete        Delete resources by filenames, stdin, resources and names, or by resources and label selector

Deploy Commands:
  rollout       Manage the rollout of a resource
  scale         Set a new size for a Deployment, ReplicaSet or Replication Controller
  autoscale     Auto-scale a Deployment, ReplicaSet, StatefulSet, or ReplicationController

Cluster Management Commands:
  certificate   Modify certificate resources.
  cluster-info  Display cluster info
  top           Display Resource (CPU/Memory) usage.
  cordon        Mark node as unschedulable
  uncordon      Mark node as schedulable
  drain         Drain node in preparation for maintenance
  taint         Update the taints on one or more nodes

Troubleshooting and Debugging Commands:
  describe      Show details of a specific resource or group of resources
  logs          Print the logs for a container in a pod
  attach        Attach to a running container
  exec          Execute a command in a container
  port-forward  Forward one or more local ports to a pod
  proxy         Run a proxy to the Kubernetes API server
  cp            Copy files and directories to and from containers.
  auth          Inspect authorization
  debug         Create debugging sessions for troubleshooting workloads and nodes

Advanced Commands:
  diff          Diff live version against would-be applied version
  apply         Apply a configuration to a resource by filename or stdin
  patch         Update field(s) of a resource
  replace       Replace a resource by filename or stdin
  wait          Experimental: Wait for a specific condition on one or many resources.
  kustomize     Build a kustomization target from a directory or URL.

Settings Commands:
  label         Update the labels on a resource
  annotate      Update the annotations on a resource
  completion    Output shell completion code for the specified shell (bash or zsh)

Other Commands:
  api-resources Print the supported API resources on the server
  api-versions  Print the supported API versions on the server, in the form of "group/version"
  config        Modify kubeconfig files
  plugin        Provides utilities for interacting with plugins.
  version       Print the client and server version information

Usage:
  kubectl [flags] [options]

Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).
[root@sureshmaster suresh]# kubectl get -h
Display one or many resources

 Prints a table of the most important information about the specified resources. You can filter the list using a label
selector and the --selector flag. If the desired resource type is namespaced you will only see results in your current
namespace unless you pass --all-namespaces.

 Uninitialized objects are not shown unless --include-uninitialized is passed.

 By specifying the output as 'template' and providing a Go template as the value of the --template flag, you can filter
the attributes of the fetched resources.

Use "kubectl api-resources" for a complete list of supported resources.

Examples:
  # List all pods in ps output format.
  kubectl get pods

  # List all pods in ps output format with more information (such as node name).
  kubectl get pods -o wide

  # List a single replication controller with specified NAME in ps output format.
  kubectl get replicationcontroller web

  # List deployments in JSON output format, in the "v1" version of the "apps" API group:
  kubectl get deployments.v1.apps -o json

  # List a single pod in JSON output format.
  kubectl get -o json pod web-pod-13je7

  # List a pod identified by type and name specified in "pod.yaml" in JSON output format.
  kubectl get -f pod.yaml -o json

  # List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml.
  kubectl get -k dir/

  # Return only the phase value of the specified pod.
  kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}

  # List resource information in custom columns.
  kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image

  # List all replication controllers and services together in ps output format.
  kubectl get rc,services

  # List one or more resources by their type and names.
  kubectl get rc/web service/frontend pods/web-pod-13je7

Options:
  -A, --all-namespaces=false: If present, list the requested object(s) across all namespaces. Namespace in current
context is ignored even if specified with --namespace.
      --allow-missing-template-keys=true: If true, ignore any errors in templates when a field or map key is missing in
the template. Only applies to golang and jsonpath output formats.
      --chunk-size=500: Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and
may change in the future.
      --field-selector='': Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector
key1=value1,key2=value2). The server only supports a limited number of field queries per type.
  -f, --filename=[]: Filename, directory, or URL to files identifying the resource to get from a server.
      --ignore-not-found=false: If the requested object does not exist the command will return exit code 0.
  -k, --kustomize='': Process the kustomization directory. This flag can't be used together with -f or -R.
  -L, --label-columns=[]: Accepts a comma separated list of labels that are going to be presented as columns. Names are
case-sensitive. You can also use multiple flag options like -L label1 -L label2...
      --no-headers=false: When using the default or custom-column output format, don't print headers (default print
headers).
  -o, --output='': Output format. One of:
json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...
See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template
[http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template
[http://kubernetes.io/docs/user-guide/jsonpath].
      --output-watch-events=false: Output watch event objects when --watch or --watch-only is used. Existing objects are
output as initial ADDED events.
      --raw='': Raw URI to request from the server.  Uses the transport specified by the kubeconfig file.
  -R, --recursive=false: Process the directory used in -f, --filename recursively. Useful when you want to manage
related manifests organized within the same directory.
  -l, --selector='': Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
      --server-print=true: If true, have the server return the appropriate table output. Supports extension APIs and
CRDs.
      --show-kind=false: If present, list the resource type for the requested object(s).
      --show-labels=false: When printing, show all labels as the last column (default hide labels column)
      --show-managed-fields=false: If true, keep the managedFields when printing objects in JSON or YAML format.
      --sort-by='': If non-empty, sort list types using this field specification.  The field specification is expressed
as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression
must be an integer or a string.
      --template='': Template string or path to template file to use when -o=go-template, -o=go-template-file. The
template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
  -w, --watch=false: After listing/getting the requested object, watch for changes. Uninitialized objects are excluded
if no object name is provided.
      --watch-only=false: Watch for changes to the requested object(s), without listing/getting first.

Usage:
  kubectl get
[(-o|--output=)json|yaml|wide|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...]
(TYPE[.VERSION][.GROUP] [NAME | -l label] | TYPE[.VERSION][.GROUP]/NAME ...) [flags] [options]

Use "kubectl options" for a list of global command-line options (applies to all commands).
[root@sureshmaster suresh]# kubectl get pods -h
Display one or many resources

 Prints a table of the most important information about the specified resources. You can filter the list using a label
selector and the --selector flag. If the desired resource type is namespaced you will only see results in your current
namespace unless you pass --all-namespaces.

 Uninitialized objects are not shown unless --include-uninitialized is passed.

 By specifying the output as 'template' and providing a Go template as the value of the --template flag, you can filter
the attributes of the fetched resources.

Use "kubectl api-resources" for a complete list of supported resources.

Examples:
  # List all pods in ps output format.
  kubectl get pods

  # List all pods in ps output format with more information (such as node name).
  kubectl get pods -o wide

  # List a single replication controller with specified NAME in ps output format.
  kubectl get replicationcontroller web

  # List deployments in JSON output format, in the "v1" version of the "apps" API group:
  kubectl get deployments.v1.apps -o json

  # List a single pod in JSON output format.
  kubectl get -o json pod web-pod-13je7

  # List a pod identified by type and name specified in "pod.yaml" in JSON output format.
  kubectl get -f pod.yaml -o json

  # List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml.
  kubectl get -k dir/

  # Return only the phase value of the specified pod.
  kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}

  # List resource information in custom columns.
  kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image

  # List all replication controllers and services together in ps output format.
  kubectl get rc,services

  # List one or more resources by their type and names.
  kubectl get rc/web service/frontend pods/web-pod-13je7

Options:
  -A, --all-namespaces=false: If present, list the requested object(s) across all namespaces. Namespace in current
context is ignored even if specified with --namespace.
      --allow-missing-template-keys=true: If true, ignore any errors in templates when a field or map key is missing in
the template. Only applies to golang and jsonpath output formats.
      --chunk-size=500: Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and
may change in the future.
      --field-selector='': Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector
key1=value1,key2=value2). The server only supports a limited number of field queries per type.
  -f, --filename=[]: Filename, directory, or URL to files identifying the resource to get from a server.
      --ignore-not-found=false: If the requested object does not exist the command will return exit code 0.
  -k, --kustomize='': Process the kustomization directory. This flag can't be used together with -f or -R.
  -L, --label-columns=[]: Accepts a comma separated list of labels that are going to be presented as columns. Names are
case-sensitive. You can also use multiple flag options like -L label1 -L label2...
      --no-headers=false: When using the default or custom-column output format, don't print headers (default print
headers).
  -o, --output='': Output format. One of:
json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...
See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template
[http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template
[http://kubernetes.io/docs/user-guide/jsonpath].
      --output-watch-events=false: Output watch event objects when --watch or --watch-only is used. Existing objects are
output as initial ADDED events.
      --raw='': Raw URI to request from the server.  Uses the transport specified by the kubeconfig file.
  -R, --recursive=false: Process the directory used in -f, --filename recursively. Useful when you want to manage
related manifests organized within the same directory.
  -l, --selector='': Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
      --server-print=true: If true, have the server return the appropriate table output. Supports extension APIs and
CRDs.
      --show-kind=false: If present, list the resource type for the requested object(s).
      --show-labels=false: When printing, show all labels as the last column (default hide labels column)
      --show-managed-fields=false: If true, keep the managedFields when printing objects in JSON or YAML format.
      --sort-by='': If non-empty, sort list types using this field specification.  The field specification is expressed
as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression
must be an integer or a string.
      --template='': Template string or path to template file to use when -o=go-template, -o=go-template-file. The
template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
  -w, --watch=false: After listing/getting the requested object, watch for changes. Uninitialized objects are excluded
if no object name is provided.
      --watch-only=false: Watch for changes to the requested object(s), without listing/getting first.

Usage:
  kubectl get
[(-o|--output=)json|yaml|wide|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...]
(TYPE[.VERSION][.GROUP] [NAME | -l label] | TYPE[.VERSION][.GROUP]/NAME ...) [flags] [options]

Use "kubectl options" for a list of global command-line options (applies to all commands).
[root@sureshmaster suresh]# vi pod.yml
[root@sureshmaster suresh]# vi pod.yaml
[root@sureshmaster suresh]# kubectl apply -f pod.yml
error: the path "pod.yml" does not exist
[root@sureshmaster suresh]# kubectl apply -f pod.yaml
error: error validating "pod.yaml": error validating data: ValidationError(Pod.metadata): unknown field "server" in io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta; if you choose to ignore these errors, turn validation off with --validate=false
[root@sureshmaster suresh]# kubectl get pods
NAME                         READY   STATUS    RESTARTS   AGE
nodehelloworld.example.com   1/1     Running   0          8m28s
[root@sureshmaster suresh]# kubectl delete pod nodehelloworld.example.com
pod "nodehelloworld.example.com" deleted
[root@sureshmaster suresh]# kubectl delete pod nodehelloworld.example.com -n=rajesh
Error from server (NotFound): pods "nodehelloworld.example.com" not found
[root@sureshmaster suresh]# kubectl delete pod nodehelloworld.example.com -n=suresh
pod "nodehelloworld.example.com" deleted
[root@sureshmaster suresh]# kubectl delete pod nodehelloworld.example.com -n=sures
Error from server (NotFound): pods "nodehelloworld.example.com" not found
[root@sureshmaster suresh]# kubectl get pods -all-namespaces
Error: unknown shorthand flag: 'a' in -all-namespaces
See 'kubectl get --help' for usage.
[root@sureshmaster suresh]# kubectl get pods --all-namespaces
NAMESPACE     NAME                                   READY   STATUS    RESTARTS   AGE
kube-system   coredns-558bd4d5db-48jwt               1/1     Running   0          2d21h
kube-system   coredns-558bd4d5db-ntpbc               1/1     Running   0          2d21h
kube-system   etcd-sureshmaster                      1/1     Running   0          2d21h
kube-system   kube-apiserver-sureshmaster            1/1     Running   0          2d21h
kube-system   kube-controller-manager-sureshmaster   1/1     Running   0          2d21h
kube-system   kube-proxy-9vtq5                       1/1     Running   0          2d21h
kube-system   kube-proxy-lv4nr                       1/1     Running   0          2d21h
kube-system   kube-scheduler-sureshmaster            1/1     Running   0          2d21h
kube-system   weave-net-9h6nd                        2/2     Running   1          2d21h
kube-system   weave-net-pbc92                        2/2     Running   0          2d21h
[root@sureshmaster suresh]# history
    1  ifconfig
    2  yum update
    3  ifconfig
    4  exit
    5  hostnamectl set-hostname sureshmaster
    6  sudo -s
    7  exit
    8  sudo yum install -y yum-utils device-mapper-persistent-data lvm2
    9  sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
   10  sudo yum install –y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
   11  sudo yum-config-manager --enable rhui-REGION-rhel-server-extras
   12  sudo yum install -y docker-ce
   13  sudo yum install docker-ce
   14  sudo systemctl enable docker
   15  sudo systemctl start docker
   16  docker -v
   17  docker info
   18  cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*
EOF

   19  setenforce 0
   20  sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
   21  yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
   22  systemctl enable --now kubelet
   23  kubeadm init --ignore-preflight-errors all
   24  mkdir -p $HOME/.kube
   25  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
   26  sudo chown $(id -u):$(id -g) $HOME/.kube/config
   27  kubectl get nodes
   28  kubectl get pods --all-namespaces
   29  kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
   30  kubectl get nodes
   31  kubectl get pods --all-namespaces
   32  kubectl get nodes
   33  kubectl config view
   34  pwd
   35  mkdir suresh
   36  cd suresh
   37  vi pod.yaml
   38  ls
   39  kubectl get ns
   40  kubectl create ns suresh
   41  kubectl get ns
   42  kubectl get pods
   43  kubectl get pods -n=suresh
   44  kubectl get pods -n=dev
   45  kubectl create -f pod.yaml
   46  kubectl create -f pod.yaml -n=suresh
   47  kubectl get pods -n=suresh
   48  kubectl get pods
   49  kubectl get pods -n=suresh,dev
   50  kubectl get pods -all-namespaces
   51  kubectl get pods --all-namespaces
   52  kubectl get pods -o wide
   53  ping 10.44.0.1
   54  kubectl get pods
   55  kubectl edit pod nodehelloworld.example.com
   56  kubectl edit pod --show-labels
   57  kubectl get  pod --show-labels
   58  kubectl -h
   59  kubectl get -h
   60  kubectl get pods -h
   61  vi pod.yml
   62  vi pod.yaml
   63  kubectl apply -f pod.yml
   64  kubectl apply -f pod.yaml
   65  kubectl get pods
   66  kubectl delete pod nodehelloworld.example.com
   67  kubectl delete pod nodehelloworld.example.com -n=rajesh
   68  kubectl delete pod nodehelloworld.example.com -n=suresh
   69  kubectl delete pod nodehelloworld.example.com -n=sures
   70  kubectl get pods -all-namespaces
   71  kubectl get pods --all-namespaces
   72  history
[root@sureshmaster suresh]# \
>