mirror of https://github.com/istio/istio.io.git
Workaround Hugo formatting bug with indented code blocks that have lines that start with - (#1372)
This commit is contained in:
parent
7cdbced51b
commit
b7d8a08998
|
@ -133,14 +133,14 @@ As a reminder, here is the end-to-end architecture of the application from the [
|
|||
1. I modify the deployment spec of a version of the _ratings_ microservice that uses a MySQL database, to use my database instance. The spec is in `samples/bookinfo/kube/bookinfo-ratings-v2-mysql.yaml` of an Istio release archive. I edit the following lines:
|
||||
|
||||
```yaml
|
||||
- name: MYSQL_DB_HOST
|
||||
value: mysqldb
|
||||
- name: MYSQL_DB_PORT
|
||||
value: "3306"
|
||||
- name: MYSQL_DB_USER
|
||||
value: root
|
||||
- name: MYSQL_DB_PASSWORD
|
||||
value: password
|
||||
- name: MYSQL_DB_HOST
|
||||
value: mysqldb
|
||||
- name: MYSQL_DB_PORT
|
||||
value: "3306"
|
||||
- name: MYSQL_DB_USER
|
||||
value: root
|
||||
- name: MYSQL_DB_PASSWORD
|
||||
value: password
|
||||
```
|
||||
|
||||
I replace the values in the snippet above, specifying the database host, port, user, and password. Note that the correct way to work with passwords in container's environment variables in Kubernetes is [to use secrets](https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables). For this example task only, I write the password directly in the deployment spec. **Do not do it** in a real environment! I also assume everyone realizes that `"password"` should not be used as a password...
|
||||
|
|
|
@ -33,22 +33,22 @@ Otherwise, ESP won't be able to access Google cloud service control.
|
|||
1. If you want to access the service through Ingress, create the following Ingress definition:
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: simple-ingress
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: istio
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /echo
|
||||
backend:
|
||||
serviceName: esp-echo
|
||||
servicePort: 80
|
||||
EOF
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: simple-ingress
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: istio
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /echo
|
||||
backend:
|
||||
serviceName: esp-echo
|
||||
servicePort: 80
|
||||
EOF
|
||||
```
|
||||
|
||||
1. Get the Ingress IP through [instructions](/docs/tasks/traffic-management/ingress/#verifying-the-gateway-for-http).
|
||||
|
@ -66,10 +66,10 @@ The recommended way to securely access a mesh Endpoints service is through an in
|
|||
Adding `"--http_port=8081"` in the ESP deployment arguments and expose the HTTP port:
|
||||
|
||||
```yaml
|
||||
- port: 80
|
||||
targetPort: 8081
|
||||
protocol: TCP
|
||||
name: http
|
||||
- port: 80
|
||||
targetPort: 8081
|
||||
protocol: TCP
|
||||
name: http
|
||||
```
|
||||
|
||||
1. Turn on mTLS in Istio by using the following command:
|
||||
|
@ -102,10 +102,10 @@ This solution uses Istio proxy for TCP bypassing. The traffic is secured through
|
|||
1. Modify the name of the HTTP port to be `tcp`
|
||||
|
||||
```yaml
|
||||
- port: 80
|
||||
targetPort: 8081
|
||||
protocol: TCP
|
||||
name: tcp
|
||||
- port: 80
|
||||
targetPort: 8081
|
||||
protocol: TCP
|
||||
name: tcp
|
||||
```
|
||||
|
||||
1. Update the mesh service deployment. See further readings on port naming rules
|
||||
|
|
|
@ -46,28 +46,28 @@ Using Istio we can ensure that `1qps` is not breached.
|
|||
Save the following YAML snippet as `ratelimit-handler.yaml`.
|
||||
|
||||
```yaml
|
||||
apiVersion: config.istio.io/v1alpha2
|
||||
kind: memquota
|
||||
metadata:
|
||||
name: handler
|
||||
namespace: istio-system
|
||||
spec:
|
||||
quotas:
|
||||
- name: requestcount.quota.istio-system
|
||||
# default rate limit is 5000qps
|
||||
maxAmount: 5000
|
||||
validDuration: 1s
|
||||
# The first matching override is applied.
|
||||
# A requestcount instance is checked against override dimensions.
|
||||
overrides:
|
||||
# The following override applies to traffic from 'rewiews' version v2,
|
||||
# destined for the ratings service. The destinationVersion dimension is ignored.
|
||||
- dimensions:
|
||||
destination: ratings
|
||||
source: reviews
|
||||
sourceVersion: v2
|
||||
maxAmount: 1
|
||||
validDuration: 1s
|
||||
apiVersion: config.istio.io/v1alpha2
|
||||
kind: memquota
|
||||
metadata:
|
||||
name: handler
|
||||
namespace: istio-system
|
||||
spec:
|
||||
quotas:
|
||||
- name: requestcount.quota.istio-system
|
||||
# default rate limit is 5000qps
|
||||
maxAmount: 5000
|
||||
validDuration: 1s
|
||||
# The first matching override is applied.
|
||||
# A requestcount instance is checked against override dimensions.
|
||||
overrides:
|
||||
# The following override applies to traffic from 'rewiews' version v2,
|
||||
# destined for the ratings service. The destinationVersion dimension is ignored.
|
||||
- dimensions:
|
||||
destination: ratings
|
||||
source: reviews
|
||||
sourceVersion: v2
|
||||
maxAmount: 1
|
||||
validDuration: 1s
|
||||
```
|
||||
|
||||
and then run the following command:
|
||||
|
@ -86,28 +86,28 @@ Using Istio we can ensure that `1qps` is not breached.
|
|||
and create a rule that uses it with the memquota handler.
|
||||
|
||||
```yaml
|
||||
apiVersion: config.istio.io/v1alpha2
|
||||
kind: quota
|
||||
metadata:
|
||||
name: requestcount
|
||||
namespace: istio-system
|
||||
spec:
|
||||
dimensions:
|
||||
source: source.labels["app"] | source.service | "unknown"
|
||||
sourceVersion: source.labels["version"] | "unknown"
|
||||
destination: destination.labels["app"] | destination.service | "unknown"
|
||||
destinationVersion: destination.labels["version"] | "unknown"
|
||||
---
|
||||
apiVersion: config.istio.io/v1alpha2
|
||||
kind: rule
|
||||
metadata:
|
||||
name: quota
|
||||
namespace: istio-system
|
||||
spec:
|
||||
actions:
|
||||
- handler: handler.memquota
|
||||
instances:
|
||||
- requestcount.quota
|
||||
apiVersion: config.istio.io/v1alpha2
|
||||
kind: quota
|
||||
metadata:
|
||||
name: requestcount
|
||||
namespace: istio-system
|
||||
spec:
|
||||
dimensions:
|
||||
source: source.labels["app"] | source.service | "unknown"
|
||||
sourceVersion: source.labels["version"] | "unknown"
|
||||
destination: destination.labels["app"] | destination.service | "unknown"
|
||||
destinationVersion: destination.labels["version"] | "unknown"
|
||||
---
|
||||
apiVersion: config.istio.io/v1alpha2
|
||||
kind: rule
|
||||
metadata:
|
||||
name: quota
|
||||
namespace: istio-system
|
||||
spec:
|
||||
actions:
|
||||
- handler: handler.memquota
|
||||
instances:
|
||||
- requestcount.quota
|
||||
```
|
||||
|
||||
Save the configuration as `ratelimit-rule.yaml` and run the following command:
|
||||
|
@ -141,15 +141,14 @@ For example, consider the following configuration:
|
|||
apiVersion: config.istio.io/v1alpha2
|
||||
kind: rule
|
||||
metadata:
|
||||
name: quota
|
||||
namespace: istio-system
|
||||
name: quota
|
||||
namespace: istio-system
|
||||
spec:
|
||||
match: source.namespace != destination.namespace
|
||||
actions:
|
||||
- handler: handler.memquota
|
||||
instances:
|
||||
- requestcount.quota
|
||||
|
||||
match: source.namespace != destination.namespace
|
||||
actions:
|
||||
- handler: handler.memquota
|
||||
instances:
|
||||
- requestcount.quota
|
||||
```
|
||||
|
||||
This configuration applies the quota rule to requests whose source and destination namespaces are different.
|
||||
|
|
|
@ -134,16 +134,16 @@ Save the following YAML snippet as `appversion-instance.yaml`:
|
|||
Save the following YAML snippet as `checkversion-rule.yaml`:
|
||||
|
||||
```yaml
|
||||
apiVersion: config.istio.io/v1alpha2
|
||||
kind: rule
|
||||
metadata:
|
||||
name: checkversion
|
||||
spec:
|
||||
match: destination.labels["app"] == "ratings"
|
||||
actions:
|
||||
- handler: whitelist.listchecker
|
||||
instances:
|
||||
- appversion.listentry
|
||||
apiVersion: config.istio.io/v1alpha2
|
||||
kind: rule
|
||||
metadata:
|
||||
name: checkversion
|
||||
spec:
|
||||
match: destination.labels["app"] == "ratings"
|
||||
actions:
|
||||
- handler: whitelist.listchecker
|
||||
instances:
|
||||
- appversion.listentry
|
||||
```
|
||||
|
||||
and then run the following command:
|
||||
|
|
|
@ -86,42 +86,43 @@ $ istioctl create -f samples/bookinfo/kube/istio-rbac-namespace.yaml
|
|||
```
|
||||
|
||||
The policy does the following:
|
||||
|
||||
* Creates a `ServiceRole` "service-viewer" which allows read access to any service in "default" namespace that has "app" label
|
||||
set to one of the values in ["productpage", "details", "reviews", "ratings"]. Note that there is a "constraint" specifying that
|
||||
the services must have one of the listed "app" labels.
|
||||
|
||||
```yaml
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRole
|
||||
metadata:
|
||||
name: service-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- services: ["*"]
|
||||
methods: ["GET"]
|
||||
constraints:
|
||||
- key: "app"
|
||||
values: ["productpage", "details", "reviews", "ratings"]
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRole
|
||||
metadata:
|
||||
name: service-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- services: ["*"]
|
||||
methods: ["GET"]
|
||||
constraints:
|
||||
- key: "app"
|
||||
values: ["productpage", "details", "reviews", "ratings"]
|
||||
```
|
||||
|
||||
* Creates a `ServiceRoleBinding` that assign the "service-viewer" role to all services in "istio-system" and "default" namespaces.
|
||||
|
||||
```yaml
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRoleBinding
|
||||
metadata:
|
||||
name: bind-service-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
subjects:
|
||||
- properties:
|
||||
namespace: "istio-system"
|
||||
- properties:
|
||||
namespace: "default"
|
||||
roleRef:
|
||||
kind: ServiceRole
|
||||
name: "service-viewer"
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRoleBinding
|
||||
metadata:
|
||||
name: bind-service-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
subjects:
|
||||
- properties:
|
||||
namespace: "istio-system"
|
||||
- properties:
|
||||
namespace: "default"
|
||||
roleRef:
|
||||
kind: ServiceRole
|
||||
name: "service-viewer"
|
||||
```
|
||||
|
||||
You can expect to see output similar to the following:
|
||||
|
@ -168,31 +169,31 @@ The policy does the following:
|
|||
* Creates a `ServiceRole` "productpage-viewer" which allows read access to "productpage" service.
|
||||
|
||||
```yaml
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRole
|
||||
metadata:
|
||||
name: productpage-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- services: ["productpage.default.svc.cluster.local"]
|
||||
methods: ["GET"]
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRole
|
||||
metadata:
|
||||
name: productpage-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- services: ["productpage.default.svc.cluster.local"]
|
||||
methods: ["GET"]
|
||||
```
|
||||
|
||||
* Creates a `ServiceRoleBinding` "bind-productpager-viewer" which assigns "productpage-viewer" role to all users/services.
|
||||
|
||||
```yaml
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRoleBinding
|
||||
metadata:
|
||||
name: bind-productpager-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
subjects:
|
||||
- user: "*"
|
||||
roleRef:
|
||||
kind: ServiceRole
|
||||
name: "productpage-viewer"
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRoleBinding
|
||||
metadata:
|
||||
name: bind-productpager-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
subjects:
|
||||
- user: "*"
|
||||
roleRef:
|
||||
kind: ServiceRole
|
||||
name: "productpage-viewer"
|
||||
```
|
||||
|
||||
Point your browser at the Bookinfo `productpage` (http://$GATEWAY_URL/productpage). Now you should see "Bookinfo Sample"
|
||||
|
@ -219,32 +220,32 @@ The policy does the following:
|
|||
* Creates a `ServiceRole` "details-reviews-viewer" which allows read access to "details" and "reviews" services.
|
||||
|
||||
```yaml
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRole
|
||||
metadata:
|
||||
name: details-reviews-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- services: ["details.default.svc.cluster.local", "reviews.default.svc.cluster.local"]
|
||||
methods: ["GET"]
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRole
|
||||
metadata:
|
||||
name: details-reviews-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- services: ["details.default.svc.cluster.local", "reviews.default.svc.cluster.local"]
|
||||
methods: ["GET"]
|
||||
```
|
||||
|
||||
* Creates a `ServiceRoleBinding` "bind-details-reviews" which assigns "details-reviews-viewer" role to service
|
||||
account "cluster.local/ns/default/sa/bookinfo-productpage" (representing the "productpage" service).
|
||||
|
||||
```yaml
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRoleBinding
|
||||
metadata:
|
||||
name: bind-details-reviews
|
||||
namespace: default
|
||||
spec:
|
||||
subjects:
|
||||
- user: "cluster.local/ns/default/sa/bookinfo-productpage"
|
||||
roleRef:
|
||||
kind: ServiceRole
|
||||
name: "details-reviews-viewer"
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRoleBinding
|
||||
metadata:
|
||||
name: bind-details-reviews
|
||||
namespace: default
|
||||
spec:
|
||||
subjects:
|
||||
- user: "cluster.local/ns/default/sa/bookinfo-productpage"
|
||||
roleRef:
|
||||
kind: ServiceRole
|
||||
name: "details-reviews-viewer"
|
||||
```
|
||||
|
||||
Point your browser at the Bookinfo `productpage` (http://$GATEWAY_URL/productpage). Now you should see "Bookinfo Sample"
|
||||
|
@ -272,32 +273,32 @@ The policy does the following:
|
|||
* Creates a `ServiceRole` "ratings-viewer" which allows read access to "ratings" service.
|
||||
|
||||
```yaml
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRole
|
||||
metadata:
|
||||
name: ratings-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- services: ["ratings.default.svc.cluster.local"]
|
||||
methods: ["GET"]
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRole
|
||||
metadata:
|
||||
name: ratings-viewer
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- services: ["ratings.default.svc.cluster.local"]
|
||||
methods: ["GET"]
|
||||
```
|
||||
|
||||
* Creates a `ServiceRoleBinding` "bind-ratings" which assigns "ratings-viewer" role to service
|
||||
account "cluster.local/ns/default/sa/bookinfo-reviews", which represents the "reviews" services.
|
||||
|
||||
```yaml
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRoleBinding
|
||||
metadata:
|
||||
name: bind-ratings
|
||||
namespace: default
|
||||
spec:
|
||||
subjects:
|
||||
- user: "cluster.local/ns/default/sa/bookinfo-reviews"
|
||||
roleRef:
|
||||
kind: ServiceRole
|
||||
name: "ratings-viewer"
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: ServiceRoleBinding
|
||||
metadata:
|
||||
name: bind-ratings
|
||||
namespace: default
|
||||
spec:
|
||||
subjects:
|
||||
- user: "cluster.local/ns/default/sa/bookinfo-reviews"
|
||||
roleRef:
|
||||
kind: ServiceRole
|
||||
name: "ratings-viewer"
|
||||
```
|
||||
|
||||
Point your browser at the Bookinfo `productpage` (http://$GATEWAY_URL/productpage). Now you should see
|
||||
|
|
|
@ -28,90 +28,90 @@ as the example application throughout this task.
|
|||
Save the following as `new_telemetry.yaml`:
|
||||
|
||||
```yaml
|
||||
# Configuration for metric instances
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: metric
|
||||
metadata:
|
||||
name: doublerequestcount
|
||||
namespace: istio-system
|
||||
spec:
|
||||
value: "2" # count each request twice
|
||||
dimensions:
|
||||
source: source.service | "unknown"
|
||||
destination: destination.service | "unknown"
|
||||
message: '"twice the fun!"'
|
||||
monitored_resource_type: '"UNSPECIFIED"'
|
||||
---
|
||||
# Configuration for a Prometheus handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: prometheus
|
||||
metadata:
|
||||
name: doublehandler
|
||||
namespace: istio-system
|
||||
spec:
|
||||
metrics:
|
||||
- name: double_request_count # Prometheus metric name
|
||||
instance_name: doublerequestcount.metric.istio-system # Mixer instance name (fully-qualified)
|
||||
kind: COUNTER
|
||||
label_names:
|
||||
- source
|
||||
- destination
|
||||
- message
|
||||
---
|
||||
# Rule to send metric instances to a Prometheus handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: rule
|
||||
metadata:
|
||||
name: doubleprom
|
||||
namespace: istio-system
|
||||
spec:
|
||||
actions:
|
||||
- handler: doublehandler.prometheus
|
||||
instances:
|
||||
- doublerequestcount.metric
|
||||
---
|
||||
# Configuration for logentry instances
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: logentry
|
||||
metadata:
|
||||
name: newlog
|
||||
namespace: istio-system
|
||||
spec:
|
||||
severity: '"warning"'
|
||||
timestamp: request.time
|
||||
variables:
|
||||
source: source.labels["app"] | source.service | "unknown"
|
||||
user: source.user | "unknown"
|
||||
destination: destination.labels["app"] | destination.service | "unknown"
|
||||
responseCode: response.code | 0
|
||||
responseSize: response.size | 0
|
||||
latency: response.duration | "0ms"
|
||||
monitored_resource_type: '"UNSPECIFIED"'
|
||||
---
|
||||
# Configuration for a stdio handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: stdio
|
||||
metadata:
|
||||
name: newhandler
|
||||
namespace: istio-system
|
||||
spec:
|
||||
severity_levels:
|
||||
warning: 1 # Params.Level.WARNING
|
||||
outputAsJson: true
|
||||
---
|
||||
# Rule to send logentry instances to a stdio handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: rule
|
||||
metadata:
|
||||
name: newlogstdio
|
||||
namespace: istio-system
|
||||
spec:
|
||||
match: "true" # match for all requests
|
||||
actions:
|
||||
- handler: newhandler.stdio
|
||||
instances:
|
||||
- newlog.logentry
|
||||
---
|
||||
# Configuration for metric instances
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: metric
|
||||
metadata:
|
||||
name: doublerequestcount
|
||||
namespace: istio-system
|
||||
spec:
|
||||
value: "2" # count each request twice
|
||||
dimensions:
|
||||
source: source.service | "unknown"
|
||||
destination: destination.service | "unknown"
|
||||
message: '"twice the fun!"'
|
||||
monitored_resource_type: '"UNSPECIFIED"'
|
||||
---
|
||||
# Configuration for a Prometheus handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: prometheus
|
||||
metadata:
|
||||
name: doublehandler
|
||||
namespace: istio-system
|
||||
spec:
|
||||
metrics:
|
||||
- name: double_request_count # Prometheus metric name
|
||||
instance_name: doublerequestcount.metric.istio-system # Mixer instance name (fully-qualified)
|
||||
kind: COUNTER
|
||||
label_names:
|
||||
- source
|
||||
- destination
|
||||
- message
|
||||
---
|
||||
# Rule to send metric instances to a Prometheus handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: rule
|
||||
metadata:
|
||||
name: doubleprom
|
||||
namespace: istio-system
|
||||
spec:
|
||||
actions:
|
||||
- handler: doublehandler.prometheus
|
||||
instances:
|
||||
- doublerequestcount.metric
|
||||
---
|
||||
# Configuration for logentry instances
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: logentry
|
||||
metadata:
|
||||
name: newlog
|
||||
namespace: istio-system
|
||||
spec:
|
||||
severity: '"warning"'
|
||||
timestamp: request.time
|
||||
variables:
|
||||
source: source.labels["app"] | source.service | "unknown"
|
||||
user: source.user | "unknown"
|
||||
destination: destination.labels["app"] | destination.service | "unknown"
|
||||
responseCode: response.code | 0
|
||||
responseSize: response.size | 0
|
||||
latency: response.duration | "0ms"
|
||||
monitored_resource_type: '"UNSPECIFIED"'
|
||||
---
|
||||
# Configuration for a stdio handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: stdio
|
||||
metadata:
|
||||
name: newhandler
|
||||
namespace: istio-system
|
||||
spec:
|
||||
severity_levels:
|
||||
warning: 1 # Params.Level.WARNING
|
||||
outputAsJson: true
|
||||
---
|
||||
# Rule to send logentry instances to a stdio handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: rule
|
||||
metadata:
|
||||
name: newlogstdio
|
||||
namespace: istio-system
|
||||
spec:
|
||||
match: "true" # match for all requests
|
||||
actions:
|
||||
- handler: newhandler.stdio
|
||||
instances:
|
||||
- newlog.logentry
|
||||
---
|
||||
```
|
||||
|
||||
1. Push the new configuration.
|
||||
|
|
|
@ -28,73 +28,73 @@ will generate and collect automatically.
|
|||
Save the following as `tcp_telemetry.yaml`:
|
||||
|
||||
```yaml
|
||||
# Configuration for a metric measuring bytes sent from a server
|
||||
# to a client
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: metric
|
||||
metadata:
|
||||
name: mongosentbytes
|
||||
namespace: default
|
||||
spec:
|
||||
value: connection.sent.bytes | 0 # uses a TCP-specific attribute
|
||||
dimensions:
|
||||
source_service: source.service | "unknown"
|
||||
source_version: source.labels["version"] | "unknown"
|
||||
destination_version: destination.labels["version"] | "unknown"
|
||||
monitoredResourceType: '"UNSPECIFIED"'
|
||||
---
|
||||
# Configuration for a metric measuring bytes sent from a client
|
||||
# to a server
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: metric
|
||||
metadata:
|
||||
name: mongoreceivedbytes
|
||||
namespace: default
|
||||
spec:
|
||||
value: connection.received.bytes | 0 # uses a TCP-specific attribute
|
||||
dimensions:
|
||||
source_service: source.service | "unknown"
|
||||
source_version: source.labels["version"] | "unknown"
|
||||
destination_version: destination.labels["version"] | "unknown"
|
||||
monitoredResourceType: '"UNSPECIFIED"'
|
||||
---
|
||||
# Configuration for a Prometheus handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: prometheus
|
||||
metadata:
|
||||
name: mongohandler
|
||||
namespace: default
|
||||
spec:
|
||||
metrics:
|
||||
- name: mongo_sent_bytes # Prometheus metric name
|
||||
instance_name: mongosentbytes.metric.default # Mixer instance name (fully-qualified)
|
||||
kind: COUNTER
|
||||
label_names:
|
||||
- source_service
|
||||
- source_version
|
||||
- destination_version
|
||||
- name: mongo_received_bytes # Prometheus metric name
|
||||
instance_name: mongoreceivedbytes.metric.default # Mixer instance name (fully-qualified)
|
||||
kind: COUNTER
|
||||
label_names:
|
||||
- source_service
|
||||
- source_version
|
||||
- destination_version
|
||||
---
|
||||
# Rule to send metric instances to a Prometheus handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: rule
|
||||
metadata:
|
||||
name: mongoprom
|
||||
namespace: default
|
||||
spec:
|
||||
match: context.protocol == "tcp"
|
||||
&& destination.service == "mongodb.default.svc.cluster.local"
|
||||
actions:
|
||||
- handler: mongohandler.prometheus
|
||||
instances:
|
||||
- mongoreceivedbytes.metric
|
||||
- mongosentbytes.metric
|
||||
# Configuration for a metric measuring bytes sent from a server
|
||||
# to a client
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: metric
|
||||
metadata:
|
||||
name: mongosentbytes
|
||||
namespace: default
|
||||
spec:
|
||||
value: connection.sent.bytes | 0 # uses a TCP-specific attribute
|
||||
dimensions:
|
||||
source_service: source.service | "unknown"
|
||||
source_version: source.labels["version"] | "unknown"
|
||||
destination_version: destination.labels["version"] | "unknown"
|
||||
monitoredResourceType: '"UNSPECIFIED"'
|
||||
---
|
||||
# Configuration for a metric measuring bytes sent from a client
|
||||
# to a server
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: metric
|
||||
metadata:
|
||||
name: mongoreceivedbytes
|
||||
namespace: default
|
||||
spec:
|
||||
value: connection.received.bytes | 0 # uses a TCP-specific attribute
|
||||
dimensions:
|
||||
source_service: source.service | "unknown"
|
||||
source_version: source.labels["version"] | "unknown"
|
||||
destination_version: destination.labels["version"] | "unknown"
|
||||
monitoredResourceType: '"UNSPECIFIED"'
|
||||
---
|
||||
# Configuration for a Prometheus handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: prometheus
|
||||
metadata:
|
||||
name: mongohandler
|
||||
namespace: default
|
||||
spec:
|
||||
metrics:
|
||||
- name: mongo_sent_bytes # Prometheus metric name
|
||||
instance_name: mongosentbytes.metric.default # Mixer instance name (fully-qualified)
|
||||
kind: COUNTER
|
||||
label_names:
|
||||
- source_service
|
||||
- source_version
|
||||
- destination_version
|
||||
- name: mongo_received_bytes # Prometheus metric name
|
||||
instance_name: mongoreceivedbytes.metric.default # Mixer instance name (fully-qualified)
|
||||
kind: COUNTER
|
||||
label_names:
|
||||
- source_service
|
||||
- source_version
|
||||
- destination_version
|
||||
---
|
||||
# Rule to send metric instances to a Prometheus handler
|
||||
apiVersion: "config.istio.io/v1alpha2"
|
||||
kind: rule
|
||||
metadata:
|
||||
name: mongoprom
|
||||
namespace: default
|
||||
spec:
|
||||
match: context.protocol == "tcp"
|
||||
&& destination.service == "mongodb.default.svc.cluster.local"
|
||||
actions:
|
||||
- handler: mongohandler.prometheus
|
||||
instances:
|
||||
- mongoreceivedbytes.metric
|
||||
- mongosentbytes.metric
|
||||
```
|
||||
|
||||
1. Push the new configuration.
|
||||
|
|
|
@ -40,47 +40,47 @@ from within your Istio cluster. In this task we will use
|
|||
1. Create an `ServiceEntry` to allow access to an external HTTP service:
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: httpbin-ext
|
||||
spec:
|
||||
hosts:
|
||||
- httpbin.org
|
||||
ports:
|
||||
- number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
EOF
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: httpbin-ext
|
||||
spec:
|
||||
hosts:
|
||||
- httpbin.org
|
||||
ports:
|
||||
- number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
EOF
|
||||
```
|
||||
|
||||
1. Create an `ServiceEntry` to allow access to an external HTTPS service:
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: google-ext
|
||||
spec:
|
||||
hosts:
|
||||
- www.google.com
|
||||
ports:
|
||||
- number: 443
|
||||
name: https
|
||||
protocol: HTTP
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: DestinationRule
|
||||
metadata:
|
||||
name: google-ext
|
||||
spec:
|
||||
host: www.google.com
|
||||
trafficPolicy:
|
||||
tls:
|
||||
mode: SIMPLE # initiates HTTPS when talking to www.google.com
|
||||
EOF
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: ServiceEntry
|
||||
metadata:
|
||||
name: google-ext
|
||||
spec:
|
||||
hosts:
|
||||
- www.google.com
|
||||
ports:
|
||||
- number: 443
|
||||
name: https
|
||||
protocol: HTTP
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: DestinationRule
|
||||
metadata:
|
||||
name: google-ext
|
||||
spec:
|
||||
host: www.google.com
|
||||
trafficPolicy:
|
||||
tls:
|
||||
mode: SIMPLE # initiates HTTPS when talking to www.google.com
|
||||
EOF
|
||||
```
|
||||
|
||||
Notice that we also create a corresponding `DestinationRule` to
|
||||
|
@ -136,21 +136,21 @@ to set a timeout rule on calls to the httpbin.org service.
|
|||
1. Exit the source pod and use `istioctl` to set a 3s timeout on calls to the httpbin.org external service:
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: httpbin-ext
|
||||
spec:
|
||||
hosts:
|
||||
- httpbin.org
|
||||
http:
|
||||
- timeout: 3s
|
||||
route:
|
||||
- destination:
|
||||
host: httpbin.org
|
||||
weight: 100
|
||||
EOF
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: httpbin-ext
|
||||
spec:
|
||||
hosts:
|
||||
- httpbin.org
|
||||
http:
|
||||
- timeout: 3s
|
||||
route:
|
||||
- destination:
|
||||
host: httpbin.org
|
||||
weight: 100
|
||||
EOF
|
||||
```
|
||||
|
||||
1. Wait a few seconds, then issue the _curl_ request again:
|
||||
|
|
|
@ -44,32 +44,32 @@ continue without any errors.
|
|||
Confirm the rule is created:
|
||||
|
||||
```command-output-as-yaml
|
||||
$ istioctl get virtualservice ratings -o yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: ratings
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- ratings
|
||||
http:
|
||||
- fault:
|
||||
delay:
|
||||
fixedDelay: 7s
|
||||
percent: 100
|
||||
match:
|
||||
- headers:
|
||||
cookie:
|
||||
regex: ^(.*?;)?(user=jason)(;.*)?$
|
||||
route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
- route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
$ istioctl get virtualservice ratings -o yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: ratings
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- ratings
|
||||
http:
|
||||
- fault:
|
||||
delay:
|
||||
fixedDelay: 7s
|
||||
percent: 100
|
||||
match:
|
||||
- headers:
|
||||
cookie:
|
||||
regex: ^(.*?;)?(user=jason)(;.*)?$
|
||||
route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
- route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
```
|
||||
|
||||
Allow several seconds to account for rule propagation delay to all pods.
|
||||
|
@ -124,32 +124,32 @@ message.
|
|||
Confirm the rule is created
|
||||
|
||||
```command-output-as-yaml
|
||||
$ istioctl get virtualservice ratings -o yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: ratings
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- ratings
|
||||
http:
|
||||
- fault:
|
||||
abort:
|
||||
httpStatus: 500
|
||||
percent: 100
|
||||
match:
|
||||
- headers:
|
||||
cookie:
|
||||
regex: ^(.*?;)?(user=jason)(;.*)?$
|
||||
route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
- route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
$ istioctl get virtualservice ratings -o yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: ratings
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- ratings
|
||||
http:
|
||||
- fault:
|
||||
abort:
|
||||
httpStatus: 500
|
||||
percent: 100
|
||||
match:
|
||||
- headers:
|
||||
cookie:
|
||||
regex: ^(.*?;)?(user=jason)(;.*)?$
|
||||
route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
- route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
```
|
||||
|
||||
1. Observe application behavior
|
||||
|
|
|
@ -115,49 +115,49 @@ In the following subsections we configure a `Gateway` on port 80 for unencrypted
|
|||
1. Create an Istio `Gateway`
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: httpbin-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use Istio default gateway implementation
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "httpbin.example.com"
|
||||
EOF
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: httpbin-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use Istio default gateway implementation
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "httpbin.example.com"
|
||||
EOF
|
||||
```
|
||||
|
||||
1. Configure routes for traffic entering via the `Gateway`
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: httpbin
|
||||
spec:
|
||||
hosts:
|
||||
- "httpbin.example.com"
|
||||
gateways:
|
||||
- httpbin-gateway
|
||||
http:
|
||||
- match:
|
||||
- uri:
|
||||
prefix: /status
|
||||
- uri:
|
||||
prefix: /delay
|
||||
route:
|
||||
- destination:
|
||||
port:
|
||||
number: 8000
|
||||
host: httpbin
|
||||
EOF
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: httpbin
|
||||
spec:
|
||||
hosts:
|
||||
- "httpbin.example.com"
|
||||
gateways:
|
||||
- httpbin-gateway
|
||||
http:
|
||||
- match:
|
||||
- uri:
|
||||
prefix: /status
|
||||
- uri:
|
||||
prefix: /delay
|
||||
route:
|
||||
- destination:
|
||||
port:
|
||||
number: 8000
|
||||
host: httpbin
|
||||
EOF
|
||||
```
|
||||
|
||||
Here we've created a [virtual service](/docs/reference/config/istio.networking.v1alpha3/#VirtualService)
|
||||
|
@ -223,32 +223,32 @@ In this subsection we add to our gateway the port 443 to handle the HTTPS traffi
|
|||
> The location of the certificate and the private key MUST be `/etc/istio/ingressgateway-certs`, or the gateway will fail to load them.
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: httpbin-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use istio default ingress gateway
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "httpbin.example.com"
|
||||
- port:
|
||||
number: 443
|
||||
name: https
|
||||
protocol: HTTPS
|
||||
tls:
|
||||
mode: SIMPLE
|
||||
serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
|
||||
privateKey: /etc/istio/ingressgateway-certs/tls.key
|
||||
hosts:
|
||||
- "httpbin.example.com"
|
||||
EOF
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: httpbin-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use istio default ingress gateway
|
||||
servers:
|
||||
- port:
|
||||
number: 80
|
||||
name: http
|
||||
protocol: HTTP
|
||||
hosts:
|
||||
- "httpbin.example.com"
|
||||
- port:
|
||||
number: 443
|
||||
name: https
|
||||
protocol: HTTPS
|
||||
tls:
|
||||
mode: SIMPLE
|
||||
serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
|
||||
privateKey: /etc/istio/ingressgateway-certs/tls.key
|
||||
hosts:
|
||||
- "httpbin.example.com"
|
||||
EOF
|
||||
```
|
||||
|
||||
### Verifying the gateway for HTTPS
|
||||
|
@ -278,26 +278,26 @@ If we want to only allow HTTPS traffic into our service mesh, we can remove the
|
|||
1. Redefine the `Gateway` without the HTTP port:
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: httpbin-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use istio default ingress gateway
|
||||
servers:
|
||||
- port:
|
||||
number: 443
|
||||
name: https
|
||||
protocol: HTTPS
|
||||
tls:
|
||||
mode: SIMPLE
|
||||
serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
|
||||
privateKey: /etc/istio/ingressgateway-certs/tls.key
|
||||
hosts:
|
||||
- "httpbin.example.com"
|
||||
EOF
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: httpbin-gateway
|
||||
spec:
|
||||
selector:
|
||||
istio: ingressgateway # use istio default ingress gateway
|
||||
servers:
|
||||
- port:
|
||||
number: 443
|
||||
name: https
|
||||
protocol: HTTPS
|
||||
tls:
|
||||
mode: SIMPLE
|
||||
serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
|
||||
privateKey: /etc/istio/ingressgateway-certs/tls.key
|
||||
hosts:
|
||||
- "httpbin.example.com"
|
||||
EOF
|
||||
```
|
||||
|
||||
1. Access the HTTP port and verify that it is not accessible (an error is returned):
|
||||
|
|
|
@ -18,72 +18,72 @@ This task demonstrates the traffic shadowing/mirroring capabilities of Istio. Tr
|
|||
httpbin-v1:
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl kube-inject -f - | kubectl create -f -
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: httpbin-v1
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
cat <<EOF | istioctl kube-inject -f - | kubectl create -f -
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: httpbin
|
||||
version: v1
|
||||
name: httpbin-v1
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/kennethreitz/httpbin
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: httpbin
|
||||
command: ["gunicorn", "--access-logfile", "-", "-b", "0.0.0.0:8080", "httpbin:app"]
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
EOF
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: httpbin
|
||||
version: v1
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/kennethreitz/httpbin
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: httpbin
|
||||
command: ["gunicorn", "--access-logfile", "-", "-b", "0.0.0.0:8080", "httpbin:app"]
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
EOF
|
||||
```
|
||||
|
||||
httpbin-v2:
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl kube-inject -f - | kubectl create -f -
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: httpbin-v2
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
cat <<EOF | istioctl kube-inject -f - | kubectl create -f -
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: httpbin
|
||||
version: v2
|
||||
name: httpbin-v2
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/kennethreitz/httpbin
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: httpbin
|
||||
command: ["gunicorn", "--access-logfile", "-", "-b", "0.0.0.0:8080", "httpbin:app"]
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
EOF
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: httpbin
|
||||
version: v2
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/kennethreitz/httpbin
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: httpbin
|
||||
command: ["gunicorn", "--access-logfile", "-", "-b", "0.0.0.0:8080", "httpbin:app"]
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
EOF
|
||||
```
|
||||
|
||||
httpbin Kubernetes service:
|
||||
|
||||
```bash
|
||||
cat <<EOF | kubectl create -f -
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: httpbin
|
||||
labels:
|
||||
app: httpbin
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
selector:
|
||||
app: httpbin
|
||||
EOF
|
||||
cat <<EOF | kubectl create -f -
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: httpbin
|
||||
labels:
|
||||
app: httpbin
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
selector:
|
||||
app: httpbin
|
||||
EOF
|
||||
```
|
||||
|
||||
* Start the `sleep` service so we can use `curl` to provide load
|
||||
|
@ -91,24 +91,24 @@ This task demonstrates the traffic shadowing/mirroring capabilities of Istio. Tr
|
|||
sleep service:
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl kube-inject -f - | kubectl create -f -
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: sleep
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
cat <<EOF | istioctl kube-inject -f - | kubectl create -f -
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: sleep
|
||||
name: sleep
|
||||
spec:
|
||||
containers:
|
||||
- name: sleep
|
||||
image: tutum/curl
|
||||
command: ["/bin/sleep","infinity"]
|
||||
imagePullPolicy: IfNotPresent
|
||||
EOF
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: sleep
|
||||
spec:
|
||||
containers:
|
||||
- name: sleep
|
||||
image: tutum/curl
|
||||
command: ["/bin/sleep","infinity"]
|
||||
imagePullPolicy: IfNotPresent
|
||||
EOF
|
||||
```
|
||||
|
||||
## Mirroring
|
||||
|
@ -120,35 +120,35 @@ Let's set up a scenario to demonstrate the traffic-mirroring capabilities of Ist
|
|||
1. Create a default route rule to route all traffic to `v1` of our `httpbin` service:
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: httpbin
|
||||
spec:
|
||||
hosts:
|
||||
- httpbin
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: httpbin
|
||||
subset: v1
|
||||
weight: 100
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: DestinationRule
|
||||
metadata:
|
||||
name: httpbin
|
||||
spec:
|
||||
host: httpbin
|
||||
subsets:
|
||||
- name: v1
|
||||
labels:
|
||||
version: v1
|
||||
- name: v2
|
||||
labels:
|
||||
version: v2
|
||||
EOF
|
||||
cat <<EOF | istioctl create -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: httpbin
|
||||
spec:
|
||||
hosts:
|
||||
- httpbin
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: httpbin
|
||||
subset: v1
|
||||
weight: 100
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: DestinationRule
|
||||
metadata:
|
||||
name: httpbin
|
||||
spec:
|
||||
host: httpbin
|
||||
subsets:
|
||||
- name: v1
|
||||
labels:
|
||||
version: v1
|
||||
- name: v2
|
||||
labels:
|
||||
version: v2
|
||||
EOF
|
||||
```
|
||||
|
||||
Now all traffic should go to `httpbin v1` service. Let's try sending in some traffic:
|
||||
|
@ -187,24 +187,24 @@ Let's set up a scenario to demonstrate the traffic-mirroring capabilities of Ist
|
|||
1. Change the route rule to mirror traffic to v2
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: httpbin
|
||||
spec:
|
||||
hosts:
|
||||
- httpbin
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: httpbin
|
||||
subset: v1
|
||||
weight: 100
|
||||
mirror:
|
||||
host: httpbin
|
||||
subset: v2
|
||||
EOF
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: httpbin
|
||||
spec:
|
||||
hosts:
|
||||
- httpbin
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: httpbin
|
||||
subset: v1
|
||||
weight: 100
|
||||
mirror:
|
||||
host: httpbin
|
||||
subset: v2
|
||||
EOF
|
||||
```
|
||||
|
||||
This route rule specifies we route 100% of the traffic to v1. The last stanza specifies we want to mirror to the `httpbin v2` service. When traffic gets mirrored, the requests are sent to the mirrored service with its Host/Authority header appended with *-shadow*. For example, *cluster-1* becomes *cluster-1-shadow*. Also important to realize is that these requests are mirrored as "fire and forget", i.e., the responses are discarded.
|
||||
|
|
|
@ -40,66 +40,66 @@ you'll need to use `replace` rather than `create` in the following command.
|
|||
You can display the routes that are defined with the following command:
|
||||
|
||||
```command-output-as-yaml
|
||||
$ istioctl get virtualservices -o yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: details
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- details
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: details
|
||||
subset: v1
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: productpage
|
||||
...
|
||||
spec:
|
||||
gateways:
|
||||
- bookinfo-gateway
|
||||
- mesh
|
||||
hosts:
|
||||
- productpage
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: productpage
|
||||
subset: v1
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: ratings
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- ratings
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: reviews
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- reviews
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v1
|
||||
---
|
||||
$ istioctl get virtualservices -o yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: details
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- details
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: details
|
||||
subset: v1
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: productpage
|
||||
...
|
||||
spec:
|
||||
gateways:
|
||||
- bookinfo-gateway
|
||||
- mesh
|
||||
hosts:
|
||||
- productpage
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: productpage
|
||||
subset: v1
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: ratings
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- ratings
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
---
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: reviews
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- reviews
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v1
|
||||
---
|
||||
```
|
||||
|
||||
> The corresponding `subset` definitions can be displayed using `istioctl get destinationrules -o yaml`.
|
||||
|
@ -124,28 +124,28 @@ you'll need to use `replace` rather than `create` in the following command.
|
|||
Confirm the rule is created:
|
||||
|
||||
```command-output-as-yaml
|
||||
$ istioctl get virtualservice reviews -o yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: reviews
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- reviews
|
||||
http:
|
||||
- match:
|
||||
- headers:
|
||||
cookie:
|
||||
regex: ^(.*?;)?(user=jason)(;.*)?$
|
||||
route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v2
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v1
|
||||
$ istioctl get virtualservice reviews -o yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: reviews
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- reviews
|
||||
http:
|
||||
- match:
|
||||
- headers:
|
||||
cookie:
|
||||
regex: ^(.*?;)?(user=jason)(;.*)?$
|
||||
route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v2
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v1
|
||||
```
|
||||
|
||||
1. Log in as user "jason" at the `productpage` web page.
|
||||
|
|
|
@ -32,43 +32,43 @@ to the `ratings` service.
|
|||
1. Route requests to v2 of the `reviews` service, i.e., a version that calls the `ratings` service
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: reviews
|
||||
spec:
|
||||
hosts:
|
||||
- reviews
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v2
|
||||
EOF
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: reviews
|
||||
spec:
|
||||
hosts:
|
||||
- reviews
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v2
|
||||
EOF
|
||||
```
|
||||
|
||||
1. Add a 2 second delay to calls to the `ratings` service:
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: ratings
|
||||
spec:
|
||||
hosts:
|
||||
- ratings
|
||||
http:
|
||||
- fault:
|
||||
delay:
|
||||
percent: 100
|
||||
fixedDelay: 2s
|
||||
route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
EOF
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: ratings
|
||||
spec:
|
||||
hosts:
|
||||
- ratings
|
||||
http:
|
||||
- fault:
|
||||
delay:
|
||||
percent: 100
|
||||
fixedDelay: 2s
|
||||
route:
|
||||
- destination:
|
||||
host: ratings
|
||||
subset: v1
|
||||
EOF
|
||||
```
|
||||
|
||||
1. Open the Bookinfo URL (http://$GATEWAY_URL/productpage) in your browser
|
||||
|
@ -79,21 +79,21 @@ to the `ratings` service.
|
|||
1. Now add a 1 second request timeout for calls to the `reviews` service
|
||||
|
||||
```bash
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: reviews
|
||||
spec:
|
||||
hosts:
|
||||
- reviews
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v2
|
||||
timeout: 1s
|
||||
EOF
|
||||
cat <<EOF | istioctl replace -f -
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: reviews
|
||||
spec:
|
||||
hosts:
|
||||
- reviews
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v2
|
||||
timeout: 1s
|
||||
EOF
|
||||
```
|
||||
|
||||
1. Refresh the Bookinfo web page
|
||||
|
|
|
@ -43,26 +43,26 @@ two steps: 50%, 100%.
|
|||
Confirm the rule was replaced:
|
||||
|
||||
```command-output-as-yaml
|
||||
$ istioctl get virtualservice reviews -o yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: reviews
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- reviews
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v1
|
||||
weight: 50
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v3
|
||||
weight: 50
|
||||
$ istioctl get virtualservice reviews -o yaml
|
||||
apiVersion: networking.istio.io/v1alpha3
|
||||
kind: VirtualService
|
||||
metadata:
|
||||
name: reviews
|
||||
...
|
||||
spec:
|
||||
hosts:
|
||||
- reviews
|
||||
http:
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v1
|
||||
weight: 50
|
||||
- route:
|
||||
- destination:
|
||||
host: reviews
|
||||
subset: v3
|
||||
weight: 50
|
||||
```
|
||||
|
||||
1. Refresh the `productpage` in your browser and you should now see *red* colored star ratings approximately 50% of the time.
|
||||
|
|
|
@ -310,15 +310,15 @@ scrape Mixer.
|
|||
|
||||
1. Visit [http://localhost:9090/config](http://localhost:9090/config) and confirm that an entry exists that looks like:
|
||||
|
||||
```yaml
|
||||
- job_name: 'istio-mesh'
|
||||
# Override the global default and scrape targets from this job every 5 seconds.
|
||||
scrape_interval: 5s
|
||||
# metrics_path defaults to '/metrics'
|
||||
# scheme defaults to 'http'.
|
||||
static_configs:
|
||||
- targets: ['istio-mixer.istio-system:42422']
|
||||
```
|
||||
```yaml
|
||||
- job_name: 'istio-mesh'
|
||||
# Override the global default and scrape targets from this job every 5 seconds.
|
||||
scrape_interval: 5s
|
||||
# metrics_path defaults to '/metrics'
|
||||
# scheme defaults to 'http'.
|
||||
static_configs:
|
||||
- targets: ['istio-mixer.istio-system:42422']
|
||||
```
|
||||
|
||||
## How can I debug issues with the service mesh?
|
||||
|
||||
|
|
|
@ -113,6 +113,26 @@ function handleDOMLoaded() {
|
|||
// HTML, but alas our current toolchain won't allow that in a clean/simple
|
||||
// way.
|
||||
function patchDOM() {
|
||||
|
||||
// To compensate for https://github.com/gohugoio/hugo/issues/4785, certain code blocks are
|
||||
// indented in markdown by four spaces. This removes these four spaces so that the visuals
|
||||
// are correct.
|
||||
function compensateForHugoBug() {
|
||||
var code = document.getElementsByTagName('CODE');
|
||||
for (var i = 0; i < code.length; i++) {
|
||||
var text = code[i].innerText;
|
||||
var lines = text.split("\n");
|
||||
if ((lines.length > 0) && lines[0].startsWith(" ")) {
|
||||
for (var j = 0; j < lines.length; j++) {
|
||||
if (lines[j].startsWith(" ")) {
|
||||
lines[j] = lines[j].slice(4);
|
||||
}
|
||||
}
|
||||
code[i].innerText = lines.join('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a Copy button to all PRE blocks
|
||||
function attachCopyButtons() {
|
||||
var pre = document.getElementsByTagName('PRE');
|
||||
|
@ -370,6 +390,7 @@ function handleDOMLoaded() {
|
|||
}
|
||||
}
|
||||
|
||||
compensateForHugoBug();
|
||||
attachCopyButtons();
|
||||
applySyntaxColoring();
|
||||
attachLinksToHeaders();
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue