SUSE Support

Here When You Need Us

Why Does kubectl get Show a Different API Group for a Resource Than Specified?

This document (000020137) is provided subject to the disclaimer at the end of this document.

Situation

Sometimes, when you use the kubectl get command to retrieve Kubernetes resources, the API group and version shown may differ from what you originally specified in the resource specification. For instance, you might create a Deployment resource using the apps/v1 API group, but when you check the resource with kubectl get deployment -o yaml, it appears under the extensions/v1beta1 API group:

Original Deployment YAML:

apiVersion: apps/v1
kind: Deployment
[...]
Output of 'kubectl get deployment -o yaml':
apiVersion: extensions/v1beta1
kind: Deployment
[...]

Resolution

Kubernetes resources, like Deployments, can exist in multiple API groups. If you don't specify an API group and version when using kubectl, it defaults to the first group listed in the Kubernetes API server's discovery documentation. In the current example, the Deployment resource is available under both the apps/v1 and extensions/v1beta1 API groups. For backward compatibility, the API server might list extensions/v1beta1 first.

To ensure that kubectl retrieves the resource from the desired API group, you can fully qualify the resource type. For example, to get Deployment resources from the apps API group, use 'kubectl get deployments.apps -o yaml'. To specify a particular version, you can use 'kubectl get deployments.v1.apps -o yaml'.

Cause

The issue arises because Kubernetes resources can exist in multiple API groups and versions. If you don't specify the API group and version when using kubectl, it defaults to the first group listed in the API server's discovery documentation. This can lead to the resource being displayed under a different API group or version than originally specified, mainly due to backward compatibility.

Additional Information

For more details on this behavior, you can check the Kubernetes GitHub Issue #58131.
The Kubernetes developer documentation on API resource versioning provides additional insights and can be found here.

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000020137
  • Creation Date: 06-May-2021
  • Modified Date:26-Jul-2024
    • SUSE Rancher

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.