k8s集群的日志,带有组件的信息,多看日志 。
文章插图
kubectl命令汇总kubectl命令汇总
文章插图
kubectl命令帮助信息[root@mcwk8s04 ~]# kubectl -hkubectl controls the Kubernetes cluster manager. Find more information at: https://kubernetes.io/docs/reference/kubectl/overview/Basic Commands (Beginner):createCreate a resource from a file or from stdin.exposeTake a replication controller, service, deployment or pod and expose it as a new Kubernetes ServicerunRun a particular image on the clustersetSet specific features on objectsBasic Commands (Intermediate):explainDocumentation of resourcesgetDisplay one or many resourceseditEdit a resource on the serverdeleteDelete resources by filenames, stdin, resources and names, or by resources and label selectorDeploy Commands:rolloutManage the rollout of a resourcescaleSet a new size for a Deployment, ReplicaSet, Replication Controller, or JobautoscaleAuto-scale a Deployment, ReplicaSet, or ReplicationControllerCluster Management Commands:certificateModify certificate resources.cluster-infoDisplay cluster infotopDisplay Resource (CPU/Memory/Storage) usage.cordonMark node as unschedulableuncordonMark node as schedulabledrainDrain node in preparation for maintenancetaintUpdate the taints on one or more nodesTroubleshooting and Debugging Commands:describeShow details of a specific resource or group of resourceslogsPrint the logs for a container in a podattachAttach to a running containerexecExecute a command in a containerport-forwardForward one or more local ports to a podproxyRun a proxy to the Kubernetes API servercpCopy files and directories to and from containers.authInspect authorizationAdvanced Commands:diffDiff live version against would-be applied versionapplyApply a configuration to a resource by filename or stdinpatchUpdate field(s) of a resource using strategic merge patchreplaceReplace a resource by filename or stdinwaitExperimental: Wait for a specific condition on one or many resources.convertConvert config files between different API versionskustomizeBuild a kustomization target from a directory or a remote url.Settings Commands:labelUpdate the labels on a resourceannotateUpdate the annotations on a resourcecompletionOutput shell completion code for the specified shell (bash or zsh)Other Commands:api-resourcesPrint the supported API resources on the serverapi-versionsPrint the supported API versions on the server, in the form of "group/version"configModify kubeconfig filespluginProvides utilities for interacting with plugins.versionPrint the client and server version informationUsage:kubectl [flags] [options]Use "kubectl <command> --help" for more information about a given command.Use "kubectl options" for a list of global command-line options (applies to all commands).[root@mcwk8s04 ~]# kubectl run 命令帮助信息[root@mcwk8s04 ~]# kubectl run --helpCreate and run a particular image, possibly replicated. Creates a deployment or job to manage the created container(s).Examples:# Start a single instance of nginx.kubectl run nginx --image=nginx# Start a single instance of hazelcast and let the container expose port 5701 .kubectl run hazelcast --image=hazelcast --port=5701# Start a single instance of hazelcast and set environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default"in the container.kubectl run hazelcast --image=hazelcast --env="DNS_DOMAIN=cluster" --env="POD_NAMESPACE=default"# Start a single instance of hazelcast and set labels "app=hazelcast" and "env=prod" in the container.kubectl run hazelcast --image=hazelcast --labels="app=hazelcast,env=prod"# Start a replicated instance of nginx.kubectl run nginx --image=nginx --replicas=5# Dry run. Print the corresponding API objects without creating them.kubectl run nginx --image=nginx --dry-run# Start a single instance of nginx, but overload the spec of the deployment with a partial set of values parsed fromJSON.kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }'# Start a pod of busybox and keep it in the foreground, don't restart it if it exits.kubectl run -i -t busybox --image=busybox --restart=Never# Start the nginx container using the default command, but use custom arguments (arg1 .. argN) for that command.kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN># Start the nginx container using a different command and custom arguments.kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN># Start the perl container to compute π to 2000 places and print it out.kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'# Start the cron job to compute π to 2000 places and print it out every 5 minutes.kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'Options:--allow-missing-template-keys=true: If true, ignore any errors in templates when a field or map key is missing inthe template. Only applies to golang and jsonpath output formats.--attach=false: If true, wait for the Pod to start running, and then attach to the Pod as if 'kubectl attach ...'were called.Default false, unless '-i/--stdin' is set, in which case the default is true. With '--restart=Never' theexit code of the container process is returned.--cascade=true: If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by aReplicationController).Default true.--command=false: If true and extra arguments are present, use them as the 'command' field in the container, ratherthan the 'args' field which is the default.--dry-run=false: If true, only print the object that would be sent, without sending it.--env=[]: Environment variables to set in the container--expose=false: If true, a public, external service is created for the container(s) which are run-f, --filename=[]: to use to replace the resource.--force=false: Only used when grace-period=0. If true, immediately remove resources from API and bypass gracefuldeletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requiresconfirmation.--generator='': The name of the API generator to use, seehttp://kubernetes.io/docs/user-guide/kubectl-conventions/#generators for a list.--grace-period=-1: Period of time in seconds given to the resource to terminate gracefully. Ignored if negative.Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).--hostport=-1: The host port mapping for the container port. To demonstrate a single-machine container.--image='': The image for the container to run.--image-pull-policy='': The image pull policy for the container. If left empty, this value will not be specifiedby the client and defaulted by the server-k, --kustomize='': Process a kustomization directory. This flag can't be used together with -f or -R.-l, --labels='': Comma separated labels to apply to the pod(s). Will override previous values.--leave-stdin-open=false: If the pod is started in interactive mode or with stdin, leave stdin open after thefirst attach completes. By default, stdin will be closed after the first attach completes.--limits='': The resource requirement limits for this container.For example, 'cpu=200m,memory=512Mi'.Note thatserver side components may assign limits depending on the server configuration, such as limit ranges.-o, --output='': Output format. One of:json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.--overrides='': An inline JSON override for the generated object. If this is non-empty, it is used to override thegenerated object. Requires that the object supply a valid apiVersion field.--pod-running-timeout=1m0s: The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least onepod is running--port='': The port that this container exposes.If --expose is true, this is also the port used by the servicethat is created.--quiet=false: If true, suppress prompt messages.--record=false: Record current kubectl command in the resource annotation. If set to false, do not record thecommand. If set to true, record the command. If not set, default to updating the existing annotation value only if onealready exists.-R, --recursive=false: Process the directory used in -f, --filename recursively. Useful when you want to managerelated manifests organized within the same directory.-r, --replicas=1: Number of replicas to create for this container. Default is 1.--requests='': The resource requirement requests for this container.For example, 'cpu=100m,memory=256Mi'.Notethat server side components may assign requests depending on the server configuration, such as limit ranges.--restart='Always': The restart policy for this Pod.Legal values [Always, OnFailure, Never].If set to 'Always'a deployment is created, if set to 'OnFailure' a job is created, if set to 'Never', a regular pod is created. For thelatter two --replicas must be 1.Default 'Always', for CronJobs `Never`.--rm=false: If true, delete resources created in this command for attached containers.--save-config=false: If true, the configuration of current object will be saved in its annotation. Otherwise, theannotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.--schedule='': A schedule in the Cron format the job should be run with.--service-generator='service/v2': The name of the generator to use for creating a service.Only used if --exposeis true--service-overrides='': An inline JSON override for the generated service object. If this is non-empty, it is usedto override the generated object. Requires that the object supply a valid apiVersion field.Only used if --expose istrue.--serviceaccount='': Service account to set in the pod spec-i, --stdin=false: Keep stdin open on the container(s) in the pod, even if nothing is attached.--template='': Template string or path to template file to use when -o=go-template, -o=go-template-file. Thetemplate format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].--timeout=0s: The length of time to wait before giving up on a delete, zero means determine a timeout from thesize of the object-t, --tty=false: Allocated a TTY for each container in the pod.--wait=false: If true, wait for resources to be gone before returning. This waits for finalizers.Usage:kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool][--overrides=inline-json] [--command] -- [COMMAND] [args...] [options]Use "kubectl options" for a list of global command-line options (applies to all commands).[root@mcwk8s04 ~]#
推荐阅读
- 奥比岛2022盛夏之旅活动参与方法
- 流放之路S20卡兰德之湖赛季上线时间说明
- 真正“搞”懂HTTP协议03之时间穿梭
- 网络协议之:redis protocol 详解
- 信号量 C# 多线程访问之 SemaphoreSlim【C# 进阶】
- JavaScript之数组高阶API—reduce
- 奥比岛暗夜袭击第一轮金块失踪之谜通关攻略
- 之八 2流高手速成记:基于Sentinel实现微服务体系下的限流与熔断
- 明日之后幽灵船在哪
- 星之彼端叶灵真伤流怎么搭配阵容