kcr_flagger_app 3.20260117.223631

Kubernetes Custom Resource Bindings
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
// WARNING: generated by kopium - manual changes will be overwritten
// kopium command: kopium --docs --derive=Default --derive=PartialEq --smart-derive-elision --filename crd-catalog/fluxcd/flagger/flagger.app/v1beta1/canaries.yaml
// kopium version: 0.22.5

#[allow(unused_imports)]
mod prelude {
    pub use kube::CustomResource;
    pub use serde::{Serialize, Deserialize};
    pub use std::collections::BTreeMap;
    pub use k8s_openapi::apimachinery::pkg::util::intstr::IntOrString;
    pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
}
use self::prelude::*;

/// CanarySpec defines the desired state of a Canary.
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, PartialEq)]
#[kube(group = "flagger.app", version = "v1beta1", kind = "Canary", plural = "canaries")]
#[kube(namespaced)]
#[kube(status = "CanaryStatus")]
#[kube(schema = "disabled")]
#[kube(derive="PartialEq")]
pub struct CanarySpec {
    /// Canary analysis for this canary
    pub analysis: CanaryAnalysis,
    /// Scaler selector
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "autoscalerRef")]
    pub autoscaler_ref: Option<CanaryAutoscalerRef>,
    /// Ingress selector
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "ingressRef")]
    pub ingress_ref: Option<CanaryIngressRef>,
    /// Prometheus URL
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "metricsServer")]
    pub metrics_server: Option<String>,
    /// Deployment progress deadline
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "progressDeadlineSeconds")]
    pub progress_deadline_seconds: Option<f64>,
    /// Traffic managent provider
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub provider: Option<String>,
    /// Revert mutated resources to original spec on deletion
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "revertOnDeletion")]
    pub revert_on_deletion: Option<bool>,
    /// APISIX route selector
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "routeRef")]
    pub route_ref: Option<CanaryRouteRef>,
    /// Kubernetes Service spec
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub service: Option<CanaryService>,
    /// Skip analysis and promote canary
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "skipAnalysis")]
    pub skip_analysis: Option<bool>,
    /// Suspend Canary disabling/pausing all canary runs
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub suspend: Option<bool>,
    /// Target selector
    #[serde(rename = "targetRef")]
    pub target_ref: CanaryTargetRef,
    /// Gloo Upstream selector
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "upstreamRef")]
    pub upstream_ref: Option<CanaryUpstreamRef>,
}

/// Canary analysis for this canary
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAnalysis {
    /// Alert list for this canary analysis
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub alerts: Option<Vec<CanaryAnalysisAlerts>>,
    /// Percentage of pods that need to be available to consider canary as ready
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "canaryReadyThreshold")]
    pub canary_ready_threshold: Option<f64>,
    /// Schedule interval for this canary
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    /// Number of checks to run for A/B Testing and Blue/Green
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub iterations: Option<f64>,
    /// A/B testing match conditions
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "match")]
    pub r#match: Option<Vec<CanaryAnalysisMatch>>,
    /// Max traffic weight routed to canary
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxWeight")]
    pub max_weight: Option<f64>,
    /// Metric check list for this canary
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub metrics: Option<Vec<CanaryAnalysisMetrics>>,
    /// Mirror traffic to canary
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub mirror: Option<bool>,
    /// Weight of traffic to be mirrored
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "mirrorWeight")]
    pub mirror_weight: Option<f64>,
    /// Percentage of pods that need to be available to consider primary as ready
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "primaryReadyThreshold")]
    pub primary_ready_threshold: Option<f64>,
    /// SessionAffinity represents the session affinity settings for a canary run.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sessionAffinity")]
    pub session_affinity: Option<CanaryAnalysisSessionAffinity>,
    /// Incremental traffic step weight for the analysis phase
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "stepWeight")]
    pub step_weight: Option<f64>,
    /// Incremental traffic step weight for the promotion phase
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "stepWeightPromotion")]
    pub step_weight_promotion: Option<f64>,
    /// Incremental traffic step weights for the analysis phase
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "stepWeights")]
    pub step_weights: Option<Vec<f64>>,
    /// Max number of failed checks before rollback
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub threshold: Option<f64>,
    /// Webhook list for this canary
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub webhooks: Option<Vec<CanaryAnalysisWebhooks>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAnalysisAlerts {
    /// Name of the this alert
    pub name: String,
    /// Alert provider reference
    #[serde(rename = "providerRef")]
    pub provider_ref: CanaryAnalysisAlertsProviderRef,
    /// Severity level can be info, warn, error (default info)
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub severity: Option<CanaryAnalysisAlertsSeverity>,
}

/// Alert provider reference
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAnalysisAlertsProviderRef {
    /// Name of the alert provider
    pub name: String,
    /// Namespace of the alert provider
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryAnalysisAlertsSeverity {
    #[serde(rename = "")]
    KopiumEmpty,
    #[serde(rename = "info")]
    Info,
    #[serde(rename = "warn")]
    Warn,
    #[serde(rename = "error")]
    Error,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAnalysisMatch {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub headers: Option<BTreeMap<String, CanaryAnalysisMatchHeaders>>,
    /// Query parameters for matching.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "queryParams")]
    pub query_params: Option<BTreeMap<String, CanaryAnalysisMatchQueryParams>>,
    /// Applicable only when the 'mesh' gateway is included in the service.gateways list
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sourceLabels")]
    pub source_labels: Option<BTreeMap<String, String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAnalysisMatchHeaders {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// RE2 style regex-based match (<https://github.com/google/re2/wiki/Syntax)>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub suffix: Option<String>,
}

/// Query parameters for matching.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAnalysisMatchQueryParams {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// RE2 style regex-based match (<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAnalysisMetrics {
    /// Interval of the query
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    /// Name of the metric
    pub name: String,
    /// Prometheus query
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub query: Option<String>,
    /// Metric template reference
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "templateRef")]
    pub template_ref: Option<CanaryAnalysisMetricsTemplateRef>,
    /// Additional variables to be used in the metrics query (key-value pairs)
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "templateVariables")]
    pub template_variables: Option<BTreeMap<String, String>>,
    /// Max value accepted for this metric
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub threshold: Option<f64>,
    /// Range accepted for this metric
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "thresholdRange")]
    pub threshold_range: Option<CanaryAnalysisMetricsThresholdRange>,
}

/// Metric template reference
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAnalysisMetricsTemplateRef {
    /// Name of this metric template
    pub name: String,
    /// Namespace of this metric template
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
}

/// Range accepted for this metric
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAnalysisMetricsThresholdRange {
    /// Max value accepted for this metric
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub max: Option<f64>,
    /// Min value accepted for this metric
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub min: Option<f64>,
}

/// SessionAffinity represents the session affinity settings for a canary run.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAnalysisSessionAffinity {
    /// CookieName is the key that will be used for the session affinity cookie.
    #[serde(rename = "cookieName")]
    pub cookie_name: String,
    /// Domain defines the host to which the cookie will be sent.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// HttpOnly forbids JavaScript from accessing the cookie, for example, through the Document.cookie property.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpOnly")]
    pub http_only: Option<bool>,
    /// MaxAge indicates the number of seconds until the session affinity cookie will expire.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")]
    pub max_age: Option<f64>,
    /// Partitioned indicates that the cookie should be stored using partitioned storage.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub partitioned: Option<bool>,
    /// Path indicates the path that must exist in the requested URL for the browser to send the Cookie header.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
    /// CookieName is the key that will be used for the session affinity cookie.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "primaryCookieName")]
    pub primary_cookie_name: Option<String>,
    /// SameSite controls whether or not a cookie is sent with cross-site requests.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sameSite")]
    pub same_site: Option<CanaryAnalysisSessionAffinitySameSite>,
    /// Secure indicates that the cookie is sent to the server only when a request is made with the https: scheme (except on localhost)
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub secure: Option<bool>,
}

