-
kubectl apply -f [filename]
:If you want to create api object in a declarative way, you can use this command.
For example, if you have a pod template yaml file called
pod.yaml
in current directory, then you can typekubectl apply -f ./pod.yaml
to create a pod according to your specified template.
-
kubectl get pod [pod name]
This command will show the status of the given pod in a table.
For example, if you have a pod called
example
in the default namespace, then you can check its status bykubectl get pod example
(since it's in the default namespace, so the namespace can be omitted. Otherwise, you must typenamespace/name
to specify a pod). -
kubectl get pods
This command will show the status of all pods(in all namespaces) in a table.
-
kubectl get node [node name]
This command will show the status of the given node in a table.
-
kubectl get nodes
This command will show the status of all nodes(in all namespaces) in a table.
-
kubectl get rs [replicaSet name]
This command will show the status of the given replicaSet in a table.
-
kubectl get rss
This command will show the status of all replicaSets(in all namespaces) in a table.
-
kubectl get hpa [hpa name]
This command will show the status of the given horizontal pod autoscaler in a table.
-
kubectl get hpas
This command will show the status of all horizontal pod autoscalers(in all namespaces) in a table.
-
kubectl get wf [workflow name]
This command will show the status of the given workflow in a table.
-
kubectl get wfs
This command will show the status of all workflows(in all namespaces) in a table.
-
kubectl get func [function name]
This command will show the status of the given function in a table.
-
kubectl get funcs
This command will show the status of all functions in a table.
-
kubectl get gpu [gpu job name]
This command will show the status of the given gpu job in a table.
-
kubectl get gpus
This command will show the status of all gpu jobs in a table.
-
kubectl get service [service name]
This command will show the status of the given service in a table.
-
kubectl get services
This command will show the status of all services in a table.
-
kubectl get dns [dns name]
This command will show the status of the given dns in a table.
-
kubectl get dnses
This command will show the status of all dnses in a table.
kubectl delete [api object type] [name]
kubectl autoscale [hpa name]
Parameter | Description | Example |
---|---|---|
target | Required. Specify the target of hpa | --target=rs1 |
min | Optional, default value is 1. Specify the minimum number of replicas | --min=1 |
max | Optional, default value is 1. Specify the maximum number of replicas | --max=4 |
c | Optional. Choose cpu utilization as metrics, and the given value as its benchmark | -c 0.5 |
m | Optional. Choose memory utilization as metrics, and the given value as its benchmark | -m 0.5 |
i | Optional, default value is 15. Specify the interval of scaling. | -i 30 |
This command will create a hpa according to given parameters. Notice that if you specify both cpu and memory metrics, the hpa controller will choose cpu(cpu has higher priority).
You can also create a hpa in a declarative way: kubectl apply -f hpa.yaml
.
We recommend you to use kubectl autoscale
command, for it is more obvious.
This command is for test only(of course you can also feel free to use it). It will remove all the K-V pairs stored
in etcd
, thus resetting the status of the whole system.
-
kubectl gpu [gpu job name] -d [directory] -f [file to download]
This command will list or download the files throw the
nginx-fileserver
. Files in blue colors are directories.-d
flag stands for the directory to hold the download files(only works when flag-f
is used).-f
flag stands for the file you want to download. It will be downloaded throughGET
http request into the directory you have specified in flag-d
.If you don't use any flags, this command will list the files, just like
ls
command.
-
kubectl func add -f [function name] -p [function code path]
This command will register a function to the
knative
.-f
flag stands for the name of the function.-p
flag stands for the filepath of the code. -
kubectl func rm -f [function name]
This command will remove the function and its instances(pods and replicaSet).
-
kubectl func update -f [function name] -p [function code path]
This command will update a function to the
knative
.
-
kubectl trigger [function name] -d [function params json]
This command will call a serverless function through
http trigger
.-d
flag stands for the json form of parameters the function needs.
-
kubectl wf apply -f [workflow.json filepath]
This command will create a workflow in a declarative way.
-f
flag stands for the${workflow_name}.json
filepath. -
kubectl wf rm [workflow name]
This command will remove the specified workflow.
-
kubectl label nodes [node name] [label]
This command can label a node with given labels.
-
kubectl cfg sched=[schedule strategy]
This command can dynamically change the schedule strategy.
strategy | Description |
---|---|
min-pods | Schedule pod to the node with minimum number of pods |
max-pods | Schedule pod to the node with maximum number of pods |
min-cpu | Schedule pod to the node with minimum cpu utilization |
min-mem | Schedule pod to the node with minimum memory utilization |
random | Schedule pod to a random node |