Create Persistent volume using command line (without using any file)

1/24/2021

I want to create PV using the kubectl command line, Is it possible in Kubernetes or not. If it is possible then how?

-- user15003460
kubectl
kubernetes
persistent-volume-claims
persistent-volumes

1 Answer

1/24/2021

For infrastructure, it has become a good practice to use declarative files to provision new infrastructure. Therefore an imperative variant only using kubectl commands for creating Persistent Volumes has not been implemented.

Persistent Volumes are typically created in one of two ways:

  • Automatically created by a dynamic volume provisioning service. What service is used depends on your environment, e.g. on-prem or a cloud provider like Google Cloud Platform or Amazon Web Services.
  • In some cases, created using kubectl and yaml manifests, typically by an operator.
-- Jonas
Source: StackOverflow