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
| NAME | SHORTNAMES | APIVERSION | NAMESPACED | KIND | Purpose |
|---|---|---|---|---|---|
| bindings | — | v1 | true | Binding | Binds a Pod to a Node |
| componentstatuses | cs | v1 | false | ComponentStatus | Health of control plane components |
| configmaps | cm | v1 | true | ConfigMap | Store non-sensitive configuration |
| endpoints | ep | v1 | true | Endpoints | Backend Pod IPs for Services |
| events | ev | v1 | true | Event | Cluster activity logs/events |
| limitranges | limits | v1 | true | LimitRange | Resource limits in namespace |
| namespaces | ns | v1 | false | Namespace | Logical cluster isolation |
| nodes | no | v1 | false | Node | Worker/master machines |
| persistentvolumeclaims | pvc | v1 | true | PersistentVolumeClaim | Request storage |
| persistentvolumes | pv | v1 | false | PersistentVolume | Actual storage resource |
| pods | po | v1 | true | Pod | Smallest deployable unit |
| podtemplates | — | v1 | true | PodTemplate | Template for Pod creation |
| replicationcontrollers | rc | v1 | true | ReplicationController | Legacy Pod replica manager |
| resourcequotas | quota | v1 | true | ResourceQuota | Namespace resource restrictions |
| secrets | — | v1 | true | Secret | Store sensitive data |
| serviceaccounts | sa | v1 | true | ServiceAccount | Identity for Pods |
| services | svc | v1 | true | Service | Stable networking endpoint |
Comments
Post a Comment