Skip to content

Commit 6dd51d2

Browse files
authored
feat: Ingress replica CRD (#268)
* introduce ingressReplica CRD * update CRD yaml file * fix unit tests * merge labels and annotations
1 parent 2807058 commit 6dd51d2

File tree

8 files changed

+883
-1
lines changed

8 files changed

+883
-1
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package v1alpha1
2+
3+
import (
4+
corev1 "k8s.io/api/core/v1"
5+
v1 "k8s.io/api/networking/v1"
6+
"k8s.io/apimachinery/pkg/api/meta"
7+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
8+
)
9+
10+
func init() {
11+
SchemeBuilder.Register(&IngressReplica{}, &IngressReplicaList{})
12+
}
13+
14+
// IngressReplicaList contains a list of [IngressReplica]
15+
// +kubebuilder:object:root=true
16+
type IngressReplicaList struct {
17+
metav1.TypeMeta `json:",inline"`
18+
metav1.ListMeta `json:"metadata,omitempty"`
19+
Items []IngressReplica `json:"items"`
20+
}
21+
22+
// IngressReplica is the Schema for the console ingress replica
23+
// +kubebuilder:object:root=true
24+
// +kubebuilder:resource:scope=Namespaced
25+
// +kubebuilder:subresource:status
26+
type IngressReplica struct {
27+
metav1.TypeMeta `json:",inline"`
28+
metav1.ObjectMeta `json:"metadata,omitempty"`
29+
30+
// Spec of the IngressReplica
31+
// +kubebuilder:validation:Required
32+
Spec IngressReplicaSpec `json:"spec"`
33+
34+
// Status of the IngressReplica
35+
// +kubebuilder:validation:Optional
36+
Status Status `json:"status,omitempty"`
37+
}
38+
39+
type IngressReplicaSpec struct {
40+
// +kubebuilder:validation:Required
41+
IngressRef corev1.ObjectReference `json:"ingressRef"`
42+
43+
// +kubebuilder:validation:Optional
44+
IngressClassName *string `json:"ingressClassName,omitempty"`
45+
46+
// +kubebuilder:validation:Optional
47+
TLS []v1.IngressTLS `json:"tls,omitempty"`
48+
49+
// +kubebuilder:validation:Required
50+
HostMappings map[string]string `json:"hostMappings"`
51+
}
52+
53+
func (in *IngressReplica) SetCondition(condition metav1.Condition) {
54+
meta.SetStatusCondition(&in.Status.Conditions, condition)
55+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 95 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.3
7+
name: ingressreplicas.deployments.plural.sh
8+
spec:
9+
group: deployments.plural.sh
10+
names:
11+
kind: IngressReplica
12+
listKind: IngressReplicaList
13+
plural: ingressreplicas
14+
singular: ingressreplica
15+
scope: Namespaced
16+
versions:
17+
- name: v1alpha1
18+
schema:
19+
openAPIV3Schema:
20+
description: IngressReplica is the Schema for the console ingress replica
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: Spec of the IngressReplica
41+
properties:
42+
hostMappings:
43+
additionalProperties:
44+
type: string
45+
type: object
46+
ingressClassName:
47+
type: string
48+
ingressRef:
49+
description: ObjectReference contains enough information to let you
50+
inspect or modify the referred object.
51+
properties:
52+
apiVersion:
53+
description: API version of the referent.
54+
type: string
55+
fieldPath:
56+
description: |-
57+
If referring to a piece of an object instead of an entire object, this string
58+
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
59+
For example, if the object reference is to a container within a pod, this would take on a value like:
60+
"spec.containers{name}" (where "name" refers to the name of the container that triggered
61+
the event) or if no container name is specified "spec.containers[2]" (container with
62+
index 2 in this pod). This syntax is chosen only to have some well-defined way of
63+
referencing a part of an object.
64+
type: string
65+
kind:
66+
description: |-
67+
Kind of the referent.
68+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
69+
type: string
70+
name:
71+
description: |-
72+
Name of the referent.
73+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
74+
type: string
75+
namespace:
76+
description: |-
77+
Namespace of the referent.
78+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
79+
type: string
80+
resourceVersion:
81+
description: |-
82+
Specific resourceVersion to which this reference is made, if any.
83+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
84+
type: string
85+
uid:
86+
description: |-
87+
UID of the referent.
88+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
89+
type: string
90+
type: object
91+
x-kubernetes-map-type: atomic
92+
tls:
93+
items:
94+
description: IngressTLS describes the transport layer security associated
95+
with an ingress.
96+
properties:
97+
hosts:
98+
description: |-
99+
hosts is a list of hosts included in the TLS certificate. The values in
100+
this list must match the name/s used in the tlsSecret. Defaults to the
101+
wildcard host setting for the loadbalancer controller fulfilling this
102+
Ingress, if left unspecified.
103+
items:
104+
type: string
105+
type: array
106+
x-kubernetes-list-type: atomic
107+
secretName:
108+
description: |-
109+
secretName is the name of the secret used to terminate TLS traffic on
110+
port 443. Field is left optional to allow TLS routing based on SNI
111+
hostname alone. If the SNI host in a listener conflicts with the "Host"
112+
header field used by an IngressRule, the SNI host is used for termination
113+
and value of the "Host" header is used for routing.
114+
type: string
115+
type: object
116+
type: array
117+
required:
118+
- hostMappings
119+
- ingressRef
120+
type: object
121+
status:
122+
description: Status of the IngressReplica
123+
properties:
124+
conditions:
125+
description: Represents the observations of a PrAutomation's current
126+
state.
127+
items:
128+
description: Condition contains details for one aspect of the current
129+
state of this API Resource.
130+
properties:
131+
lastTransitionTime:
132+
description: |-
133+
lastTransitionTime is the last time the condition transitioned from one status to another.
134+
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
135+
format: date-time
136+
type: string
137+
message:
138+
description: |-
139+
message is a human readable message indicating details about the transition.
140+
This may be an empty string.
141+
maxLength: 32768
142+
type: string
143+
observedGeneration:
144+
description: |-
145+
observedGeneration represents the .metadata.generation that the condition was set based upon.
146+
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
147+
with respect to the current state of the instance.
148+
format: int64
149+
minimum: 0
150+
type: integer
151+
reason:
152+
description: |-
153+
reason contains a programmatic identifier indicating the reason for the condition's last transition.
154+
Producers of specific condition types may define expected values and meanings for this field,
155+
and whether the values are considered a guaranteed API.
156+
The value should be a CamelCase string.
157+
This field may not be empty.
158+
maxLength: 1024
159+
minLength: 1
160+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
161+
type: string
162+
status:
163+
description: status of the condition, one of True, False, Unknown.
164+
enum:
165+
- "True"
166+
- "False"
167+
- Unknown
168+
type: string
169+
type:
170+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
171+
maxLength: 316
172+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
173+
type: string
174+
required:
175+
- lastTransitionTime
176+
- message
177+
- reason
178+
- status
179+
- type
180+
type: object
181+
type: array
182+
x-kubernetes-list-map-keys:
183+
- type
184+
x-kubernetes-list-type: map
185+
id:
186+
description: ID of the resource in the Console API.
187+
type: string
188+
sha:
189+
description: SHA of last applied configuration.
190+
type: string
191+
type: object
192+
required:
193+
- spec
194+
type: object
195+
served: true
196+
storage: true
197+
subresources:
198+
status: {}

cmd/agent/kubernetes.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ func registerKubeReconcilersOrDie(
171171
setupLog.Error(err, "unable to create controller", "controller", "StackRun")
172172
}
173173

174+
if err := (&controller.IngressReplicaReconciler{
175+
Client: manager.GetClient(),
176+
Scheme: manager.GetScheme(),
177+
}).SetupWithManager(manager); err != nil {
178+
setupLog.Error(err, "unable to create controller", "controller", "IngressReplica")
179+
}
180+
174181
rawConsoleUrl, _ := strings.CutSuffix(args.ConsoleUrl(), "/ext/gql")
175182
if err := (&controller.VirtualClusterController{
176183
Client: manager.GetClient(),

0 commit comments

Comments
 (0)