|
| 1 | +# conformance/tests/basic/inferencepool_httproute_port_validation.yaml |
| 2 | + |
| 3 | +# --- Backend Deployment (reusing standard echoserver) --- |
| 4 | + |
| 5 | +apiVersion: apps/v1 |
| 6 | +kind: Deployment |
| 7 | +metadata: |
| 8 | + name: infra-backend-deployment-port-test |
| 9 | + namespace: gateway-conformance-app-backend |
| 10 | + labels: |
| 11 | + app: infra-backend-port-test |
| 12 | +spec: |
| 13 | + replicas: 1 |
| 14 | + selector: |
| 15 | + matchLabels: |
| 16 | + app: infra-backend-port-test |
| 17 | + template: |
| 18 | + metadata: |
| 19 | + labels: |
| 20 | + app: infra-backend-port-test |
| 21 | + spec: |
| 22 | + containers: |
| 23 | + - name: echoserver |
| 24 | + image: gcr.io/k8s-staging-gateway-api/echo-basic:v20240412-v1.0.0-394-g40c666fd |
| 25 | + ports: |
| 26 | + - containerPort: 3000 |
| 27 | + readinessProbe: |
| 28 | + httpGet: |
| 29 | + path: / |
| 30 | + port: 3000 |
| 31 | + initialDelaySeconds: 3 |
| 32 | + periodSeconds: 5 |
| 33 | + failureThreshold: 2 |
| 34 | + env: |
| 35 | + - name: POD_NAME |
| 36 | + valueFrom: |
| 37 | + fieldRef: |
| 38 | + fieldPath: metadata.name |
| 39 | + - name: NAMESPACE |
| 40 | + valueFrom: |
| 41 | + fieldRef: |
| 42 | + fieldPath: metadata.namespace |
| 43 | +--- |
| 44 | +# --- Backend Service --- |
| 45 | +# Service for the infra-backend-deployment-port-test. |
| 46 | +apiVersion: v1 |
| 47 | +kind: Service |
| 48 | +metadata: |
| 49 | + name: infra-backend-svc-port-test |
| 50 | + namespace: gateway-conformance-app-backend |
| 51 | +spec: |
| 52 | + selector: |
| 53 | + app: infra-backend-port-test |
| 54 | + ports: |
| 55 | + - name: http |
| 56 | + port: 3000 |
| 57 | + targetPort: 3000 |
| 58 | +--- |
| 59 | +# --- InferencePool Definition --- |
| 60 | +apiVersion: inference.networking.x-k8s.io/v1alpha2 |
| 61 | +kind: InferencePool |
| 62 | +metadata: |
| 63 | + name: target-pool-port-validation |
| 64 | + namespace: gateway-conformance-app-backend |
| 65 | +spec: |
| 66 | + selector: |
| 67 | + app: "infra-backend-port-test" |
| 68 | + targetPortNumber: 3000 |
| 69 | + extensionRef: |
| 70 | + name: target-pool-port-validation-epp |
| 71 | +--- |
| 72 | +apiVersion: v1 |
| 73 | +kind: Service |
| 74 | +metadata: |
| 75 | + name: target-pool-port-validation-epp |
| 76 | + namespace: gateway-conformance-app-backend |
| 77 | +spec: |
| 78 | + selector: |
| 79 | + app: target-pool-port-validation-epp |
| 80 | + ports: |
| 81 | + - protocol: TCP |
| 82 | + port: 9002 |
| 83 | + targetPort: 9002 |
| 84 | + appProtocol: http2 |
| 85 | + type: ClusterIP |
| 86 | +--- |
| 87 | +apiVersion: apps/v1 |
| 88 | +kind: Deployment |
| 89 | +metadata: |
| 90 | + name: target-pool-port-validation-epp |
| 91 | + namespace: gateway-conformance-app-backend |
| 92 | + labels: |
| 93 | + app: target-pool-port-validation-epp |
| 94 | +spec: |
| 95 | + replicas: 1 |
| 96 | + selector: |
| 97 | + matchLabels: |
| 98 | + app: target-pool-port-validation-epp |
| 99 | + template: |
| 100 | + metadata: |
| 101 | + labels: |
| 102 | + app: target-pool-port-validation-epp |
| 103 | + spec: |
| 104 | + terminationGracePeriodSeconds: 130 |
| 105 | + containers: |
| 106 | + - name: epp |
| 107 | + image: us-central1-docker.pkg.dev/k8s-staging-images/gateway-api-inference-extension/epp:main |
| 108 | + imagePullPolicy: Always |
| 109 | + args: |
| 110 | + - -poolName |
| 111 | + - "target-pool-port-validation" |
| 112 | + - "-poolNamespace" |
| 113 | + - "gateway-conformance-app-backend" |
| 114 | + - -v |
| 115 | + - "4" |
| 116 | + - --zap-encoder |
| 117 | + - "json" |
| 118 | + - -grpcPort |
| 119 | + - "9002" |
| 120 | + - -grpcHealthPort |
| 121 | + - "9003" |
| 122 | + ports: |
| 123 | + - containerPort: 9002 |
| 124 | + - containerPort: 9003 |
| 125 | + - name: metrics |
| 126 | + containerPort: 9090 |
| 127 | + livenessProbe: |
| 128 | + grpc: |
| 129 | + port: 9003 |
| 130 | + service: inference-extension |
| 131 | + initialDelaySeconds: 5 |
| 132 | + periodSeconds: 10 |
| 133 | + readinessProbe: |
| 134 | + grpc: |
| 135 | + port: 9003 |
| 136 | + service: inference-extension |
| 137 | + initialDelaySeconds: 5 |
| 138 | + periodSeconds: 10 |
| 139 | +--- |
| 140 | +# --- HTTPRoute Scenario 1: Port Unspecified --- |
| 141 | +apiVersion: gateway.networking.k8s.io/v1 |
| 142 | +kind: HTTPRoute |
| 143 | +metadata: |
| 144 | + name: httproute-pool-port-unspecified |
| 145 | + namespace: gateway-conformance-app-backend |
| 146 | +spec: |
| 147 | + parentRefs: |
| 148 | + - group: gateway.networking.k8s.io |
| 149 | + kind: Gateway |
| 150 | + name: conformance-gateway |
| 151 | + namespace: gateway-conformance-infra |
| 152 | + sectionName: http |
| 153 | + hostnames: |
| 154 | + - "port-unspecified.example.com" |
| 155 | + rules: |
| 156 | + - backendRefs: |
| 157 | + - group: inference.networking.x-k8s.io |
| 158 | + kind: InferencePool |
| 159 | + name: target-pool-port-validation |
| 160 | + # Port is intentionally unspecified here |
| 161 | + matches: |
| 162 | + - path: |
| 163 | + type: PathPrefix |
| 164 | + value: /test-port-unspecified |
| 165 | +--- |
| 166 | +# --- HTTPRoute Scenario 2: Port Matching --- |
| 167 | +apiVersion: gateway.networking.k8s.io/v1 |
| 168 | +kind: HTTPRoute |
| 169 | +metadata: |
| 170 | + name: httproute-pool-port-matching |
| 171 | + namespace: gateway-conformance-app-backend |
| 172 | +spec: |
| 173 | + parentRefs: |
| 174 | + - group: gateway.networking.k8s.io |
| 175 | + kind: Gateway |
| 176 | + name: conformance-gateway |
| 177 | + namespace: gateway-conformance-infra |
| 178 | + sectionName: http |
| 179 | + hostnames: |
| 180 | + - "port-matching.example.com" |
| 181 | + rules: |
| 182 | + - backendRefs: |
| 183 | + - group: inference.networking.x-k8s.io |
| 184 | + kind: InferencePool |
| 185 | + name: target-pool-port-validation |
| 186 | + port: 3000 # Port matches InferencePool's targetPortNumber |
| 187 | + matches: |
| 188 | + - path: |
| 189 | + type: PathPrefix |
| 190 | + value: /test-port-matching |
| 191 | +--- |
| 192 | +# --- HTTPRoute Scenario 3: Port Non-Matching --- |
| 193 | +apiVersion: gateway.networking.k8s.io/v1 |
| 194 | +kind: HTTPRoute |
| 195 | +metadata: |
| 196 | + name: httproute-pool-port-non-matching |
| 197 | + namespace: gateway-conformance-app-backend |
| 198 | +spec: |
| 199 | + parentRefs: |
| 200 | + - group: gateway.networking.k8s.io |
| 201 | + kind: Gateway |
| 202 | + name: conformance-gateway |
| 203 | + namespace: gateway-conformance-infra |
| 204 | + sectionName: http |
| 205 | + hostnames: |
| 206 | + - "port-non-matching.example.com" |
| 207 | + rules: |
| 208 | + - backendRefs: |
| 209 | + - group: inference.networking.x-k8s.io |
| 210 | + kind: InferencePool |
| 211 | + name: target-pool-port-validation |
| 212 | + port: 8888 # Port does NOT match InferencePool's targetPortNumber |
| 213 | + matches: |
| 214 | + - path: |
| 215 | + type: PathPrefix |
| 216 | + value: /test-port-non-matching |
| 217 | +--- |
| 218 | +# --- Conformance EPP Requried Role and RoleBindings --- |
| 219 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 220 | +kind: Role |
| 221 | +metadata: |
| 222 | + name: inference-model-reader |
| 223 | + namespace: gateway-conformance-app-backend |
| 224 | +rules: |
| 225 | +- apiGroups: ["inference.networking.x-k8s.io"] |
| 226 | + resources: ["inferencemodels", "inferencepools"] |
| 227 | + verbs: ["get", "list", "watch"] |
| 228 | +- apiGroups: [""] |
| 229 | + resources: ["pods"] |
| 230 | + verbs: ["get", "list", "watch"] |
| 231 | +--- |
| 232 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 233 | +kind: RoleBinding |
| 234 | +metadata: |
| 235 | + name: epp-to-inference-model-reader |
| 236 | + namespace: gateway-conformance-app-backend |
| 237 | +subjects: |
| 238 | +- kind: ServiceAccount |
| 239 | + name: default |
| 240 | + namespace: gateway-conformance-app-backend |
| 241 | +roleRef: |
| 242 | + kind: Role |
| 243 | + name: inference-model-reader |
| 244 | + apiGroup: rbac.authorization.k8s.io |
0 commit comments