istio.io/istio@v0.0.0-20240520182934-d79c90f27776/samples/ratelimit/rate-limit-service.yaml (about) 1 # Copyright Istio Authors 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 ################################################################################################## 16 # Redis service and deployment 17 # Ratelimit service and deployment 18 19 # Note: a configmap is needed to make the rate limit deployment work properly, for example: 20 # 21 # apiVersion: v1 22 # kind: ConfigMap 23 # metadata: 24 # name: ratelimit-config 25 # data: 26 # config.yaml: | 27 # domain: echo-ratelimit 28 # descriptors: 29 # - key: PATH 30 # value: "/" 31 # rate_limit: 32 # unit: minute 33 # requests_per_unit: 1 34 # - key: PATH 35 # rate_limit: 36 # unit: minute 37 # requests_per_unit: 100 38 ################################################################################################## 39 apiVersion: v1 40 kind: Service 41 metadata: 42 name: redis 43 labels: 44 app: redis 45 spec: 46 ports: 47 - name: redis 48 port: 6379 49 selector: 50 app: redis 51 --- 52 apiVersion: apps/v1 53 kind: Deployment 54 metadata: 55 name: redis 56 spec: 57 replicas: 1 58 selector: 59 matchLabels: 60 app: redis 61 template: 62 metadata: 63 labels: 64 app: redis 65 spec: 66 containers: 67 - image: redis:alpine 68 imagePullPolicy: Always 69 name: redis 70 ports: 71 - name: redis 72 containerPort: 6379 73 restartPolicy: Always 74 serviceAccountName: "" 75 --- 76 apiVersion: v1 77 kind: Service 78 metadata: 79 name: ratelimit 80 labels: 81 app: ratelimit 82 spec: 83 ports: 84 - name: http-port 85 port: 8080 86 targetPort: 8080 87 protocol: TCP 88 - name: grpc-port 89 port: 8081 90 targetPort: 8081 91 protocol: TCP 92 - name: http-debug 93 port: 6070 94 targetPort: 6070 95 protocol: TCP 96 selector: 97 app: ratelimit 98 --- 99 apiVersion: apps/v1 100 kind: Deployment 101 metadata: 102 name: ratelimit 103 spec: 104 replicas: 1 105 selector: 106 matchLabels: 107 app: ratelimit 108 strategy: 109 type: Recreate 110 template: 111 metadata: 112 labels: 113 app: ratelimit 114 spec: 115 containers: 116 - image: envoyproxy/ratelimit:9d8d70a8 # 2022/08/16 117 imagePullPolicy: Always 118 name: ratelimit 119 command: ["/bin/ratelimit"] 120 env: 121 - name: LOG_LEVEL 122 value: debug 123 - name: REDIS_SOCKET_TYPE 124 value: tcp 125 - name: REDIS_URL 126 value: redis:6379 127 - name: USE_STATSD 128 value: "false" 129 - name: RUNTIME_ROOT 130 value: /data 131 - name: RUNTIME_SUBDIRECTORY 132 value: ratelimit 133 - name: RUNTIME_WATCH_ROOT 134 value: "false" 135 - name: RUNTIME_IGNOREDOTFILES 136 value: "true" 137 - name: HOST 138 value: "::" 139 - name: GRPC_HOST 140 value: "::" 141 ports: 142 - containerPort: 8080 143 - containerPort: 8081 144 - containerPort: 6070 145 volumeMounts: 146 - name: config-volume 147 mountPath: /data/ratelimit/config 148 volumes: 149 - name: config-volume 150 configMap: 151 name: ratelimit-config