Apply a configuration to a resource by filename or stdin. The resource name must be specified. This resource will be created if it doesn’t exist yet. To use ‘apply’, always create the resource initially with either ‘apply’ or ‘create —save-config’.
kubectl apply使用YMAL/JSON文件中定义的所有内容更新资源,而不是通过删除并从新文件重新创建的方式。

Usage:

kubectl apply -f FILENAME

Examples:

Apply the configuration in pod.yaml to a pod.
kubectl apply -f ./pod.yaml