/// SessionAffinity represents the session affinity settings for a canary run.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryAnalysisSessionAffinitySameSite {
    Strict,
    Lax,
    None,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAnalysisWebhooks {
    /// Disable TLS verification for this webhook
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "disableTLS")]
    pub disable_tls: Option<bool>,
    /// Metadata (key-value pairs) for this webhook
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub metadata: Option<BTreeMap<String, String>>,
    /// Mute all alerts for the webhook
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "muteAlert")]
    pub mute_alert: Option<bool>,
    /// Name of the webhook
    pub name: String,
    /// Number of retries for this webhook
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub retries: Option<f64>,
    /// Request timeout for this webhook
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub timeout: Option<String>,
    /// Type of the webhook pre, post or during rollout
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
    pub r#type: Option<CanaryAnalysisWebhooksType>,
    /// URL address of this webhook
    pub url: String,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryAnalysisWebhooksType {
    #[serde(rename = "")]
    KopiumEmpty,
    #[serde(rename = "confirm-rollout")]
    ConfirmRollout,
    #[serde(rename = "pre-rollout")]
    PreRollout,
    #[serde(rename = "rollout")]
    Rollout,
    #[serde(rename = "confirm-promotion")]
    ConfirmPromotion,
    #[serde(rename = "post-rollout")]
    PostRollout,
    #[serde(rename = "event")]
    Event,
    #[serde(rename = "rollback")]
    Rollback,
    #[serde(rename = "confirm-traffic-increase")]
    ConfirmTrafficIncrease,
}

/// Scaler selector
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct CanaryAutoscalerRef {
    #[serde(rename = "apiVersion")]
    pub api_version: String,
    pub kind: CanaryAutoscalerRefKind,
    pub name: String,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "primaryScalerQueries")]
    pub primary_scaler_queries: Option<BTreeMap<String, String>>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "primaryScalerReplicas")]
    pub primary_scaler_replicas: Option<CanaryAutoscalerRefPrimaryScalerReplicas>,
}

/// Scaler selector
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryAutoscalerRefKind {
    HorizontalPodAutoscaler,
    ScaledObject,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryAutoscalerRefPrimaryScalerReplicas {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxReplicas")]
    pub max_replicas: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "minReplicas")]
    pub min_replicas: Option<i64>,
}

/// Ingress selector
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct CanaryIngressRef {
    #[serde(rename = "apiVersion")]
    pub api_version: String,
    pub kind: CanaryIngressRefKind,
    pub name: String,
}

/// Ingress selector
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryIngressRefKind {
    Ingress,
}

/// APISIX route selector
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct CanaryRouteRef {
    #[serde(rename = "apiVersion")]
    pub api_version: String,
    pub kind: CanaryRouteRefKind,
    pub name: String,
}

/// APISIX route selector
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryRouteRefKind {
    ApisixRoute,
}

