Skip to content

Commit

Permalink
Merge pull request #52 from sunyuan3/markdowncheck
Browse files Browse the repository at this point in the history
add markdownlint
  • Loading branch information
BSWANG authored Jul 4, 2019
2 parents 297aebe + 9685624 commit b7816cb
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 30 deletions.
17 changes: 17 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ jobs:
name: detect deadcode without tests folder
command: |
gometalinter --disable-all --skip vendor --skip tests -E deadcode -d ./...
- run:
name: use markdownlint v0.5.0 to lint markdown file (https://github.com/markdownlint/markdownlint)
command: |
find ./ -name "*.md" | grep -v vendor | grep -v commandline | grep -v .github | grep -v swagger | grep -v api | xargs mdl -r ~MD010,~MD013,~MD024,~MD029,~MD033,~MD036
- run:
name: use markdown-link-check(https://github.com/tcort/markdown-link-check) to check links in markdown files
command: |
set +e
for name in $(find . -name \*.md | grep -v vendor); do
if [ -f $name ]; then
markdown-link-check -q $name;
if [ $? -ne 0 ]; then
code=1
fi
fi
done
bash -c "exit $code";
markdown-spellcheck:
docker:
Expand Down
25 changes: 14 additions & 11 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Terway 网络插件
CNI plugin for alibaba cloud VPC/ENI

CNI plugin for alibaba cloud VPC/ENI

[![CircleCI](https://circleci.com/gh/AliyunContainerService/terway.svg?style=svg)](https://circleci.com/gh/AliyunContainerService/terway)

[English](./README.md) | 简体中文

## 安装Kubernetes
使用kubeadm的指导文档 https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/ 来创建集群

使用kubeadm的指导文档`https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/`来创建集群

安装好了之后要:

* 将iptables的policy换成ACCEPT,`iptables -P FORWARD ACCEPT`
* 检查节点上的"rp_filter"内核参数,并在每个节点上将其设置为"0"。

Expand All @@ -28,12 +31,12 @@ Terway有两种安装模式:
ENI多IP模式,使用Aliyun ENI的辅助IP来打通网络,不受VPC的路由条目限制,安装方式:<br />
修改[terway-multiip.yml](./terway-multiip.yml)文件中的eni.conf的配置中的授权和资源配置,然后通过`kubectl apply -f terway-multiip.yml`来安装terway插件。


使用`kubectl get ds terway`看到插件在每个节点上都运行起来后,表明插件安装成功。

## 验证terway的功能

### 一般VPC网络的容器

在VPC安装模式下,在容器没有做任何特殊配置时,terway会通过在节点上的podCidr中去分配地址然后配置给容器。
例如:

Expand All @@ -58,7 +61,7 @@ If you don't see a command prompt, try pressing enter.
valid_lft forever preferred_lft forever
inet6 fe80::4402:2ff:fe6b:651e/64 scope link
valid_lft forever preferred_lft forever
```
```

#### 使用ENI弹性网卡获得等同于底层网络的性能

Expand Down Expand Up @@ -129,15 +132,16 @@ root@nginx-64f497f8fd-ckpdm:/# ip addr show
Terway插件兼容标准的K8S中的NetworkPolicy来控制容器间的访问,例如:

1. 启动一个用于测试的服务

```
[root@iZbp126bomo449eksjknkeZ ~]# kubectl run nginx --image=nginx --replicas=2
deployment "nginx" created
[root@iZbp126bomo449eksjknkeZ ~]# kubectl expose deployment nginx --port=80
service "nginx" exposed
```

2. 验证到这个服务是可以访问的

```
[root@iZbp126bomo449eksjknkeZ ~]# kubectl run busybox --rm -ti --image=busybox /bin/sh
If you don't see a command prompt, try pressing enter.
Expand All @@ -147,7 +151,7 @@ Terway插件兼容标准的K8S中的NetworkPolicy来控制容器间的访问,
```

3. 配置network policy规则,只允许某些标签的服务访问

```
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
Expand All @@ -173,14 +177,13 @@ Terway插件兼容标准的K8S中的NetworkPolicy来控制容器间的访问,
Connecting to nginx (172.21.0.225:80)
wget: download timed out
/ #

[root@iZbp126bomo449eksjknkeZ ~]# kubectl run busybox --rm -ti --labels="access=true" --image=busybox /bin/sh
If you don't see a command prompt, try pressing enter.
/ # wget --spider --timeout=1 nginx
Connecting to nginx (172.21.0.225:80)
/ #
```

```

### 限制容器的出入带宽

Expand All @@ -202,4 +205,4 @@ spec:
image: nginx:1.7.9
ports:
- containerPort: 80
```
```
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Terway CNI Network Plugin
CNI plugin for Alibaba Cloud VPC/ENI

CNI plugin for Alibaba Cloud VPC/ENI

[![CircleCI](https://circleci.com/gh/AliyunContainerService/terway.svg?style=svg)](https://circleci.com/gh/AliyunContainerService/terway)
[![Go Report Card](https://goreportcard.com/badge/github.com/AliyunContainerService/terway)](https://goreportcard.com/report/github.com/AliyunContainerService/terway)


English | [简体中文](./README-zh_CN.md)

## Try It:
## Try It

### Install Kubernetes
Install Kubernetes via kubeadm: https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/

Install Kubernetes via kubeadm: `https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/`

After setup kubernetes cluster.

* Change `iptables` `Forward` default policy to `ACCEPT` on every node of cluster: `iptables -P FORWARD ACCEPT`.
* Check the `rp_filter` in sysctl parameters, set them to "0" on every node of cluster.

Expand All @@ -32,12 +35,11 @@ Terway plugin have two installation modes
ENI Secondary IP Mode, Using `Aliyun ENI's secondary ip` to connect the pods. This mode not limited by VPC route tables quotation. Install method: <br />
Replace `access_key/access_secret` and `security_group/vswitches` in [terway-multiip.yml](./terway-multiip.yml) with your aliyun openapi credentials and resources id. Then use `kubectl apply -f terway-multiip.yml` to install Terway into kubernetes cluster.


Using `kubectl get ds terway -n kube-system` to watch plugin launching. Plugin install completed while terway daemonset available pods equal to nodes.

### Terway network plugin usage:
### Terway network plugin usage

#### Vpc network container:
#### Vpc network container

On VPC installation mode, Terway will config pod's address using node's `podCidr` when pod not have any especial config. eg:

Expand All @@ -62,9 +64,10 @@ If you don't see a command prompt, try pressing enter.
valid_lft forever preferred_lft forever
inet6 fe80::4402:2ff:fe6b:651e/64 scope link
valid_lft forever preferred_lft forever
```
```

#### Using ENI network interface to get the performance equivalent to the underlying network

#### Using ENI network interface to get the performance equivalent to the underlying network.
On VPC installation mode, Config `eni` request `aliyun/eni: 1` in one container of pod. The following example will create an Nginx Pod and assign an ENI:

```
Expand Down Expand Up @@ -125,20 +128,21 @@ root@nginx-64f497f8fd-ckpdm:/# ip addr show
valid_lft forever preferred_lft forever
```

#### Using network policy to limit accessible between containers.
#### Using network policy to limit accessible between containers

The Terway plugin is compatible with NetworkPolicy in the standard K8S to control access between containers, for example:

1. Create and expose an deployment for test

```
[root@iZbp126bomo449eksjknkeZ ~]# kubectl run nginx --image=nginx --replicas=2
deployment "nginx" created
[root@iZbp126bomo449eksjknkeZ ~]# kubectl expose deployment nginx --port=80
service "nginx" exposed
```

2. Run busybox to test connection to deployment:

```
[root@iZbp126bomo449eksjknkeZ ~]# kubectl run busybox --rm -ti --image=busybox /bin/sh
If you don't see a command prompt, try pressing enter.
Expand All @@ -148,7 +152,7 @@ The Terway plugin is compatible with NetworkPolicy in the standard K8S to contro
```

3. Config network policy,only allow pod access which have `run: nginx` label:

```
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
Expand All @@ -174,14 +178,13 @@ The Terway plugin is compatible with NetworkPolicy in the standard K8S to contro
Connecting to nginx (172.21.0.225:80)
wget: download timed out
/ #

[root@iZbp126bomo449eksjknkeZ ~]# kubectl run busybox --rm -ti --labels="access=true" --image=busybox /bin/sh
If you don't see a command prompt, try pressing enter.
/ # wget --spider --timeout=1 nginx
Connecting to nginx (172.21.0.225:80)
/ #
```

```

#### Limit container in/out bandwidth

Expand All @@ -203,9 +206,10 @@ spec:
image: nginx:1.7.9
ports:
- containerPort: 80
```
```

## Build Terway

Prerequisites:

* Docker >= 17.05 with multi-stage build
Expand All @@ -222,5 +226,5 @@ You are welcome to make new issues and pull requests.

### DingTalk

Join `DingTalk` group by the QR code below:
Join `DingTalk` group by the QR code below:
<img src="./docs/images/ding_group_qrcode.jpg" width="300" height="400" />
10 changes: 9 additions & 1 deletion docs/design.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
# Terway插件

Kubernetes有着种类丰富,数量繁多的网络插件,几乎任何场景,都能找到能用的网络插件。对于有追求的程序员来说,只是能用可不行,必须要选择最好的。很多时候,适合的才是最好的。
Terway是容器服务团队推出的针对阿里云VPC网络的CNI插件,稳定、高性能,支持Kubernetes network policy、流控等高级特性。

![terway](images/terway.png)
Terway的结构还是比较简单的,首先是标准的CNI接口,支持Kubernetes。内置了Network Policy和Traffic Control,同样是在Kubernetes场景下使用,支持Network Policies,可以实现Pod之间的访问隔离。通过在Pod上声明annotation kubernetes.io/ingress-bandwidth和kubernetes.io/egress-bandwidth可以限制Pod的入网和出网带宽。

## 架构设计与考虑

组件列表,时序图交互

### 资源管理和分配

资源状态,资源的池化与缓存,pod关联关系

### 不同资源类型的通信方案

#### vpc

#### ENI

#### ENI多IP

##### veth策略路由

##### ipvlan l3s

### Network Policy

### Pod流量控制
### Pod流量控制

0 comments on commit b7816cb

Please sign in to comment.