kubectl 常用命令
语法:
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 服务器地址和端口,并且这里指定的参数覆盖环境变量中的参数。
所有资源类型及缩写:
AME | SHORTNAMES | APIGROUP | NAMESPACED | KIND |
---|---|---|---|---|
bindings | true | Binding | ||
componentstatuses | cs | false | ComponentStatus | |
configmaps | cm | true | ConfigMap | |
endpoints | ep | true | Endpoints | |
events | ev | true | Event | |
limitranges | limits | true | LimitRange | |
namespaces | ns | false | Namespace | |
nodes | no | false | Node | |
persistentvolumeclaims | pvc | true | PersistentVolumeClaim | |
persistentvolumes | pv | false | PersistentVolume | |
pods | po | true | Pod | |
podtemplates | true | PodTemplate | ||
replicationcontrollers | rc | true | ReplicationController | |
resourcequotas | quota | true | ResourceQuota | |
secrets | true | Secret | ||
serviceaccounts | sa | true | ServiceAccount | |
services | svc | true | Service | |
mutatingwebhookconfigurations | admissionregistration.k8s.io | false | MutatingWebhookConfiguration | |
validatingwebhookconfigurations | admissionregistration.k8s.io | false | ValidatingWebhookConfiguration | |
customresourcedefinitions | crd,crds | apiextensions.k8s.io | false | CustomResourceDefinition |
apiservices | apiregistration.k8s.io | false | APIService | |
controllerrevisions | apps | true | ControllerRevision | |
daemonsets | ds | apps | true | DaemonSet |
deployments | deploy | apps | true | Deployment |
replicasets | rs | apps | true | ReplicaSet |
statefulsets | sts | apps | true | StatefulSet |
tokenreviews | authentication.k8s.io | false | TokenReview | |
localsubjectaccessreviews | authorization.k8s.io | true | LocalSubjectAccessReview | |
selfsubjectaccessreviews | authorization.k8s.io | false | SelfSubjectAccessReview | |
selfsubjectrulesreviews | authorization.k8s.io | false | SelfSubjectRulesReview | |
subjectaccessreviews | authorization.k8s.io | false | SubjectAccessReview | |
horizontalpodautoscalers | hpa | autoscaling | true | HorizontalPodAutoscaler |
cronjobs | cj | batch | true | CronJob |
jobs | batch | true | Job | |
certificatesigningrequests | csr | certificates.k8s.io | false | CertificateSigningRequest |
leases | coordination.k8s.io | true | Lease | |
endpointslices | discovery.k8s.io | true | EndpointSlice | |
events | ev | events.k8s.io | true | Event |
ingresses | ing | extensions | true | Ingress |
flowschemas | flowcontrol.apiserver.k8s.io | false | FlowSchema | |
prioritylevelconfigurations | flowcontrol.apiserver.k8s.io | false | PriorityLevelConfiguration | |
ingressclasses | networking.k8s.io | false | IngressClass | |
ingresses | ing | networking.k8s.io | true | Ingress |
networkpolicies | netpol | networking.k8s.io | true | NetworkPolicy |
runtimeclasses | node.k8s.io | false | RuntimeClass | |
poddisruptionbudgets | pdb | policy | true | PodDisruptionBudget |
podsecuritypolicies | psp | policy | false | PodSecurityPolicy |
clusterrolebindings | rbac.authorization.k8s.io | false | ClusterRoleBinding | |
clusterroles | rbac.authorization.k8s.io | false | ClusterRole | |
rolebindings | rbac.authorization.k8s.io | true | RoleBinding | |
roles | rbac.authorization.k8s.io | true | Role | |
priorityclasses | pc | scheduling.k8s.io | false | PriorityClass |
csidrivers | storage.k8s.io | false | CSIDriver | |
csinodes | storage.k8s.io | false | CSINode | |
storageclasses | sc | storage.k8s.io | false | StorageClass |
volumeattachments | storage.k8s.io | false | VolumeAttachment |