Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: InstanaAgent/Agent CRD Naming Issue Causes kubectl Commands to Fail #227

Open
O7Oghany opened this issue Nov 21, 2024 · 0 comments
Open

Comments

@O7Oghany
Copy link

Hello,

I discovered a bug when trying to list or delete InstanaAgent objects using kubectl. The following commands return no objects:

kubectl get InstanaAgent -A
kubectl get InstanaAgents -A
kubectl get agent -A
kubectl get agents -A

The only commands that work are using the full API group or the short name.

kubectl get instanaagent.instana.io
kubectl get ia -A

Investigation and Findings

After inspecting the CRD, I found that there is a mismatch between the singular, plural, and kind names in the CRD definition:

spec:
  conversion:
    strategy: None
  group: instana.io
  names:
    categories:
    - monitoring
    - openshift-optional
    kind: InstanaAgent
    listKind: InstanaAgentList
    plural: agents
    shortNames:
    - ia
    singular: agent

This mismatch is likely causing kubectl to fail when using commands like kubectl get instanaagent.


Resolution

I updated the CRD to ensure the singular and plural names match the kind. The corrected names section is:

spec:
  conversion:
    strategy: None
  group: instana.io
  names:
    categories:
    - monitoring
    - openshift-optional
    kind: InstanaAgent
    listKind: InstanaAgentList
    plural: instanaagents
    shortNames:
    - ia
    singular: instanaagent

With this change, the commands now work as expected.

kubectl get instanaagent -A
NAMESPACE       NAME            AGE
instana-agent   instana-agent   48m

Suggestion

Please update the code in the following file:

https://github.com/instana/instana-agent-operator/blob/main/api/v1/instanaagent_types.go#L147

To:

+kubebuilder:resource:path=instanaagents,singular=instanaagent,shortName=ia,scope=Namespaced,categories=monitoring;openshift-optional

O7Oghany pushed a commit to O7Oghany/instana-agent-operator that referenced this issue Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant