-
Notifications
You must be signed in to change notification settings - Fork 107
Description
What problem are you facing?
Currently, upjet only supports CRD Kind Names (like "amis.ec2.aws.m.upbound.io", "amis.ec2.aws.upbound.io") which get added as CRD categories. However, there's no way to define kubectl shortNames for individual resources.
This becomes particularly problematic in v2 where both cluster-scoped and namespaced CRs can have the same resource names (e.g., both amis resources exist in different API groups).
Having short aliases would significantly improve the user experience when working with kubectl.
For example, it would be very helpful to define short names like:
mAmifor namespaced Project CRsami/cAmifor cluster-scoped Project CRsmClusterfor namespaced Cluster CRscCluster/Clusterfor cluster-scoped Cluster CRs
How could Upjet help solve your problem?
Option 1: Smart auto-generation
Automatically generate shortNames based on scope and resource type:
- Namespaced resources:
m{{ .CRD.Kind }}(e.g.,mAmi,mCluster) - Cluster-scoped resources:
c{{ .CRD.Kind }}(e.g.,mAmi,cCluster)
{{ if eq .CRD.Scope "Namespaced" }},shortNames={m{{ .CRD.Kind }}{{ else if eq .CRD.Scope "Cluster" }},shortNames={c{{ .CRD.Kind }}{{ end }}// +kubebuilder:resource:scope={{ .CRD.Scope }},categories={crossplane,managed,{{ .Provider.ShortName }}{{ if .CRD.Path }},path={{ .CRD.Path }}{{ end }}{{ if eq .CRD.Scope "Namespaced" }},shortNames={m{{ .CRD.Kind }}{{ else if eq .CRD.Scope "Cluster" }},shortNames={c{{ .CRD.Kind }}{{ end }}Option 2: Add ShortName field to Resource struct
Add a ShortName field to the config.Resource struct that gets passed through to the CRD generation:
type Resource struct {
// ... existing fields ...
ShortName string // kubectl shortName for this resource
}Update the CRD template to support shortNames in the kubebuilder resource marker:
// Current template:
// +kubebuilder:resource:scope={{ .CRD.Scope }},categories={crossplane,managed,{{ .Provider.ShortName }}}{{ if .CRD.Path }},path={{ .CRD.Path }}{{ end }}
// Proposed template:
// +kubebuilder:resource:scope={{ .CRD.Scope }},categories={crossplane,managed,{{ .Provider.ShortName }}}{{ if .CRD.ShortName }},shortNames={{{ .CRD.ShortName }}}{{ end }}{{ if .CRD.Path }},path={{ .CRD.Path }}{{ end }}Use Cases
- Improved kubectl experience: Users can use
kubectl get mAmiinstead ofkubectl get amis.ec2.aws.m.upbound.io -n namespace - Scope disambiguation: Clear distinction between cluster and namespaced resources with same names
- Better UX: Reduce typing and improve resource identification