/// Kubernetes Service spec
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryService {
    /// Metadata to add to the apex service
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub apex: Option<CanaryServiceApex>,
    /// Application protocol of the port
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "appProtocol")]
    pub app_protocol: Option<String>,
    /// AppMesh backend array
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub backends: Option<Vec<String>>,
    /// Metadata to add to the canary service
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub canary: Option<CanaryServiceCanary>,
    /// Istio Cross-Origin Resource Sharing policy (CORS)
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "corsPolicy")]
    pub cors_policy: Option<CanaryServiceCorsPolicy>,
    /// enable behaving as a delegate VirtualService
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub delegation: Option<bool>,
    /// The list of parent Gateways for a HTTPRoute
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "gatewayRefs")]
    pub gateway_refs: Option<Vec<CanaryServiceGatewayRefs>>,
    /// The list of Istio gateway for this virtual service
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub gateways: Option<Vec<String>>,
    /// Headers operations
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub headers: Option<CanaryServiceHeaders>,
    /// Headless if set to true, generates headless Kubernetes services.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub headless: Option<bool>,
    /// The list of host names for this service
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub hosts: Option<Vec<String>>,
    /// URI match conditions
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "match")]
    pub r#match: Option<Vec<CanaryServiceMatch>>,
    /// AppMesh mesh name
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "meshName")]
    pub mesh_name: Option<String>,
    /// Mirror defines a schema for a filter that mirrors requests.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub mirror: Option<Vec<CanaryServiceMirror>>,
    /// Kubernetes service name
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Container port number
    pub port: f64,
    /// Enable port discovery
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portDiscovery")]
    pub port_discovery: Option<bool>,
    /// Container port name
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portName")]
    pub port_name: Option<String>,
    /// Metadata to add to the primary service
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub primary: Option<CanaryServicePrimary>,
    /// Retry policy for HTTP requests
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub retries: Option<CanaryServiceRetries>,
    /// Rewrite HTTP URIs
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub rewrite: Option<CanaryServiceRewrite>,
    /// Container target port name
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "targetPort")]
    pub target_port: Option<IntOrString>,
    /// HTTP or gRPC request timeout
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub timeout: Option<String>,
    /// Traffic distribution of the service
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "trafficDistribution")]
    pub traffic_distribution: Option<CanaryServiceTrafficDistribution>,
    /// Istio traffic policy
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "trafficPolicy")]
    pub traffic_policy: Option<CanaryServiceTrafficPolicy>,
    /// UnmanagedMetadata is a list of metadata keys that should be ignored by Flagger.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "unmanagedMetadata")]
    pub unmanaged_metadata: Option<CanaryServiceUnmanagedMetadata>,
}

/// Metadata to add to the apex service
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceApex {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub annotations: Option<BTreeMap<String, String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub labels: Option<BTreeMap<String, String>>,
}

/// Metadata to add to the canary service
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceCanary {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub annotations: Option<BTreeMap<String, String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub labels: Option<BTreeMap<String, String>>,
}

