File size: 19,594 Bytes
df0899b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
id: verifydeprecatedapi
title: Verify deprecated APIs
---

# Verify deprecated APIs

## Description
Verifies deprecated Kubernetes APIs to ensure all the API versions are up to date. This template does not apply to audit as audit looks at the resources which are already present in the cluster with non-deprecated API versions.

## Template
```yaml
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
  name: verifydeprecatedapi
  annotations:
    metadata.gatekeeper.sh/title: "Verify deprecated APIs"
    metadata.gatekeeper.sh/version: 1.0.0
    description: >-
      Verifies deprecated Kubernetes APIs to ensure all the API versions are up to date. This template does not apply to audit as audit looks at the resources which are already present in the cluster with non-deprecated API versions.
spec:
  crd:
    spec:
      names:
        kind: VerifyDeprecatedAPI
      validation:
        openAPIV3Schema:
          type: object
          properties:
            kvs:
              type: array
              description: Deprecated api versions and corresponding kinds
              items:
                type: object
                properties:
                  deprecatedAPI:
                    type: string
                    description: deprecated api
                    example: flowcontrol.apiserver.k8s.io/v1beta2
                  kinds:
                    type: array
                    items:
                      type: string
                    description: impacted list of kinds
                    example: '["FlowSchema", "PriorityLevelConfiguration"]'
                  targetAPI:
                    type: string
                    description: target api
                    example: flowcontrol.apiserver.k8s.io/v1beta3
            k8sVersion:
              type: number
              description: kubernetes version
  targets:
    - target: admission.k8s.gatekeeper.sh
      rego: |
        package verifydeprecatedapi

        violation[{"msg": msg}] {
          kvs := input.parameters.kvs[_]
          kvs.deprecatedAPI == input.review.object.apiVersion
          k := kvs.kinds[_]
          k == input.review.object.kind
          msg := get_message(input.review.object.kind, input.review.object.apiVersion, input.parameters.k8sVersion, kvs.targetAPI)
        }

        get_message(kind, apiVersion, k8sVersion, targetAPI) = msg {
          not match(targetAPI)
          msg := sprintf("API %v for %v is deprecated in Kubernetes version %v, please use %v instead", [kind, apiVersion, k8sVersion, targetAPI])
        }

        get_message(kind, apiVersion, k8sVersion, targetAPI) = msg {
          match(targetAPI)
          msg := sprintf("API %v for %v is deprecated in Kubernetes version %v, please see Kubernetes API deprecation guide", [kind, apiVersion, k8sVersion])
        }

        match(api) {
          api == "None"
        }

```

### Usage
```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/template.yaml
```
## Examples
<details>
<summary>verifydeprecatedapi-1.16</summary>

<details>
<summary>constraint</summary>

```yaml
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: VerifyDeprecatedAPI
metadata:
  name: verify-1.16
spec:
  match:
    kinds:
      - apiGroups: ["apps"]
        kinds: ["Deployment", "ReplicaSet", "StatefulSet", "DaemonSet"]
      - apiGroups: ["extensions"]
        kinds: ["PodSecurityPolicy", "ReplicaSet", "Deployment", "DaemonSet", "NetworkPolicy"]
  parameters:
    kvs: 
      - deprecatedAPI: "apps/v1beta1"
        kinds: ["Deployment", "ReplicaSet", "StatefulSet"]
        targetAPI: "apps/v1"
      - deprecatedAPI: "extensions/v1beta1"
        kinds: ["ReplicaSet", "Deployment", "DaemonSet"]
        targetAPI: "apps/v1"
      - deprecatedAPI: "extensions/v1beta1"
        kinds: ["PodSecurityPolicy"]
        targetAPI: "policy/v1beta1"
      - deprecatedAPI: "apps/v1beta2"
        kinds: ["ReplicaSet", "StatefulSet", "Deployment", "DaemonSet"]
        targetAPI: "apps/v1"
      - deprecatedAPI: "extensions/v1beta1"
        kinds: ["NetworkPolicy"]
        targetAPI: "networking.k8s.io/v1"
    k8sVersion: 1.16

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.16/constraint.yaml
```

</details>

