Skip to content

Commit

Permalink
change KongLicense to cluster scoped and add printcolumns
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Jan 30, 2024
1 parent c2b1368 commit 6b4b884
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 24 deletions.
37 changes: 26 additions & 11 deletions config/crd/bases/configuration.konghq.com_konglicenses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@ spec:
shortNames:
- kl
singular: konglicense
scope: Namespaced
scope: Cluster
versions:
- name: v1alpha1
- additionalPrinterColumns:
- description: Age
jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: Enabled to configure on Kong gateway instances
jsonPath: .Enabled
name: Enabled
type: boolean
- jsonPath: .status.conditions[?(@.type=="Programmed")].status
name: Programmed
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: KongLicense stores a Kong enterprise license to apply to managed
Expand All @@ -34,7 +46,7 @@ spec:
enabled:
default: true
description: |-
Enabled is set to true to let controllers (like KIC) to reconcile it.
Enabled is set to true to let controllers (like KIC or KGO) to reconcile it.
Default value is true to apply the license by default.
type: boolean
kind:
Expand All @@ -48,8 +60,8 @@ spec:
metadata:
type: object
rawLicenseString:
description: RawLicenseString is the raw content of the license in string
format.
description: RawLicenseString is a string with the raw content of the
license.
type: string
status:
description: Status is the status of the KongLicense being processed by
Expand All @@ -62,6 +74,12 @@ spec:
identified by the controllerName field.
properties:
conditions:
default:
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: Waiting for controller
reason: Pending
status: Unknown
type: Programmed
description: Conditions describe the current conditions of the
KongLicense on the controller.
items:
Expand Down Expand Up @@ -139,10 +157,6 @@ spec:
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
configured:
description: Configured is set to true if the controller applied
the content of the license on managed Kong gateway.
type: boolean
controllerName:
description: |-
ControllerName is an identifier of the controller to reconcile this KongLicense.
Expand All @@ -161,7 +175,9 @@ spec:
pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
kind:
description: Kind is the kind of the referent.
description: |-
Kind is the kind of the referent.
By default the nil kind means kind Pod.
maxLength: 63
minLength: 1
pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$
Expand All @@ -183,7 +199,6 @@ spec:
- name
type: object
required:
- configured
- controllerName
type: object
type: array
Expand Down
9 changes: 4 additions & 5 deletions docs/api-reference.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions pkg/apis/configuration/v1alpha1/kong_license_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ import (
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced,shortName=kl,categories=kong-ingress-controller,path=konglicenses
// +kubebuilder:resource:scope=Cluster,shortName=kl,categories=kong-ingress-controller,path=konglicenses
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="Age"
// +kubebuilder:printcolumn:name="Enabled",type=boolean,JSONPath=`.Enabled`,description="Enabled to configure on Kong gateway instances"
// +kubebuilder:printcolumn:name="Programmed",type=string,JSONPath=`.status.conditions[?(@.type=="Programmed")].status`

// KongLicense stores a Kong enterprise license to apply to managed Kong gateway instances.
type KongLicense struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// RawLicenseString is the raw content of the license in string format.
// RawLicenseString is a string with the raw content of the license.
RawLicenseString string `json:"rawLicenseString"`
// Enabled is set to true to let controllers (like KIC) to reconcile it.
// Enabled is set to true to let controllers (like KIC or KGO) to reconcile it.
// Default value is true to apply the license by default.
// +kubebuilder:default=true
Enabled bool `json:"enabled"`
Expand All @@ -41,24 +44,21 @@ type KongLicenseControllerStatus struct {
// ControllerRef is the reference of the controller to reconcile this KongLicense.
// It is usually the name of (KIC/KGO) pod that reconciles it.
ControllerRef *ControllerReference `json:"controllerRef,omitempty"`
// Configured is set to true if the controller applied the content of the license on managed Kong gateway.
Configured bool `json:"configured"`
// Conditions describe the current conditions of the KongLicense on the controller.
// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=8
// +kubebuilder:default={{type: "Programmed", status: "Unknown", reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// TODO: copy validation notes from the gateway api package to run the same validation?

// Group refers to a Kubernetes Group. It must either be an empty string or a
// RFC 1123 subdomain.
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:validation:Pattern=`^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
type Group string

// Kind refers to a kubernetes kind.
// Kind refers to a Kubernetes kind.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern=`^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$`
Expand All @@ -83,6 +83,7 @@ type ControllerReference struct {
// It should be empty if the referent is in "core" group (like pod.)
Group *Group `json:"group,omitempty"`
// Kind is the kind of the referent.
// By default the nil kind means kind Pod.
Kind *Kind `json:"kind,omitempty"`
// Namespace is the namespace of the referent.
// It should be empty if the referent is cluster scoped.
Expand Down

0 comments on commit 6b4b884

Please sign in to comment.