/// Istio Cross-Origin Resource Sharing policy (CORS)
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceCorsPolicy {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "allowCredentials")]
    pub allow_credentials: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "allowHeaders")]
    pub allow_headers: Option<Vec<String>>,
    /// List of HTTP methods allowed to access the resource
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "allowMethods")]
    pub allow_methods: Option<Vec<String>>,
    /// The list of origins that are allowed to perform CORS requests.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "allowOrigin")]
    pub allow_origin: Option<Vec<String>>,
    /// String patterns that match allowed origins
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "allowOrigins")]
    pub allow_origins: Option<Vec<CanaryServiceCorsPolicyAllowOrigins>>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "exposeHeaders")]
    pub expose_headers: Option<Vec<String>>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")]
    pub max_age: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceCorsPolicyAllowOrigins {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceGatewayRefs {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub group: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kind: Option<String>,
    pub name: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<i32>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sectionName")]
    pub section_name: Option<String>,
}

/// Headers operations
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceHeaders {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub request: Option<CanaryServiceHeadersRequest>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub response: Option<CanaryServiceHeadersResponse>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceHeadersRequest {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub add: Option<BTreeMap<String, String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub remove: Option<Vec<String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub set: Option<BTreeMap<String, String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceHeadersResponse {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub add: Option<BTreeMap<String, String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub remove: Option<Vec<String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub set: Option<BTreeMap<String, String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceMatch {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub authority: Option<CanaryServiceMatchAuthority>,
    /// Names of gateways where the rule should be applied.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub gateways: Option<Vec<String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub headers: Option<BTreeMap<String, CanaryServiceMatchHeaders>>,
    /// Flag to specify whether the URI matching should be case-insensitive.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "ignoreUriCase")]
    pub ignore_uri_case: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub method: Option<CanaryServiceMatchMethod>,
    /// The name assigned to a match.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Specifies the ports on the host that is being addressed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<i64>,
    /// Query parameters for matching.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "queryParams")]
    pub query_params: Option<BTreeMap<String, CanaryServiceMatchQueryParams>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scheme: Option<CanaryServiceMatchScheme>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sourceLabels")]
    pub source_labels: Option<BTreeMap<String, String>>,
    /// Source namespace constraining the applicability of a rule to workloads in that namespace.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sourceNamespace")]
    pub source_namespace: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub uri: Option<CanaryServiceMatchUri>,
    /// withoutHeader has the same syntax with the header, but has opposite meaning.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "withoutHeaders")]
    pub without_headers: Option<BTreeMap<String, CanaryServiceMatchWithoutHeaders>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceMatchAuthority {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// RE2 style regex-based match (<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceMatchHeaders {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// RE2 style regex-based match (<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceMatchMethod {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// RE2 style regex-based match (<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

/// Query parameters for matching.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceMatchQueryParams {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// RE2 style regex-based match (<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceMatchScheme {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// RE2 style regex-based match (<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceMatchUri {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// RE2 style regex-based match (<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

/// withoutHeader has the same syntax with the header, but has opposite meaning.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceMatchWithoutHeaders {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// RE2 style regex-based match (<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceMirror {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "backendRef")]
    pub backend_ref: Option<CanaryServiceMirrorBackendRef>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceMirrorBackendRef {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub group: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kind: Option<String>,
    pub name: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<i32>,
}

/// Metadata to add to the primary service
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServicePrimary {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub annotations: Option<BTreeMap<String, String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub labels: Option<BTreeMap<String, String>>,
}

/// Retry policy for HTTP requests
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceRetries {
    /// Number of retries for a given request
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub attempts: Option<i32>,
    /// Timeout per retry attempt for a given request
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "perTryTimeout")]
    pub per_try_timeout: Option<String>,
    /// Specifies the conditions under which retry takes place
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "retryOn")]
    pub retry_on: Option<String>,
}

/// Rewrite HTTP URIs
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceRewrite {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub authority: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
    pub r#type: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub uri: Option<String>,
}

/// Kubernetes Service spec
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryServiceTrafficDistribution {
    PreferClose,
    PreferSameZone,
    PreferSameNode,
}

/// Istio traffic policy
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceTrafficPolicy {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectionPool")]
    pub connection_pool: Option<CanaryServiceTrafficPolicyConnectionPool>,
    /// Settings controlling the load balancer algorithms.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "loadBalancer")]
    pub load_balancer: Option<CanaryServiceTrafficPolicyLoadBalancer>,
    /// Settings controlling eviction of unhealthy hosts from the load balancing pool.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "outlierDetection")]
    pub outlier_detection: Option<CanaryServiceTrafficPolicyOutlierDetection>,
    /// Istio TLS related settings for connections to the upstream service
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tls: Option<CanaryServiceTrafficPolicyTls>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceTrafficPolicyConnectionPool {
    /// HTTP connection pool settings.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub http: Option<CanaryServiceTrafficPolicyConnectionPoolHttp>,
}

/// HTTP connection pool settings.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceTrafficPolicyConnectionPoolHttp {
    /// Specify if http1.1 connection should be upgraded to http2 for the associated destination.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "h2UpgradePolicy")]
    pub h2_upgrade_policy: Option<CanaryServiceTrafficPolicyConnectionPoolHttpH2UpgradePolicy>,
    /// Maximum number of pending HTTP requests to a destination.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "http1MaxPendingRequests")]
    pub http1_max_pending_requests: Option<i32>,
    /// Maximum number of requests to a backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "http2MaxRequests")]
    pub http2_max_requests: Option<i32>,
    /// The idle timeout for upstream connection pool connections.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "idleTimeout")]
    pub idle_timeout: Option<String>,
    /// Maximum number of requests per connection to a backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxRequestsPerConnection")]
    pub max_requests_per_connection: Option<i32>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxRetries")]
    pub max_retries: Option<i32>,
}

/// HTTP connection pool settings.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryServiceTrafficPolicyConnectionPoolHttpH2UpgradePolicy {
    #[serde(rename = "DEFAULT")]
    Default,
    #[serde(rename = "DO_NOT_UPGRADE")]
    DoNotUpgrade,
    #[serde(rename = "UPGRADE")]
    Upgrade,
}

/// Settings controlling the load balancer algorithms.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceTrafficPolicyLoadBalancer {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consistentHash")]
    pub consistent_hash: Option<CanaryServiceTrafficPolicyLoadBalancerConsistentHash>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "localityLbSetting")]
    pub locality_lb_setting: Option<CanaryServiceTrafficPolicyLoadBalancerLocalityLbSetting>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub simple: Option<CanaryServiceTrafficPolicyLoadBalancerSimple>,
    /// Represents the warmup duration of Service.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "warmupDurationSecs")]
    pub warmup_duration_secs: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceTrafficPolicyLoadBalancerConsistentHash {
    /// Hash based on HTTP cookie.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpCookie")]
    pub http_cookie: Option<CanaryServiceTrafficPolicyLoadBalancerConsistentHashHttpCookie>,
    /// Hash based on a specific HTTP header.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpHeaderName")]
    pub http_header_name: Option<String>,
    /// Hash based on a specific HTTP query parameter.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpQueryParameterName")]
    pub http_query_parameter_name: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "minimumRingSize")]
    pub minimum_ring_size: Option<i64>,
    /// Hash based on the source IP address.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useSourceIp")]
    pub use_source_ip: Option<bool>,
}

