Kubectl - Command

kubectl run mini-kube  // is used to deploy an application on the cluster

kubectl cluster-info // command to view information about the cluster

kubectl get nodes // get the information about all the nodes in the cluster


kubectl get pods -o custom-columns="NAME:.metadata.name,IMAGE:.spec.containers[*].image,STATUS:.status.phase,NODE:.spec.nodeName"

NAME          IMAGE           STATUS    NODE

nginx-pod     nginx:alpine    Running   worker-1

redis-pod     redis:7         Running   worker-2


kubectl get pods -o custom-columns="\

NAMESPACE:.metadata.namespace,\

NAME:.metadata.name,\

IMAGE:.spec.containers[*].image,\

READY:.status.containerStatuses[*].ready,\

RESTARTS:.status.containerStatuses[*].restartCount,\

STATUS:.status.phase,\

NODE:.spec.nodeName,\

POD_IP:.status.podIP,\

AGE:.metadata.creationTimestamp"

OUTPUT BELOW: 

NAMESPACE  NAME        IMAGE        READY   RESTARTS  STATUS       NODE       POD_IP       AGE

default         nginx-pod   nginx:alpine             true                    0         Running    worker-1   10.1.2.3                2d  


SERVICE

kubectl get svc -o custom-columns="\

NAMESPACE:.metadata.namespace,\

NAME:.metadata.name,\

TYPE:.spec.type,\

CLUSTER-IP:.spec.clusterIP,\

EXTERNAL-IP:.status.loadBalancer.ingress[*].ip,\

PORTS:.spec.ports[*].port,\

TARGET-PORTS:.spec.ports[*].targetPort,\

SELECTOR:.spec.selector"


DEPLOYMENT

kubectl get deploy -o custom-columns="\

NAMESPACE:.metadata.namespace,\

NAME:.metadata.name,\

READY:.status.readyReplicas,\

UP-TO-DATE:.status.updatedReplicas,\

AVAILABLE:.status.availableReplicas,\

REPLICAS:.spec.replicas,\

IMAGE:.spec.template.spec.containers[*].image,\

STRATEGY:.spec.strategy.type,\

AGE:.metadata.creationTimestamp"


CONFIG MAPS

kubectl get configmap -o custom-columns="\

NAMESPACE:.metadata.namespace,\

NAME:.metadata.name,\

DATA-KEYS:.data,\

CREATION-TIME:.metadata.creationTimestamp"

The below tells you what version to use

kubectl explain replicaset 

kubectl explain deployment

KIND: Deployment
VERSION: apps/v1

DESCRIPTION:
Deployment enables declarative updates for Pods and ReplicaSets.

FIELDS:
apiVersion <string>
APIVersion defines the versioned schema of this representation of an object.

kubectl get all  // to see all the created components


. Show current context name -- which namespace you currently are in

kubectl config current-context

kubectl get pods --all-namespaces


kubectl api-resources 

NAMESHORTNAMESAPIVERSIONNAMESPACEDKINDPurpose
bindingsv1trueBindingBinds a Pod to a Node
componentstatusescsv1falseComponentStatusHealth of control plane components
configmapscmv1trueConfigMapStore non-sensitive configuration
endpointsepv1trueEndpointsBackend Pod IPs for Services
eventsevv1trueEventCluster activity logs/events
limitrangeslimitsv1trueLimitRangeResource limits in namespace
namespacesnsv1falseNamespaceLogical cluster isolation
nodesnov1falseNodeWorker/master machines
persistentvolumeclaimspvcv1truePersistentVolumeClaimRequest storage
persistentvolumespvv1falsePersistentVolumeActual storage resource
podspov1truePodSmallest deployable unit
podtemplatesv1truePodTemplateTemplate for Pod creation
replicationcontrollersrcv1trueReplicationControllerLegacy Pod replica manager
resourcequotasquotav1trueResourceQuotaNamespace resource restrictions
secretsv1trueSecretStore sensitive data
serviceaccountssav1trueServiceAccountIdentity for Pods
servicessvcv1trueServiceStable networking endpoint


Comments

Popular posts from this blog

Azure Migrate

Azure -- All Networking Components

All Kuberneters - Components