@@ -696,7 +696,7 @@ kind: Deployment
696
696
metadata :
697
697
labels :
698
698
app .kubernetes .io / name : gateway - operator
699
- helm .sh / chart : gateway - operator - 0.4 .9
699
+ helm .sh / chart : gateway - operator - 0.4 .10 - rc . 1
700
700
app .kubernetes .io / instance : " chartsnap"
701
701
app .kubernetes .io / version : " 1.4"
702
702
app .kubernetes .io / component : kgo
@@ -718,7 +718,7 @@ spec:
718
718
labels :
719
719
control - plane : controller - manager
720
720
app .kubernetes .io / name : gateway - operator
721
- helm .sh / chart : gateway - operator - 0.4 .9
721
+ helm .sh / chart : gateway - operator - 0.4 .10 - rc . 1
722
722
app .kubernetes .io / instance : " chartsnap"
723
723
app .kubernetes .io / version : " 1.4"
724
724
app .kubernetes .io / component : kgo
@@ -785,3 +785,97 @@ spec:
785
785
- name : chartsnap - gateway - operator - certs - dir
786
786
emptyDir :
787
787
sizeLimit : 256Mi
788
+ -- -
789
+ # Source : gateway - operator / templates / validation - policy - dataplane .yaml
790
+ apiVersion : admissionregistration .k8s .io / v1
791
+ kind : ValidatingAdmissionPolicy
792
+ metadata :
793
+ name : ports .dataplane .gateway - operator .konghq .com
794
+ spec :
795
+ matchConstraints :
796
+ resourceRules :
797
+ - apiGroups :
798
+ - " gateway-operator.konghq.com"
799
+ apiVersions :
800
+ - " v1beta1"
801
+ operations :
802
+ - " CREATE"
803
+ - " UPDATE"
804
+ resources :
805
+ - " dataplanes"
806
+ variables :
807
+ - name : ingressPorts
808
+ expression : object .spec .network .services .ingress .ports
809
+ - name : podTemplateSpec
810
+ expression : object .spec .deployment .podTemplateSpec
811
+ - name : proxyContainers
812
+ expression : |
813
+ variables .podTemplateSpec .spec .containers .filter (c , c .name == ' proxy' )
814
+ - name : proxyContainer
815
+ expression : |
816
+ variables .proxyContainers .size () > 0 ?
817
+ variables .proxyContainers [0 ] :
818
+ null
819
+ - name : envFilteredPortMaps
820
+ expression : |
821
+ variables .proxyContainer .env .filter (e , e .name == " KONG_PORT_MAPS" )
822
+ - name : envFilteredProxyListen
823
+ expression : |
824
+ variables .proxyContainer .env .filter (e , e .name == " KONG_PROXY_LISTEN" )
825
+ - name : envPortMaps
826
+ expression : |
827
+ variables .envFilteredPortMaps .size () > 0 ? variables .envFilteredPortMaps [0 ].value : null
828
+ - name : envProxyListen
829
+ expression : |
830
+ variables .envFilteredProxyListen .size () > 0 ? variables .envFilteredProxyListen [0 ].value : null
831
+ # NOTE : Rules below do not validate the ports from the spec .network .services .ingress .ports
832
+ # when no KONG_PORT_MAPS or KONG_PROXY_LISTEN env variables are present in the proxy container .
833
+ # This has been the case before the introduction of validating admission policies so we are keeping
834
+ # the same behavior .
835
+
836
+ # Using string functions from : https :// pkg.go.dev/github.com/google/cel-go/ext
837
+ validations :
838
+ - messageExpression : " 'Each port from spec.network.services.ingress.ports has to have an accompanying port in KONG_PORT_MAPS env'"
839
+ expression : |
840
+ ! has (object .spec .network ) ||
841
+ ! has (object .spec .network .services ) ||
842
+ ! has (object .spec .network .services .ingress ) ||
843
+ ! has (object .spec .network .services .ingress .ports ) ||
844
+ ! has (variables .proxyContainer .env ) ||
845
+ variables .envPortMaps == null ||
846
+ (
847
+ variables .ingressPorts .all (p , variables .envPortMaps .
848
+ split (" ," ).
849
+ exists (pm ,
850
+ pm .split (" :" )[1 ].trim () == string (p .targetPort )
851
+ )
852
+ )
853
+ )
854
+ reason : Invalid
855
+ - messageExpression : " 'Each port from spec.network.services.ingress.ports has to have an accompanying port in KONG_PROXY_LISTEN env'"
856
+ expression : |
857
+ ! has (object .spec .network ) ||
858
+ ! has (object .spec .network .services ) ||
859
+ ! has (object .spec .network .services .ingress ) ||
860
+ ! has (object .spec .network .services .ingress .ports ) ||
861
+ ! has (variables .proxyContainer .env ) ||
862
+ variables .envProxyListen == null ||
863
+ (
864
+ variables .ingressPorts .all (p , variables .envProxyListen .
865
+ split (" ," ).
866
+ exists (pm ,
867
+ pm .trim ().split (" " )[0 ].split (" :" )[1 ].trim () == string (p .targetPort )
868
+ )
869
+ )
870
+ )
871
+ reason : Invalid
872
+ -- -
873
+ # Source : gateway - operator / templates / validation - policy - dataplane .yaml
874
+ apiVersion : admissionregistration .k8s .io / v1
875
+ kind : ValidatingAdmissionPolicyBinding
876
+ metadata :
877
+ name : binding - ports .dataplane .gateway - operator .konghq .com
878
+ spec :
879
+ policyName : ports .dataplane .gateway - operator .konghq .com
880
+ validationActions :
881
+ - Deny
0 commit comments