<details>
<summary>example-allowed</summary>

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: allowed-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.16/example_allowed.yaml
```

</details>
<details>
<summary>example-disallowed</summary>

```yaml
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: disallowed-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.16/example_disallowed.yaml
```

</details>


</details><details>
<summary>verifydeprecatedapi-1.22</summary>

<details>
<summary>constraint</summary>

```yaml
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: VerifyDeprecatedAPI
metadata:
  name: verify-1.22
spec:
  match:
    kinds:
      - apiGroups: ["admissionregistration.k8s.io"]
        kinds: ["MutatingWebhookConfiguration", "ValidatingWebhookConfiguration"]
      - apiGroups: ["apiextensions.k8s.io"]
        kinds: ["CustomResourceDefinition"]
      - apiGroups: ["apiregistration.k8s.io"]
        kinds: ["APIService"]
      - apiGroups: ["authentication.k8s.io"]
        kinds: ["TokenReview"]
      - apiGroups: ["authorization.k8s.io"]
        kinds: ["SubjectAccessReview"]
      - apiGroups: ["certificates.k8s.io"]
        kinds: ["CertificateSigningRequest"]
      - apiGroups: ["coordination.k8s.io"]
        kinds: ["Lease"]
      - apiGroups: ["extensions", "networking.k8s.io"]
        kinds: ["Ingress"]
      - apiGroups: ["networking.k8s.io"]
        kinds: ["IngressClass"]
      - apiGroups: ["rbac.authorization.k8s.io"]
        kinds: ["ClusterRole", "ClusterRoleBinding", "Role", "RoleBinding"]
      - apiGroups: ["scheduling.k8s.io"]
        kinds: ["PriorityClass"]
      - apiGroups: ["storage.k8s.io"]
        kinds: ["CSIDriver", "CSINode", "StorageClass", "VolumeAttachment"]
  parameters:
    kvs:
      - deprecatedAPI: "admissionregistration.k8s.io/v1beta1"
        kinds: ["MutatingWebhookConfiguration", "ValidatingWebhookConfiguration"]
        targetAPI: "admissionregistration.k8s.io/v1"
      - deprecatedAPI: "apiextensions.k8s.io/v1beta1"
        kinds: ["CustomResourceDefinition"]
        targetAPI: "apiextensions.k8s.io/v1"
      - deprecatedAPI: "apiregistration.k8s.io/v1beta1"
        kinds: ["APIService"]
        targetAPI: "apiregistration.k8s.io/v1"
      - deprecatedAPI: "authentication.k8s.io/v1beta1"
        kinds: ["TokenReview"]
        targetAPI: "authentication.k8s.io/v1"
      - deprecatedAPI: "authorization.k8s.io/v1beta1"
        kinds: ["SubjectAccessReview"]
        targetAPI: "authorization.k8s.io/v1"
      - deprecatedAPI: "certificates.k8s.io/v1beta1"
        kinds: ["CertificateSigningRequest"]
        targetAPI: "certificates.k8s.io/v1"
      - deprecatedAPI: "coordination.k8s.io/v1beta1"
        kinds: ["Lease"]
        targetAPI: "coordination.k8s.io/v1"
      - deprecatedAPI: "extensions/v1beta1"
        kinds: ["Ingress"]
        targetAPI: "networking.k8s.io/v1"
      - deprecatedAPI: "networking.k8s.io/v1beta1"
        kinds: ["Ingress", "IngressClass"]
        targetAPI: "networking.k8s.io/v1"
      - deprecatedAPI: "rbac.authorization.k8s.io/v1beta1"
        kinds: ["ClusterRole", "ClusterRoleBinding", "Role", "RoleBinding"]
        targetAPI: "rbac.authorization.k8s.io/v1"
      - deprecatedAPI: "scheduling.k8s.io/v1beta1"
        kinds: ["PriorityClass"]
        targetAPI: "scheduling.k8s.io/v1"
      - deprecatedAPI: "storage.k8s.io/v1beta1"
        kinds: ["CSIDriver", "CSINode", "StorageClass", "VolumeAttachment"]
        targetAPI: "storage.k8s.io/v1"
    k8sVersion: 1.22

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.22/constraint.yaml
```

</details>

<details>
<summary>example-allowed</summary>

```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: allowed-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx-example
  rules:
  - http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.22/example_allowed.yaml