/// Hash based on HTTP cookie.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceTrafficPolicyLoadBalancerConsistentHashHttpCookie {
    /// Name of the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Path to set for the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
    /// Lifetime of the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ttl: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceTrafficPolicyLoadBalancerLocalityLbSetting {
    /// Optional: only one of distribute or failover can be set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub distribute: Option<Vec<CanaryServiceTrafficPolicyLoadBalancerLocalityLbSettingDistribute>>,
    /// enable locality load balancing, this is DestinationRule-level and will override mesh wide settings in entirety.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub enabled: Option<bool>,
    /// Optional: only failover or distribute can be set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub failover: Option<Vec<CanaryServiceTrafficPolicyLoadBalancerLocalityLbSettingFailover>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceTrafficPolicyLoadBalancerLocalityLbSettingDistribute {
    /// Originating locality, '/' separated, e.g.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    /// Map of upstream localities to traffic distribution weights.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub to: Option<BTreeMap<String, i64>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceTrafficPolicyLoadBalancerLocalityLbSettingFailover {
    /// Originating region.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub to: Option<String>,
}

/// Settings controlling the load balancer algorithms.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryServiceTrafficPolicyLoadBalancerSimple {
    #[serde(rename = "ROUND_ROBIN")]
    RoundRobin,
    #[serde(rename = "LEAST_CONN")]
    LeastConn,
    #[serde(rename = "RANDOM")]
    Random,
    #[serde(rename = "PASSTHROUGH")]
    Passthrough,
    #[serde(rename = "LEAST_REQUEST")]
    LeastRequest,
}

/// Settings controlling eviction of unhealthy hosts from the load balancing pool.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceTrafficPolicyOutlierDetection {
    /// Minimum ejection duration.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "baseEjectionTime")]
    pub base_ejection_time: Option<String>,
    /// Number of 5xx errors before a host is ejected from the connection pool.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutive5xxErrors")]
    pub consecutive5xx_errors: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveErrors")]
    pub consecutive_errors: Option<i32>,
    /// Number of gateway errors before a host is ejected from the connection pool.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveGatewayErrors")]
    pub consecutive_gateway_errors: Option<i32>,
    /// Time interval between ejection sweep analysis.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxEjectionPercent")]
    pub max_ejection_percent: Option<i32>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "minHealthPercent")]
    pub min_health_percent: Option<i32>,
}

