mohammedrafi@NOC-RAFI:~$ sudo kubectl
kubectl controls the Kubernetes cluster manager.
Find more information at https://github.com/kubernetes/kubernetes.
Basic Commands (Beginner):
create Create a resource by filename or 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
run-container Run a particular image on the cluster
set Set specific features on objects
Basic Commands (Intermediate):
get Display one or many resources
explain Documentation of 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
rolling-update Perform a rolling update of the given ReplicationController
rollingupdate Perform a rolling update of the given ReplicationController
scale Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job
resize Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job
autoscale Auto-scale a Deployment, ReplicaSet, or ReplicationController
Cluster Management Commands:
certificate Modify certificate resources.
cluster-info Display cluster info
clusterinfo Display cluster info
top Display Resource (CPU/Memory/Storage) 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
Advanced Commands:
apply Apply a configuration to a resource by filename or stdin
patch Update field(s) of a resource using strategic merge patch
replace Replace a resource by filename or stdin
update Replace a resource by filename or stdin
convert Convert config files between different API versions
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-versions Print the supported API versions on the server, in the form of “group/version”
config Modify kubeconfig files
help Help about any command
plugin Runs a command-line plugin
version Print the client and server version information
Use “kubectl –help” for more information about a given command.
Use “kubectl options” for a list of global command-line options (applies to all commands).
mohammedrafi@NOC-RAFI:~$ sudo kubectl explain pod
DESCRIPTION:
Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts.
FIELDS:
apiVersion
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
kind
Kind is a string value representing the REST resource this object
represents. Servers may infer this from the endpoint the client submits
requests to. Cannot be updated. In CamelCase. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
metadata Standard object’s metadata. More info:https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata spec Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status/
status Most recently observed status of the pod. This data may not be up to date.Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status/
mohammedrafi@NOC-RAFI:~$ sudo kubectl explain pod.status
RESOURCE: status
DESCRIPTION:
Most recently observed status of the pod. This data may not be up to date.
Populated by the system. Read-only. More info: https://git.k8s.io/community/
contributors/devel/api-conventions.md#spec-and-status/
PodStatus represents information about the status of a pod. Status may trail the actual state of a system.
FIELDS:
hostIP
IP address of the host to which the pod is assigned. Empty if not yet
scheduled.
message
A human readable message indicating details about why the pod is in this
condition.
phase
Current condition of the pod. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-phase
podIP
IP address allocated to the pod. Routable at least within the cluster.
Empty if not yet allocated.
reason
A brief CamelCase message indicating details about why the pod is in this
state. e.g. ‘OutOfDisk’
conditions <[]Object>
Current service state of pod. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions
initContainerStatuses <[]Object>
The list has one entry per init container in the manifest. The most recent
successful init container will have ready = true, the most recently started
container will have startTime set. More info: https://kubernetes.io/docs/
concepts/workloads/pods/pod-lifecycle#pod-and-container-status/
qosClass
The Quality of Service (QOS) classification assigned to the pod based on
resource requirements See PodQOSClass type for available QOS classes More
info:
https://github.com/kubernetes/kubernetes/blob/master/docs/design/resource-qos.md
startTime
RFC 3339 date and time at which the object was acknowledged by the Kubelet.
This is before the Kubelet pulled the container image(s) for the pod.
containerStatuses <[]Object>
The list has one entry per container in the manifest. Each entry is
currently the output of `docker inspect`. More info: https://kubernetes.io/
docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status/
mohammedrafi@NOC-RAFI:~$ sudo kubectl explain pod.metadata
RESOURCE: metadata
DESCRIPTION:
Standard object’s metadata. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.
FIELDS:
finalizers <[]string>
Must be empty before the object is deleted from the registry. Each entry is
an identifier for the responsible component that will remove the entry from
the list. If the deletionTimestamp of the object is non-nil, entries in this
list can only be removed.
labels Map of string keys and values that can be used to organize and categorize(scope and select) objects. May match selectors of replication controllersand services. More info: http://kubernetes.io/docs/user-guide/labels
ownerReferences <[]Object>
List of objects depended by this object. If ALL objects in the list have
been deleted, this object will be garbage collected. If this object is
managed by a controller, then an entry in this list will point to this
controller, with the controller field set to true. There cannot be more than
one managing controller.
creationTimestamp
CreationTimestamp is a timestamp representing the server time when this
object was created. It is not guaranteed to be set in happens-before order
across separate operations. Clients may not set this value. It is
represented in RFC3339 form and is in UTC. Populated by the system.
Read-only. Null for lists. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
deletionTimestamp
DeletionTimestamp is RFC 3339 date and time at which this resource will be
deleted. This field is set by the server when a graceful deletion is
requested by the user, and is not directly settable by a client. The
resource is expected to be deleted (no longer visible from resource lists,
and not reachable by name) after the time in this field. Once set, this
value may not be unset or be set further into the future, although it may be
shortened or the resource may be deleted prior to this time. For example, a
user may request that a pod is deleted in 30 seconds. The Kubelet will react
by sending a graceful termination signal to the containers in the pod. After
that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL)
to the container and after cleanup, remove the pod from the API. In the
presence of network partitions, this object may still exist after this
timestamp, until an administrator or automated process can determine the
resource is fully terminated. If not set, graceful deletion of the object
has not been requested. Populated by the system when a graceful deletion is
requested. Read-only. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
generation
A sequence number representing a specific generation of the desired state.
Populated by the system. Read-only.
initializers An initializer is a controller which enforces some system invariant atobject creation time. This field is a list of initializers that have not yetacted on this object. If nil or empty, this object has been completelyinitialized. Otherwise, the object is considered uninitialized and is hidden(in list/watch and get calls) from clients that haven’t explicitly asked toobserve uninitialized objects. When an object is created, the system willpopulate this list with the current set of initializers. Only privilegedusers may set or modify this list. Once it is empty, it may not be modifiedfurther by any user.
namespace
Namespace defines the space within each name must be unique. An empty
namespace is equivalent to the “default” namespace, but “default” is the
canonical representation. Not all objects are required to be scoped to a
namespace – the value of this field for those objects will be empty. Must
be a DNS_LABEL. Cannot be updated. More info:
http://kubernetes.io/docs/user-guide/namespaces
selfLink
SelfLink is a URL representing this object. Populated by the system.
Read-only.
name
Name must be unique within a namespace. Is required when creating
resources, although some resources may allow a client to request the
generation of an appropriate name automatically. Name is primarily intended
for creation idempotence and configuration definition. Cannot be updated.
More info: http://kubernetes.io/docs/user-guide/identifiers#names
resourceVersion
An opaque value that represents the internal version of this object that
can be used by clients to determine when objects have changed. May be used
for optimistic concurrency, change detection, and the watch operation on a
resource or set of resources. Clients must treat these values as opaque and
passed unmodified back to the server. They may only be valid for a
particular resource or set of resources. Populated by the system.
Read-only. Value must be treated as opaque by clients and . More info:
https://git.k8s.io/community/contributors/devel/
api-conventions.md#concurrency-control-and-consistency/
uid
UID is the unique in time and space value for this object. It is typically
generated by the server on successful creation of a resource and is not
allowed to change on PUT operations. Populated by the system. Read-only.
More info: http://kubernetes.io/docs/user-guide/identifiers#uids
annotations Annotations is an unstructured key value map stored with a resource thatmay be set by external tools to store and retrieve arbitrary metadata. Theyare not queryable and should be preserved when modifying objects. More info:http://kubernetes.io/docs/user-guide/annotations
clusterName
The name of the cluster which the object belongs to. This is used to
distinguish resources with same name and namespace in different clusters.
This field is not set anywhere right now and apiserver is going to ignore it
if set in create or update request.
deletionGracePeriodSeconds
Number of seconds allowed for this object to gracefully terminate before it
will be removed from the system. Only set when deletionTimestamp is also
set. May only be shortened. Read-only.
generateName
GenerateName is an optional prefix, used by the server, to generate a
unique name ONLY IF the Name field has not been provided. If this field is
used, the name returned to the client will be different than the name
passed. This value will also be combined with a unique suffix. The provided
value has the same validation rules as the Name field, and may be truncated
by the length of the suffix required to make the value unique on the server.
If this field is specified and the generated name exists, the server will
NOT return a 409 – instead, it will either return 201 Created or 500 with
Reason ServerTimeout indicating a unique name could not be found in the time
allotted, and the client should retry (optionally after the time indicated
in the Retry-After header). Applied only if Name is not specified. More
info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#idempotency
mohammedrafi@NOC-RAFI:~$ sudo kubectl explain pod.spec
RESOURCE: spec
DESCRIPTION:
Specification of the desired behavior of the pod. More info: https://
git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status/
PodSpec is a description of a pod.
FIELDS:
volumes <[]Object>
List of volumes that can be mounted by containers belonging to the pod.
More info: https://kubernetes.io/docs/concepts/storage/volumes
affinity If specified, the pod’s scheduling constraints
dnsPolicy
Set DNS policy for containers within the pod. One of
‘ClusterFirstWithHostNet’, ‘ClusterFirst’ or ‘Default’. Defaults to
“ClusterFirst”. To have DNS options set along with hostNetwork, you have to
specify DNS policy explicitly to ‘ClusterFirstWithHostNet’.
nodeName
NodeName is a request to schedule this pod onto a specific node. If it is
non-empty, the scheduler simply schedules this pod onto that node, assuming
that it fits resource requirements.
serviceAccountName
ServiceAccountName is the name of the ServiceAccount to use to run this
pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/
configure-service-account//
terminationGracePeriodSeconds
Optional duration in seconds the pod needs to terminate gracefully. May be
decreased in delete request. Value must be non-negative integer. The value
zero indicates delete immediately. If this value is nil, the default grace
period will be used instead. The grace period is the duration in seconds
after the processes running in the pod are sent a termination signal and the
time when the processes are forcibly halted with a kill signal. Set this
value longer than the expected cleanup time for your process. Defaults to 30
seconds.
containers <[]Object> -required-
List of containers belonging to the pod. Containers cannot currently be
added or removed. There must be at least one container in a Pod. Cannot be
updated.
initContainers <[]Object>
List of initialization containers belonging to the pod. Init containers are
executed in order prior to containers being started. If any init container
fails, the pod is considered to have failed and is handled according to its
restartPolicy. The name for an init container or normal container must be
unique among all containers. Init containers may not have Lifecycle actions,
Readiness probes, or Liveness probes. The resourceRequirements of an init
container are taken into account during scheduling by finding the highest
request/limit for each resource type, and then using the max of of that
value or the sum of the normal containers. Limits are applied to init
containers in a similar fashion. Init containers cannot currently be added
or removed. Cannot be updated. More info:
https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
restartPolicy
Restart policy for all containers within the pod. One of Always, OnFailure,
Never. Default to Always. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy
securityContext SecurityContext holds pod-level security attributes and common containersettings. Optional: Defaults to empty. See type description for defaultvalues of each field.
automountServiceAccountToken
AutomountServiceAccountToken indicates whether a service account token
should be automatically mounted.
hostAliases <[]Object>
HostAliases is an optional list of hosts and IPs that will be injected into
the pod’s hosts file if specified. This is only valid for non-hostNetwork
pods.
hostNetwork
Host networking requested for this pod. Use the host’s network namespace.
If this option is set, the ports that will be used must be specified.
Default to false.
hostPID
Use the host’s pid namespace. Optional: Default to false.
hostname
Specifies the hostname of the Pod If not specified, the pod’s hostname will
be set to a system-defined value.
serviceAccount
DeprecatedServiceAccount is a depreciated alias for ServiceAccountName.
Deprecated: Use serviceAccountName instead.
subdomain
If specified, the fully qualified Pod hostname will be
“…svc.”. If not
specified, the pod will not have a domainname at all.
tolerations <[]Object>
If specified, the pod’s tolerations.
activeDeadlineSeconds
Optional duration in seconds the pod may be active on the node relative to
StartTime before the system will actively try to mark it failed and kill
associated containers. Value must be a positive integer.
hostIPC
Use the host’s ipc namespace. Optional: Default to false.
imagePullSecrets <[]Object>
ImagePullSecrets is an optional list of references to secrets in the same
namespace to use for pulling any of the images used by this PodSpec. If
specified, these secrets will be passed to individual puller implementations
for them to use. For example, in the case of docker, only DockerConfig type
secrets are honored. More info: https://kubernetes.io/docs/concepts/
containers/images#specifying-imagepullsecrets-on-a-pod/
nodeSelector NodeSelector is a selector which must be true for the pod to fit on a node.Selector which must match a node’s labels for the pod to be scheduled onthat node. More info:https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
schedulerName
If specified, the pod will be dispatched by specified scheduler. If not
specified, the pod will be dispatched by default scheduler.
mohammedrafi@NOC-RAFI:~$ sudo kubectl explain pod.status
RESOURCE: status
DESCRIPTION:
Most recently observed status of the pod. This data may not be up to date.
Populated by the system. Read-only. More info: https://git.k8s.io/community/
contributors/devel/api-conventions.md#spec-and-status/
PodStatus represents information about the status of a pod. Status may trail the actual state of a system.
FIELDS:
qosClass
The Quality of Service (QOS) classification assigned to the pod based on
resource requirements See PodQOSClass type for available QOS classes More
info:
https://github.com/kubernetes/kubernetes/blob/master/docs/design/resource-qos.md
conditions <[]Object>
Current service state of pod. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions
containerStatuses <[]Object>
The list has one entry per container in the manifest. Each entry is
currently the output of `docker inspect`. More info: https://kubernetes.io/
docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status/
hostIP
IP address of the host to which the pod is assigned. Empty if not yet
scheduled.
message
A human readable message indicating details about why the pod is in this
condition.
startTime
RFC 3339 date and time at which the object was acknowledged by the Kubelet.
This is before the Kubelet pulled the container image(s) for the pod.
initContainerStatuses <[]Object>
The list has one entry per init container in the manifest. The most recent
successful init container will have ready = true, the most recently started
container will have startTime set. More info: https://kubernetes.io/docs/
concepts/workloads/pods/pod-lifecycle#pod-and-container-status/
phase
Current condition of the pod. More info:
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-phase
podIP
IP address allocated to the pod. Routable at least within the cluster.
Empty if not yet allocated.
reason
A brief CamelCase message indicating details about why the pod is in this
state. e.g. ‘OutOfDisk’
