Skip to content

Commit

Permalink
update post
Browse files Browse the repository at this point in the history
Signed-off-by: zhaohuabing <zhaohuabing@gmail.com>
  • Loading branch information
zhaohuabing committed Oct 17, 2022
1 parent 3410987 commit f93b14a
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,3 +1,3 @@
# Istio 运维手册
# Istio 运维实战

[在线阅读](https://istio-operation-bible.aeraki.net/)
30 changes: 21 additions & 9 deletions config.toml
@@ -1,4 +1,5 @@
baseURL = "/"
#baseURL = "/"
baseURL="https://www.zhaohuabing.com/istio-guide/"
title = "Istio 运维实战"

# Language settings
Expand Down Expand Up @@ -66,8 +67,8 @@ id = "UA-00000000-0"
# Language configuration

[languages.zh]
title = "Istio 运维实战"
description = "Istio 运维实战"
title = "Envoy 学习笔记"
description = "Envoy 学习笔记"
languageName ="中文"
contentDir = "content/zh"
time_format_default = "2006.02.01"
Expand All @@ -90,8 +91,8 @@ time_format_blog = "2006.02.01"
section = ["HTML", "print", "RSS"]

[params]
copyright = "Aeraki Mesh"
privacy_policy = "https://www.aeraki.net/"
copyright = "Huabing Blog"
privacy_policy = "https://www.zhaohuabing.com/"

# First one is picked as the Twitter card image if not set on page.
# images = ["images/project-illustration.png"]
Expand All @@ -112,12 +113,12 @@ version = "0.0"

# A link to latest version of the docs. Used in the "version-banner" partial to
# point people to the main doc site.
url_latest_version = "https://github.com/aeraki-mesh/istio-operation-bible"
url_latest_version = "https://zhaohuabing.com/istio-guide"

# Repository configuration (URLs for in-page links to opening issues and suggesting changes)
github_repo = "https://github.com/aeraki-mesh/istio-operation-bible"
github_repo = "https://github.com/zhaohuabing/istio-guide"
# An optional link to a related project repo. For example, the sibling repository where your product code lives.
#github_project_repo = "https://github.com/aeraki-mesh/aeraki"
#github_project_repo = "https://github.com/google/docsy"

# Specify a value here if your content directory is not in your repo's root directory
# github_subdir = ""
Expand Down Expand Up @@ -173,10 +174,21 @@ no = 'Sorry to hear that. Please <a href="https://github.com/USERNAME/REPOSITORY
enable = false

[params.links]
# End user relevant links. These will show up on left side of footer and in the community page if you have one.
[[params.links.user]]
name = "Email"
url = "mailto:zhaohuabing@zhaohuabing.com"
icon = "fa fa-envelope"
desc = "Discussion and help from your fellow users"
[[params.links.user]]
name ="Twitter"
url = "https://twitter.com/zhaohuabing"
icon = "fab fa-twitter"
desc = "Follow us on Twitter to get the latest news!"
# Developer relevant links. These will show up on right side of footer and in the community page if you have one.
[[params.links.developer]]
name = "GitHub"
url = "https://github.com/aeraki-mesh/istio-operation-bible"
url = "https://github.com/zhaohuabing/istio-guide"
icon = "fab fa-github"
desc = "Development takes place here!"
[params.plantuml]
Expand Down
4 changes: 2 additions & 2 deletions content/zh/_index.html
@@ -1,6 +1,6 @@
+++
title = "Istio 运维实战"
linkTitle = "Istio 运维实战"
title = "Istio 运维实战 "
linkTitle = "Istio 运维实战 "

+++

Expand Down
2 changes: 1 addition & 1 deletion content/zh/docs/debug-istio/envoy-log/_index.md
@@ -1,5 +1,5 @@
---
title: "Envoy 日志调试指南"
title: "Envoy 日志分析"
linkTitle: ""
weight: 1
date: 2022-07-06
Expand Down
35 changes: 35 additions & 0 deletions content/zh/docs/debug-istio/istio-debug/_index.md
@@ -0,0 +1,35 @@
---
title: "Istio 调试端口"
linkTitle: ""
weight: 1
date: 2022-10-11
description:
---


## Istio 调试接口

Istio 提供了一个调试端口 15014,通过该端口可以查看到 istiod 内部的大量调试信息,包括 istiod 的内存、cpu 使用情况,xds 缓存信息,连接到 istio 的代理,cluster 和 endpoint 信息等等。

可以通过下面的命令将 15014 端口 port forward 到 localhost:

```bash
k -n istio-system port-forward svc/istiod 15014
```

通过浏览器访问 ```http://127.0.0.1:15014/debug```, 可以看到调试端口支持获取的所有信息。

![istio-debug](image/istio-debug.png)

## 查看 istiod 内存占用

将 istio 调试端口 port forward 到 localhost 后,可以采用下面的命令分析 istiod 的内存使用情况:

```bash
go tool pprof -http=:8080 localhost:15014/debug/pprof/heap
```

该命令以 istio 调试端口输出的 heap 信息为输入,在 8080 端口上提供了 istiod 内存的详细分析。

![istio-heap](image/istio-heap.png)

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions content/zh/docs/tricks/_index.md
@@ -0,0 +1,7 @@
---
title: "Istio 小技巧"
linkTitle: "Istio 小技巧"
weight: 90
description: >
一些 Istio 小技巧
---
68 changes: 68 additions & 0 deletions content/zh/docs/tricks/direct-response/_index.md
@@ -0,0 +1,68 @@
---
title: "directResoponse"
weight: 1
date: 2022-10-17
description: >
代理对符合某个条件的 HTTP 请求直接返回一个响应。
---

有时候我们希望 gateway/sidecar 能直接向客户端返回一个 HTTP response,而不用交给应用程序处理。

## 1.15 版本之前

可以通过 EnvoyFilter 来修改 HTTP Route,为匹配某个条件的 HTTP 请求直接返回指定的内容。例如,下面的 EnvoyFilter 为 ingress gateway 收到的 http://*:80/direct 直接返回一个 200 response,消息体为 ```hello world```。:

```yaml
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: direct
spec:
workloadSelector:
labels:
istio: ingressgateway
configPatches:
- applyTo: HTTP_ROUTE
match:
context: GATEWAY
routeConfiguration:
portNumber: 80
patch:
operation: INSERT_FIRST
value:
name: direct
match:
path: /direct
directResponse:
body:
inlineString: 'hello world'
status: 200
```

## 1.15 及之后版本

1.15 版本开始,VS 支持设置 directResponse,如下所示:

```yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings-route
spec:
hosts:
- ratings.prod.svc.cluster.local
http:
- match:
- uri:
exact: /v1/getProductRatings
directResponse:
status: 503
body:
string: "unknown error"
...
```

## 参考文档

* EnvoyFilter https://istio.io/latest/docs/reference/config/networking/envoy-filter/
* HTTPDirectResponse https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPDirectResponse

0 comments on commit f93b14a

Please sign in to comment.