/// Istio TLS related settings for connections to the upstream service
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceTrafficPolicyTls {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "caCertificates")]
    pub ca_certificates: Option<String>,
    /// REQUIRED if mode is `MUTUAL`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "clientCertificate")]
    pub client_certificate: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub mode: Option<CanaryServiceTrafficPolicyTlsMode>,
    /// REQUIRED if mode is `MUTUAL`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "privateKey")]
    pub private_key: Option<String>,
    /// SNI string to present to the server during TLS handshake.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sni: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "subjectAltNames")]
    pub subject_alt_names: Option<Vec<String>>,
}

/// Istio TLS related settings for connections to the upstream service
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryServiceTrafficPolicyTlsMode {
    #[serde(rename = "DISABLE")]
    Disable,
    #[serde(rename = "SIMPLE")]
    Simple,
    #[serde(rename = "MUTUAL")]
    Mutual,
    #[serde(rename = "ISTIO_MUTUAL")]
    IstioMutual,
}

/// UnmanagedMetadata is a list of metadata keys that should be ignored by Flagger.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryServiceUnmanagedMetadata {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub annotations: Option<Vec<String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub labels: Option<Vec<String>>,
}

/// Target selector
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct CanaryTargetRef {
    #[serde(rename = "apiVersion")]
    pub api_version: String,
    pub kind: CanaryTargetRefKind,
    pub name: String,
}

/// Target selector
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryTargetRefKind {
    DaemonSet,
    Deployment,
    Service,
}

/// Gloo Upstream selector
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct CanaryUpstreamRef {
    #[serde(rename = "apiVersion")]
    pub api_version: String,
    pub kind: CanaryUpstreamRefKind,
    pub name: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
}

/// Gloo Upstream selector
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryUpstreamRefKind {
    Upstream,
}

/// CanaryStatus defines the observed state of a canary.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct CanaryStatus {
    /// Traffic weight routed to canary
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "canaryWeight")]
    pub canary_weight: Option<f64>,
    /// Status conditions of this canary
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub conditions: Option<Vec<Condition>>,
    /// Failed check count of the current canary analysis
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "failedChecks")]
    pub failed_checks: Option<f64>,
    /// Iteration count of the current canary analysis
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub iterations: Option<f64>,
    /// LastAppliedSpec of this canary
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "lastAppliedSpec")]
    pub last_applied_spec: Option<String>,
    /// LastPromotedSpec of this canary
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "lastPromotedSpec")]
    pub last_promoted_spec: Option<String>,
    /// LastTransitionTime of this canary
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "lastTransitionTime")]
    pub last_transition_time: Option<String>,
    /// Analysis phase of this canary
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub phase: Option<CanaryStatusPhase>,
    /// Session affinity cookie of the previous canary run
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "previousSessionAffinityCookie")]
    pub previous_session_affinity_cookie: Option<String>,
    /// Primary session affinity cookie of the current canary run
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "primarySessionAffinityCookie")]
    pub primary_session_affinity_cookie: Option<String>,
    /// Session affinity cookie of the current canary run
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sessionAffinityCookie")]
    pub session_affinity_cookie: Option<String>,
    /// TrackedConfig of this canary
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "trackedConfigs")]
    pub tracked_configs: Option<BTreeMap<String, String>>,
}

/// CanaryStatus defines the observed state of a canary.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum CanaryStatusPhase {
    #[serde(rename = "")]
    KopiumEmpty,
    Initializing,
    Initialized,
    Waiting,
    Progressing,
    WaitingPromotion,
    Promoting,
    Finalising,
    Succeeded,
    Failed,
    Terminating,
    Terminated,
}