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

Creation fails when the CRD property is ServiceAccount #129392

Open
WillardHu opened this issue Dec 25, 2024 · 2 comments
Open

Creation fails when the CRD property is ServiceAccount #129392

WillardHu opened this issue Dec 25, 2024 · 2 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@WillardHu
Copy link

What happened?

My CRD property use the ServiceAccount type, When I use kubelet apply -f <crds> to create CRDs generated by controller-gen, get an error message:

Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property.

This is because ServiceAccount.Secret.Name property is in x-kubernetes-list-map-keys, but it is not have a default and not be a required property.

Structure definition:

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:...
type Foo struct {
    ServiceAccount corev1.ServiceAccount `json:"serviceAccount,omitempty"`
    ....
}

What did you expect to happen?

I expect to generate CRDs that can be created successfully.

Solutions:

  • Set ObjectReference.Name to required. I think the name is required in most scenarios.
  • Add default value annotations (//+default="" and //+kubebuilder:default="") for ObjectReference.Name.
  • Modify the ServiceAccount.Secrets type to []SecretReference and set SecretReference.name to required.

How can we reproduce it (as minimally and precisely as possible)?

Refer to "What happened"

Anything else we need to know?

No response

Kubernetes version

v1.30+

Cloud provider

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

@WillardHu WillardHu added the kind/bug Categorizes issue or PR as related to a bug. label Dec 25, 2024
@k8s-ci-robot
Copy link
Contributor

There are no sig labels on this issue. Please add an appropriate label by using one of the following commands:

  • /sig <group-name>
  • /wg <group-name>
  • /committee <group-name>

Please see the group list for a listing of the SIGs, working groups, and committees available.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Dec 25, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

2 participants