<p>How to remove version from 'status.storedVersions' while Manually upgrading the existing objects to a new stored version in kubernetes custom resources</p>

<p>apiVersion for CRD: <code>apiextensions.k8s.io/v1beta1</code></p>

<p>Using aws EKS</p>

<p>CRD YAML</p>

<pre><code>apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: &lt;plural&gt;.&lt;group&gt;
  name: crontabs.stable.example.com
spec:
  # group name to use for REST API: /apis/&lt;group&gt;/&lt;version&gt;
  group: stable.example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1
      # Each version can be enabled/disabled by Served flag.
      served: true
      # One and only one version must be marked as the storage version.
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                image:
                  type: string
                replicas:
                  type: integer
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/&lt;group&gt;/&lt;version&gt;/&lt;plural&gt;
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct
</code></pre>

<p>And upgrading the CRD to v2</p>

<pre><code>apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: &lt;plural&gt;.&lt;group&gt;
  name: crontabs.stable.example.com
spec:
  # group name to use for REST API: /apis/&lt;group&gt;/&lt;version&gt;
  group: stable.example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v2
      # Each version can be enabled/disabled by Served flag.
      served: true
      # One and only one version must be marked as the storage version.
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                image:
                  type: string
                replicas:
                  type: integer
    - name: v1
      # Each version can be enabled/disabled by Served flag.
      served: false
      # One and only one version must be marked as the storage version.
      storage: false
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                image:
                  type: string
                replicas:
                  type: integer
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/&lt;group&gt;/&lt;version&gt;/&lt;plural&gt;
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct
</code></pre>

<p>After disabling version v1 I want remove it from the versions list to do that I need to remove it from status.storedVersions how can i do that the kubernetes document does not give details about that</p>

DK_
<p>There is also another another way of removing <code>status.specVersion</code> using cluster API.</p>

<p>Fields under status are modified via the status sub resource:</p>

<pre class="lang-sh prettyprint-override"><code>curl -d '[{ "op": "replace", "path":"/status/storedVersions", "value": ["v2"] }]' \
  -H "Content-Type: application/json-patch+json" \
  -X PATCH \
 http://localhost:8080/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/crontabs.stable.example.com/status
</code></pre>

<p>To access API you need to first connected to cluster <a href="https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/" rel="nofollow noreferrer">doc</a></p>
