Search code examples
kuberneteskubectlpersistent-volumespersistent-volume-claims

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


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


Solution

  • 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.