@@ -427,6 +427,7 @@ option go_package = "istio.io/api/networking/v1alpha3";
427
427
// Clients may not set this value. It is represented in RFC3339 form and is in UTC.
428
428
// Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata"
429
429
// +cue-gen:ServiceEntry:preserveUnknownFields:false
430
+ // +cue-gen:ServiceEntry:spec:required
430
431
// -->
431
432
//
432
433
// <!-- go code generation tags
@@ -436,6 +437,10 @@ option go_package = "istio.io/api/networking/v1alpha3";
436
437
// +k8s:deepcopy-gen=true
437
438
// istiostatus-override: ServiceEntryStatus: istio.io/api/networking/v1alpha3
438
439
// -->
440
+ // +kubebuilder:validation:XValidation:message="only one of WorkloadSelector or Endpoints can be set",rule="(has(self.workloadSelector)?1:0)+(has(self.endpoints)?1:0)<=1"
441
+ // +kubebuilder:validation:XValidation:message="CIDR addresses are allowed only for NONE/STATIC resolution types",rule="!(has(self.addresses) && self.addresses.exists(k, k.contains('/')) && (self.resolution != 'STATIC' && self.resolution != 'NONE'))"
442
+ // +kubebuilder:validation:XValidation:message="NONE mode cannot set endpoints",rule="(!has(self.resolution) || self.resolution == 'NONE') ? !has(self.endpoints) : true"
443
+ // +kubebuilder:validation:XValidation:message="DNS_ROUND_ROBIN mode cannot have multiple endpoints",rule="(has(self.resolution) && self.resolution == 'DNS_ROUND_ROBIN') ? (!has(self.endpoints) || size(self.endpoints) == 1) : true"
439
444
message ServiceEntry {
440
445
// The hosts associated with the ServiceEntry. Could be a DNS
441
446
// name with wildcard prefix.
@@ -460,7 +465,9 @@ message ServiceEntry {
460
465
// 1. subjectAltNames: In addition to verifying the SANs of the
461
466
// service accounts associated with the pods of the service, the
462
467
// SANs specified here will also be verified.
463
- //
468
+ // +kubebuilder:validation:MinItems=1
469
+ // +kubebuilder:validation:MaxItems=256
470
+ // +protoc-gen-crd:list-value-validation:XValidation:message="hostname cannot be wildcard",rule="self != '*'"
464
471
repeated string hosts = 1 [(google.api.field_behavior ) = REQUIRED ];
465
472
466
473
// The virtual IP addresses associated with the service. Could be CIDR
@@ -477,11 +484,17 @@ message ServiceEntry {
477
484
// simple TCP proxy, forwarding incoming traffic on a specified port to
478
485
// the specified destination endpoint IP/host. Unix domain socket
479
486
// addresses are not supported in this field.
487
+ // +kubebuilder:validation:MaxItems=256
488
+ // +protoc-gen-crd:list-value-validation:MaxLength=64
480
489
repeated string addresses = 2 ;
481
490
482
491
// The ports associated with the external service. If the
483
492
// Endpoints are Unix domain socket addresses, there must be exactly one
484
493
// port.
494
+ // +listType=map
495
+ // +listMapKey=name
496
+ // +kubebuilder:validation:MaxItems=256
497
+ // +kubebuilder:validation:XValidation:message="port number cannot be duplicated",rule="self.all(l1, self.exists_one(l2, l1.number == l2.number))"
485
498
repeated ServicePort ports = 3 ;
486
499
487
500
// Location specifies whether the service is part of Istio mesh or
@@ -600,19 +613,23 @@ message ServiceEntry {
600
613
// ServicePort describes the properties of a specific port of a service.
601
614
message ServicePort {
602
615
// A valid non-negative integer port number.
616
+ // +kubebuilder:validation:XValidation:message="port must be between 1-65535",rule="0 < self && self <= 65535"
603
617
uint32 number = 1 [(google.api.field_behavior ) = REQUIRED ];
604
618
605
619
// The protocol exposed on the port.
606
620
// MUST BE one of HTTP|HTTPS|GRPC|HTTP2|MONGO|TCP|TLS.
607
621
// TLS implies the connection will be routed based on the SNI header to
608
622
// the destination without terminating the TLS connection.
623
+ // +kubebuilder:validation:MaxLength=256
609
624
string protocol = 2 ;
610
625
611
626
// Label assigned to the port.
627
+ // +kubebuilder:validation:MaxLength=256
612
628
string name = 3 [(google.api.field_behavior ) = REQUIRED ];
613
629
614
630
// The port number on the endpoint where the traffic will be
615
631
// received. If unset, default to `number`.
632
+ // +kubebuilder:validation:XValidation:message="port must be between 1-65535",rule="0 < self && self <= 65535"
616
633
uint32 target_port = 4 ;
617
634
}
618
635
0 commit comments