```

</details>
<details>
<summary>example-disallowed</summary>

```yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: disallowed-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx-example
  rules:
  - http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.22/example_disallowed.yaml
```

</details>


</details><details>
<summary>verifydeprecatedapi-1.25</summary>

<details>
<summary>constraint</summary>

```yaml
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: VerifyDeprecatedAPI
metadata:
  name: verify-1.25
spec:
  match:
    kinds:
      - apiGroups: ["batch"]
        kinds: ["CronJob"]
      - apiGroups: ["discovery.k8s.io"]
        kinds: ["EndpointSlice"]
      - apiGroups: ["events.k8s.io"]
        kinds: ["Event"]
      - apiGroups: ["autoscaling"]
        kinds: ["HorizontalPodAutoscaler"]
      - apiGroups: ["policy"]
        kinds: ["PodDisruptionBudget", "PodSecurityPolicy"]
      - apiGroups: ["node.k8s.io"]
        kinds: ["RuntimeClass"]
  parameters:
    kvs:
      - deprecatedAPI: "batch/v1beta1"
        kinds: ["CronJob"]
        targetAPI: "batch/v1"
      - deprecatedAPI: "discovery.k8s.io/v1beta1"
        kinds: ["EndpointSlice"]
        targetAPI: "discovery.k8s.io/v1"
      - deprecatedAPI: "events.k8s.io/v1beta1"
        kinds: ["Event"]
        targetAPI: "events.k8s.io/v1"
      - deprecatedAPI: "autoscaling/v2beta1"
        kinds: ["HorizontalPodAutoscaler"]
        targetAPI: "autoscaling/v2"
      - deprecatedAPI: "policy/v1beta1"
        kinds: ["PodDisruptionBudget"]
        targetAPI: "policy/v1"
      - deprecatedAPI: "policy/v1beta1"
        kinds: ["PodSecurityPolicy"]
        targetAPI: "None"
      - deprecatedAPI: "node.k8s.io/v1beta1"
        kinds: ["RuntimeClass"]
        targetAPI: "node.k8s.io/v1"
    k8sVersion: 1.25

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.25/constraint.yaml
```

</details>

<details>
<summary>example-allowed</summary>

```yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: allowed-cronjob
  namespace: default
spec:
  schedule: "* * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox:1.28
            imagePullPolicy: IfNotPresent
            command:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.25/example_allowed.yaml
```

</details>
<details>
<summary>example-disallowed</summary>

```yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: disallowed-cronjob
  namespace: default
spec:
  schedule: "* * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox:1.28
            imagePullPolicy: IfNotPresent
            command:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.25/example_disallowed.yaml
```

</details>


</details><details>
<summary>verifydeprecatedapi-1.26</summary>

<details>
<summary>constraint</summary>

```yaml
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: VerifyDeprecatedAPI
metadata:
  name: verify-1.26
spec:
  match:
    kinds:
      - apiGroups: ["flowcontrol.apiserver.k8s.io"]
        kinds: ["FlowSchema", "PriorityLevelConfiguration"]
      - apiGroups: ["autoscaling"]
        kinds: ["HorizontalPodAutoscaler"]
  parameters:
    kvs: 
      - deprecatedAPI: "flowcontrol.apiserver.k8s.io/v1beta1"
        kinds: ["FlowSchema", "PriorityLevelConfiguration"]
        targetAPI: "flowcontrol.apiserver.k8s.io/v1beta3"
      - deprecatedAPI: "autoscaling/v2beta2"
        kinds: ["HorizontalPodAutoscaler"]
        targetAPI: "autoscaling/v2"
    k8sVersion: 1.26

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.26/constraint.yaml
```

</details>

<details>
<summary>example-allowed</summary>

```yaml
apiVersion: flowcontrol.apiserver.k8s.io/v1beta3
kind: FlowSchema
metadata:
  name: allowed-flowcontrol
  namespace: default
