forked from istio/istio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automating Mixer samples (istio#13196)
* move samples Signed-off-by: Kuat Yessenov <kuat@google.com> * add metric samples Signed-off-by: Kuat Yessenov <kuat@google.com> * add samples Signed-off-by: Kuat Yessenov <kuat@google.com> * add samples Signed-off-by: Kuat Yessenov <kuat@google.com> * typo Signed-off-by: Kuat Yessenov <kuat@google.com> * typo Signed-off-by: Kuat Yessenov <kuat@google.com> * add samples Signed-off-by: Kuat Yessenov <kuat@google.com> * add samples Signed-off-by: Kuat Yessenov <kuat@google.com> * add samples Signed-off-by: Kuat Yessenov <kuat@google.com> * add samples Signed-off-by: Kuat Yessenov <kuat@google.com>
- Loading branch information
Showing
20 changed files
with
786 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: listchecker | ||
metadata: | ||
name: whitelistip | ||
spec: | ||
# providerUrl: ordinarily black and white lists are maintained | ||
# externally and fetched asynchronously using the providerUrl. | ||
overrides: ["10.57.0.0/16"] # overrides provide a static list | ||
blacklist: false | ||
entryType: IP_ADDRESSES | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: listentry | ||
metadata: | ||
name: sourceip | ||
spec: | ||
value: source.ip | ip("0.0.0.0") | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: rule | ||
metadata: | ||
name: checkip | ||
spec: | ||
match: source.labels["istio"] == "ingressgateway" | ||
actions: | ||
- handler: whitelistip.listchecker | ||
instances: | ||
- sourceip.listentry | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: handler | ||
metadata: | ||
name: whitelistip | ||
spec: | ||
compiledAdapter: listchecker | ||
params: | ||
# providerUrl: ordinarily black and white lists are maintained | ||
# externally and fetched asynchronously using the providerUrl. | ||
overrides: ["10.57.0.0/16"] # overrides provide a static list | ||
blacklist: false | ||
entryType: IP_ADDRESSES | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: instance | ||
metadata: | ||
name: sourceip | ||
spec: | ||
compiledTemplate: listentry | ||
params: | ||
value: source.ip | ip("0.0.0.0") | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: rule | ||
metadata: | ||
name: checkip | ||
spec: | ||
match: source.labels["istio"] == "ingressgateway" | ||
actions: | ||
- handler: whitelistip | ||
instances: [ sourceip ] | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: "config.istio.io/v1alpha2" | ||
kind: denier | ||
metadata: | ||
name: denyreviewsv3handler | ||
spec: | ||
status: | ||
code: 7 | ||
message: Not allowed | ||
--- | ||
apiVersion: "config.istio.io/v1alpha2" | ||
kind: checknothing | ||
metadata: | ||
name: denyreviewsv3request | ||
spec: | ||
--- | ||
apiVersion: "config.istio.io/v1alpha2" | ||
kind: rule | ||
metadata: | ||
name: denyreviewsv3 | ||
spec: | ||
match: destination.labels["app"] == "ratings" && source.labels["app"]=="reviews" && source.labels["version"] == "v3" | ||
actions: | ||
- handler: denyreviewsv3handler.denier | ||
instances: [ denyreviewsv3request.checknothing ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
samples/bookinfo/policy/mixer-rule-deny-whitelist-crd.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: listchecker | ||
metadata: | ||
name: whitelist | ||
spec: | ||
# providerUrl: ordinarily black and white lists are maintained | ||
# externally and fetched asynchronously using the providerUrl. | ||
overrides: ["v1", "v2"] # overrides provide a static list | ||
blacklist: false | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: listentry | ||
metadata: | ||
name: appversion | ||
spec: | ||
value: source.labels["version"] | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: rule | ||
metadata: | ||
name: checkversion | ||
spec: | ||
match: destination.labels["app"] == "ratings" | ||
actions: | ||
- handler: whitelist.listchecker | ||
instances: | ||
- appversion.listentry | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: handler | ||
metadata: | ||
name: whitelist | ||
spec: | ||
compiledAdapter: listchecker | ||
params: | ||
# providerUrl: ordinarily black and white lists are maintained | ||
# externally and fetched asynchronously using the providerUrl. | ||
overrides: ["v1", "v2"] # overrides provide a static list | ||
blacklist: false | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: instance | ||
metadata: | ||
name: appversion | ||
spec: | ||
compiledTemplate: listentry | ||
params: | ||
value: source.labels["version"] | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: rule | ||
metadata: | ||
name: checkversion | ||
spec: | ||
match: destination.labels["app"] == "ratings" | ||
actions: | ||
- handler: whitelist | ||
instances: [ appversion ] | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
samples/bookinfo/policy/mixer-rule-productpage-redis-quota-rolling-window.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: handler | ||
metadata: | ||
name: redishandler | ||
namespace: istio-system | ||
spec: | ||
compiledAdapter: redisquota | ||
params: | ||
redisServerUrl: redis-release-master:6379 | ||
connectionPoolSize: 10 | ||
quotas: | ||
- name: requestcountquota.instance.istio-system | ||
maxAmount: 500 | ||
validDuration: 1s | ||
bucketDuration: 500ms | ||
rateLimitAlgorithm: ROLLING_WINDOW | ||
# The first matching override is applied. | ||
# A requestcount instance is checked against override dimensions. | ||
overrides: | ||
# The following override applies to 'reviews' regardless | ||
# of the source. | ||
- dimensions: | ||
destination: reviews | ||
maxAmount: 1 | ||
# The following override applies to 'productpage' when | ||
# the source is a specific ip address. | ||
- dimensions: | ||
destination: productpage | ||
source: "10.28.11.20" | ||
maxAmount: 500 | ||
# The following override applies to 'productpage' regardless | ||
# of the source. | ||
- dimensions: | ||
destination: productpage | ||
maxAmount: 2 | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: instance | ||
metadata: | ||
name: requestcountquota | ||
namespace: istio-system | ||
spec: | ||
compiledTemplate: quota | ||
params: | ||
dimensions: | ||
source: request.headers["x-forwarded-for"] | "unknown" | ||
destination: destination.labels["app"] | destination.workload.name | "unknown" | ||
destinationVersion: destination.labels["version"] | "unknown" | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: QuotaSpec | ||
metadata: | ||
name: request-count | ||
namespace: istio-system | ||
spec: | ||
rules: | ||
- quotas: | ||
- charge: 1 | ||
quota: requestcountquota | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: QuotaSpecBinding | ||
metadata: | ||
name: request-count | ||
namespace: istio-system | ||
spec: | ||
quotaSpecs: | ||
- name: request-count | ||
namespace: istio-system | ||
services: | ||
- name: productpage | ||
namespace: default | ||
# - service: '*' # Uncomment this to bind *all* services to request-count | ||
--- | ||
apiVersion: config.istio.io/v1alpha2 | ||
kind: rule | ||
metadata: | ||
name: quota | ||
namespace: istio-system | ||
spec: | ||
# quota only applies if you are not logged in. | ||
# match: match(request.headers["cookie"], "session=*") == false | ||
actions: | ||
- handler: redishandler | ||
instances: | ||
- requestcountquota | ||
--- |
Oops, something went wrong.