Teams describe what should run in YAML files called manifests, keep them in version control and apply them with kubectl apply -f. Each manifest names its apiVersion, kind, metadata (name, labels, sometimes a namespace) and a spec with the desired state. Apply sends that desired state to the API server, which validates it and stores it; controllers then make the cluster match.
You rarely type a manifest from nothing. kubectl run and kubectl create accept --dry-run=client -o yaml, which prints the object instead of creating it: redirect that into a file and edit from there. Applying a folder applies every manifest in it, and running apply again changes only what differs.
The API checks more than syntax. A Deployment whose selector doesn't match its Pod template is rejected, and most fields of a running Pod are immutable, so changing a Pod's environment means deleting it and creating it again. Read the error kubectl prints; it names the field.
Generate, edit, apply; then apply the whole folder.