语法:

kubectl [command] [TYPE] [NAME] [flags]
CODE


command, 命令: create, get, describe, delete  https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands

type,资源类型:可以是单数或者复数,大小写敏感,可以有缩写:

这个是等价的:

kubectl get pod pod1
kubectl get pods pod1
kubectl get po pod1
CODE

name, 资源名字:大小写敏感,如果为空的话,列出所有的资源。

flags:可选参数,-s 或者 --server 指定Kubernets API 服务器地址和端口,并且这里指定的参数覆盖环境变量中的参数。


所有资源类型及缩写:

AMESHORTNAMESAPIGROUPNAMESPACEDKIND
bindings

trueBinding
componentstatusescs
falseComponentStatus
configmapscm
trueConfigMap
endpointsep
trueEndpoints
eventsev
trueEvent
limitrangeslimits
trueLimitRange
namespacesns
falseNamespace
nodesno
falseNode
persistentvolumeclaimspvc
truePersistentVolumeClaim
persistentvolumespv
falsePersistentVolume
podspo
truePod
podtemplates

truePodTemplate
replicationcontrollersrc
trueReplicationController
resourcequotasquota
trueResourceQuota
secrets

trueSecret
serviceaccountssa
trueServiceAccount
servicessvc
trueService
mutatingwebhookconfigurations
admissionregistration.k8s.iofalseMutatingWebhookConfiguration
validatingwebhookconfigurations
admissionregistration.k8s.iofalseValidatingWebhookConfiguration
customresourcedefinitionscrd,crdsapiextensions.k8s.iofalseCustomResourceDefinition
apiservices
apiregistration.k8s.iofalseAPIService
controllerrevisions
appstrueControllerRevision
daemonsetsdsappstrueDaemonSet
deploymentsdeployappstrueDeployment
replicasetsrsappstrueReplicaSet
statefulsetsstsappstrueStatefulSet
tokenreviews
authentication.k8s.iofalseTokenReview
localsubjectaccessreviews
authorization.k8s.iotrueLocalSubjectAccessReview
selfsubjectaccessreviews
authorization.k8s.iofalseSelfSubjectAccessReview
selfsubjectrulesreviews
authorization.k8s.iofalseSelfSubjectRulesReview
subjectaccessreviews
authorization.k8s.iofalseSubjectAccessReview
horizontalpodautoscalershpaautoscalingtrueHorizontalPodAutoscaler
cronjobscjbatchtrueCronJob
jobs
batchtrueJob
certificatesigningrequestscsrcertificates.k8s.iofalseCertificateSigningRequest
leases
coordination.k8s.iotrueLease
endpointslices
discovery.k8s.iotrueEndpointSlice
eventsevevents.k8s.iotrueEvent
ingressesingextensionstrueIngress
flowschemas
flowcontrol.apiserver.k8s.iofalseFlowSchema
prioritylevelconfigurations
flowcontrol.apiserver.k8s.iofalsePriorityLevelConfiguration
ingressclasses
networking.k8s.iofalseIngressClass
ingressesingnetworking.k8s.iotrueIngress
networkpoliciesnetpolnetworking.k8s.iotrueNetworkPolicy
runtimeclasses
node.k8s.iofalseRuntimeClass
poddisruptionbudgetspdbpolicytruePodDisruptionBudget
podsecuritypoliciespsppolicyfalsePodSecurityPolicy
clusterrolebindings
rbac.authorization.k8s.iofalseClusterRoleBinding
clusterroles
rbac.authorization.k8s.iofalseClusterRole
rolebindings
rbac.authorization.k8s.iotrueRoleBinding
roles
rbac.authorization.k8s.iotrueRole
priorityclassespcscheduling.k8s.iofalsePriorityClass
csidrivers
storage.k8s.iofalseCSIDriver
csinodes
storage.k8s.iofalseCSINode
storageclassesscstorage.k8s.iofalseStorageClass
volumeattachments
storage.k8s.iofalseVolumeAttachment