<p>Two years ago while I took CKA exam, I already have this question. At that time I only could do was to see k8s.io official documentation. Now just curious on generating pv / pvc / storageClass via pure kubectl cli. What I look for is similar to the similar logic as deployment, for example:</p>
<pre><code>$ kubectl create deploy test --image=nginx --port=80 --dry-run -o yaml
W0419 23:54:11.092265   76572 helpers.go:553] --dry-run is deprecated and can be replaced with --dry-run=client.
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: test
  name: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: test
    spec:
      containers:
      - image: nginx
        name: nginx
        ports:
        - containerPort: 80
        resources: {}
status: {}
</code></pre>
<p>Or similar logic to run a single pod:</p>
<pre><code>$ kubectl run test-pod --image=nginx --port=80 --dry-run -o yaml
W0419 23:56:29.174692   76654 helpers.go:553] --dry-run is deprecated and can be replaced with --dry-run=client.
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test-pod
  name: test-pod
spec:
  containers:
  - image: nginx
    name: test-pod
    ports:
    - containerPort: 80
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
</code></pre>
<p>So what should I type in order to generate pv / pvc / storageClass yaml? The current only declarative fastest way:</p>
<pre><code>cat &lt;&lt;EOF | kubectl create -f -
&lt;PV / PVC / storageClass yaml goes here&gt;
EOF
</code></pre>
<p>Edited: Please note that I look any fast way to generate correct pv / pvc / storageClass template without remembering specific syntax thru cli, and not necessary via kubectl.</p>

<p>There is no kubectl command to create a resource like PV, PVC, and storage class.</p>
<blockquote>
<p>From certificate points of view, you have go over <a href="https://kubernetes.io/" rel="nofollow noreferrer">k8.io</a> and look for the PV, PVC, and storage class under the task link.</p>
</blockquote>
<blockquote>
<p>Under task link, most of the YAML will be the same and for now, this is <strong>one of the fastest ways in exam</strong>.</p>
</blockquote>
