--- title: Imperative Management of Kubernetes Objects Using Configuration Files content_type: task weight: 40 --- Kubernetes objects can be created, updated, and deleted by using the `kubectl` command-line tool along with an object configuration file written in YAML or JSON. This document explains how to define and manage objects using configuration files. ## {{% heading "prerequisites" %}} Install [`kubectl`](/docs/tasks/tools/). {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}} ## Trade-offs The `kubectl` tool supports three kinds of object management: * Imperative commands * Imperative object configuration * Declarative object configuration See [Kubernetes Object Management](/docs/concepts/overview/working-with-objects/object-management/) for a discussion of the advantages and disadvantage of each kind of object management. ## How to create objects You can use `kubectl create -f` to create an object from a configuration file. Refer to the [kubernetes API reference](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/) for details. * `kubectl create -f ` ## How to update objects {{< warning >}} Updating objects with the `replace` command drops all parts of the spec not specified in the configuration file. This should not be used with objects whose specs are partially managed by the cluster, such as Services of type `LoadBalancer`, where the `externalIPs` field is managed independently from the configuration file. Independently managed fields must be copied to the configuration file to prevent `replace` from dropping them. {{< /warning >}} You can use `kubectl replace -f` to update a live object according to a configuration file. * `kubectl replace -f ` ## How to delete objects You can use `kubectl delete -f` to delete an object that is described in a configuration file. * `kubectl delete -f ` {{< note >}} If configuration file has specified the `generateName` field in the `metadata` section instead of the `name` field, you cannot delete the object using `kubectl delete -f `. You will have to use other flags for deleting the object. For example: ```shell kubectl delete kubectl delete -l