spec:
  matchingPrecedence: 1000
  priorityLevelConfiguration:
    name: exempt
  rules:
    - nonResourceRules:
      - nonResourceURLs:
          - "/healthz"
          - "/livez"
          - "/readyz"
        verbs:
          - "*"
      subjects:
        - kind: Group
          group:
            name: "system:unauthenticated"

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.26/example_allowed.yaml
```

</details>
<details>
<summary>example-disallowed</summary>

```yaml
apiVersion: flowcontrol.apiserver.k8s.io/v1beta1
kind: FlowSchema
metadata:
  name: disallowed-flowcontrol
  namespace: default
spec:
  matchingPrecedence: 1000
  priorityLevelConfiguration:
    name: exempt
  rules:
    - nonResourceRules:
      - nonResourceURLs:
          - "/healthz"
          - "/livez"
          - "/readyz"
        verbs:
          - "*"
      subjects:
        - kind: Group
          group:
            name: "system:unauthenticated"

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.26/example_disallowed.yaml
```

</details>


</details><details>
<summary>verifydeprecatedapi-1.27</summary>

<details>
<summary>constraint</summary>

```yaml
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: VerifyDeprecatedAPI
metadata:
  name: verify-1.27
spec:
  match:
    kinds:
      - apiGroups: ["storage.k8s.io"]
        kinds: ["CSIStorageCapacity"]
  parameters:
    kvs: 
      - deprecatedAPI: "storage.k8s.io/v1beta1"
        kinds: ["CSIStorageCapacity"]
        targetAPI: "storage.k8s.io/v1"
    k8sVersion: 1.27

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.27/constraint.yaml
```

</details>

<details>
<summary>example-allowed</summary>

```yaml
apiVersion: storage.k8s.io/v1
kind: CSIStorageCapacity
metadata:
  name: allowed-csistoragecapacity
storageClassName: standard

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.27/example_allowed.yaml
```

</details>
<details>
<summary>example-disallowed</summary>

```yaml
apiVersion: storage.k8s.io/v1beta1
kind: CSIStorageCapacity
metadata:
  name: allowed-csistoragecapacity
  namespace: default
storageClassName: standard

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.27/example_disallowed.yaml
```

</details>


</details><details>
<summary>verifydeprecatedapi-1.29</summary>

<details>
<summary>constraint</summary>

```yaml
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: VerifyDeprecatedAPI
metadata:
  name: verify-1.29
spec:
  match:
    kinds:
      - apiGroups: ["flowcontrol.apiserver.k8s.io"]
        kinds: ["FlowSchema", "PriorityLevelConfiguration"]
  parameters:
    kvs: 
      - deprecatedAPI: "flowcontrol.apiserver.k8s.io/v1beta2"
        kinds: ["FlowSchema", "PriorityLevelConfiguration"]
        targetAPI: "flowcontrol.apiserver.k8s.io/v1beta3"
    k8sVersion: 1.29

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.29/constraint.yaml
```

</details>

<details>
<summary>example-allowed</summary>

```yaml
apiVersion: flowcontrol.apiserver.k8s.io/v1beta3
kind: FlowSchema
metadata:
  name: allowed-flowcontrol
  namespace: default
spec:
  matchingPrecedence: 1000
  priorityLevelConfiguration:
    name: exempt
  rules:
    - nonResourceRules:
      - nonResourceURLs:
          - "/healthz"
          - "/livez"
          - "/readyz"
        verbs:
          - "*"
      subjects:
        - kind: Group
          group:
            name: "system:unauthenticated"

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.29/example_allowed.yaml
```

</details>
<details>
<summary>example-disallowed</summary>

```yaml
apiVersion: flowcontrol.apiserver.k8s.io/v1beta2
kind: FlowSchema
metadata:
  name: disallowed-flowcontrol
  namespace: default
spec:
  matchingPrecedence: 1000
  priorityLevelConfiguration:
    name: exempt
  rules:
    - nonResourceRules:
      - nonResourceURLs:
          - "/healthz"
          - "/livez"
          - "/readyz"
        verbs:
          - "*"
      subjects:
        - kind: Group
          group:
            name: "system:unauthenticated"

```

Usage

```shell
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/library/general/verifydeprecatedapi/samples/verify-1.29/example_disallowed.yaml
```

</details>


</details>