Skip to content

Commit ab808c0

Browse files
committed
1 parent e92104a commit ab808c0

File tree

12 files changed

+66
-59
lines changed

12 files changed

+66
-59
lines changed

.vuepress/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ module.exports = {
107107
link: 'https://github.com/fenixsoft/microservice_arch_kubernetes'
108108
}, {
109109
text: '后端:微服务架构 Istio',
110-
link: 'https://github.com/fenixsoft/microservice_arch_istio'
110+
link: 'https://github.com/fenixsoft/servicemesh_arch_istio'
111111
}, {
112112
text: '后端:无服务架构 Serverless',
113113
link: 'https://github.com/fenixsoft/serverless_arch'
@@ -150,7 +150,7 @@ module.exports = {
150150
'/exploration/projects/monolithic_arch_springboot',
151151
'/exploration/projects/microservice_arch_springcloud',
152152
'/exploration/projects/microservice_arch_kubernetes',
153-
'/exploration/projects/microservice_arch_istio',
153+
'/exploration/projects/servicemesh_arch_istio',
154154
'/exploration/projects/serverless_arch'
155155
]
156156
}]

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@
7979
- 后端工程:
8080
- Spring Boot 实现单体架构:[https://github.com/fenixsoft/monolithic_arch_springboot](https://github.com/fenixsoft/monolithic_arch_springboot)
8181
- Spring Cloud 实现微服务架构:[https://github.com/fenixsoft/microservice_arch_springcloud](https://github.com/fenixsoft/microservice_arch_springcloud)
82-
- Kubernetes 为基础设施的微服务架构:https://github.com/fenixsoft/microservice_arch_kubernetes
83-
- Knative 实现的无服务架构:https://github.com/fenixsoft/serverless_arch_knative
82+
- Kubernetes 为基础设施的微服务架构:[https://github.com/fenixsoft/microservice_arch_kubernetes](https://github.com/fenixsoft/microservice_arch_kubernetes)
83+
- Istio 为基础设施的服务网格架构:https://github.com/fenixsoft/servicemesh_arch_istio
84+
- 基于云端的无服务架构:https://github.com/fenixsoft/serverless_arch
8485

8586

8687

appendix/deployment-env-setup/setup-docker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ Docker自带了bash的命令行补全,用其他shell,如zsh,则需采用zs
249249
>
250250
> ```bash
251251
> $ mkdir -p ~/.zsh/completion
252-
> $ curl -L https://raw.githubusercontent.com/docker/docker/master/contrib/completion/zsh/_docker > ~/.zsh/completion/_docker
252+
> $ curl -L https://raw.githubusercontent.com/docker/cli/master/contrib/completion/zsh/_docker > ~/.zsh/completion/_docker
253253
>
254254
> $ echo 'fpath=(~/.zsh/completion $fpath)' >> ~/.zshrc
255255
> $ echo 'autoload -Uz compinit && compinit -u' >> ~/.zshrc

appendix/deployment-env-setup/setup-kubernetes/README.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,15 @@
22

33
Kubernetes是一个由Google发起的开源自动化部署,缩放,以及容器化管理应用程序的容器编排系统。
44

5-
部署Kubernetes曾经是一件比较麻烦的事情,但程序员大概是最爱偷懒最怕麻烦的群体,出现了若干种不同的途径,使得部署和管理Kubernetes集群正在变得越来越简单。目前主流的方式大致有:
5+
部署Kubernetes曾经是一件比较麻烦的事情,kubelet、Api-Server、etcd、controller-manager等每一个组件都需要自己部署,还要创建自签名证书来保证各个组件之间的网络访问。但程序员大概是最爱偷懒最怕麻烦的群体,随着Kubernetes的后续版本不断改进(如提供了自动生成证书、Api-Server等组件改为默认静态Pod部署方式),使得部署和管理Kubernetes集群正在变得越来越简单。目前主流的方式大致有:
66

77
* [使用Kubeadm部署Kubernetes集群](setup-kubeadm.md)
8-
* [使用Rancher部署、管理Kubernetes集群](setup-rancher.md)
9-
10-
8+
* [使用Rancher部署、管理Kubernetes集群](setup-rancher.md)</br>
119
其他如KubeSphere等在Kubernetes基础上构建的工具均归入此类
12-
13-
* [使用Minikube在本地单节点部署Kubernetes集群](setup-minikube.md)
14-
15-
10+
* [使用Minikube在本地单节点部署Kubernetes集群](setup-minikube.md)</br>
1611
其他如Microk8s等本地环境的工具均归入此类
17-
18-
* 在Google Kubernetes Engine云原生环境中部署
19-
20-
21-
其他如AWS、阿里云、腾讯云等提供的Kubernetes云主机均归入此类
12+
* 在Google Kubernetes Engine云原生环境中部署</br>
13+
其他如AWS、阿里云、腾讯云等提供的Kubernetes云主机均归入此类
2214

2315
以上集中部署方式都有很明显的针对性,个人开发环境以Minikube最简单,生产环境以Rancher最简单,在云原生环境中,自然是使用环境提供的相应工具。不过笔者推荐首次接触Kubernetes的同学最好还是选择Kubeadm来部署,毕竟这是官方提供的集群管理工具,是相对更底层、基础的方式,充分熟悉了之后再接触其他简化的方式会快速融会贯通。 以上部署方式无需全部阅读,根据自己环境的情况选择其一即可。
2416

appendix/deployment-env-setup/setup-kubernetes/setup-kubeadm.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,16 @@ $ kubeadm init --kubernetes-version v1.17.3 --pod-network-cidr=10.244.0.0/16
198198
199199
这信息先恭喜你已经把控制平面安装成功了,但还有三行“you need……”、“you should……”、“you can……”开头的内容,这是三项后续的“可选”工作,下面继续介绍。
200200
201-
## 让非Root用户可以使用Kubernetes <Badge text="可选" type="warning"/>
201+
## 为当前用户生成kubeconfig
202202
203-
Kubernetes最初是以root用户安装的,如果需要非root的其他用户也可以使用Kubernetes集群,那需要为该用户先配置好admin.conf文件。切换至该用户后,进行如下操作:
203+
使用Kubernetes前需要为当前用户先配置好admin.conf文件。切换至需配置的用户后,进行如下操作:
204204
205205
```bash
206206
$ mkdir -p $HOME/.kube
207207
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
208208
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
209209
```
210210
211-
当然,如果只是在测试环境,准备后续都准备使用root运行,那这个步骤可以略过。
212-
213211
## 安装CNI插件 <Badge text="可选" type="warning"/>
214212
215213
CNI即“容器网络接口”,在2016 年,CoreOS发布了CNI规范。2017年5月,CNI被CNCF技术监督委员会投票决定接受为托管项目,从此成为不同容器编排工具(Kubernetes、Mesos、OpenShift)可以共同使用的、解决容器之间网络通讯的统一接口规范。
@@ -243,6 +241,27 @@ $ kubectl taint nodes --all node-role.kubernetes.io/master-
243241
![](./images/kubernetes-setup-completed.png)
244242
:::
245243
244+
## 调整NodePort范围<Badge text="可选" type="warning"/>
245+
246+
Kubernetes默认的NodePort范围为30000-32767,为了方便使用低端口,可能需要修改此范围,这需要调整Api-Server的启动参数,具体操作如下(如过是高可用部署,需要对每一个Master节点进行修改):
247+
248+
- 修改`/etc/kubernetes/manifests/kube-apiserver.yaml`文件,添加一个参数在`spec.containers.command`中增加一个参数`--service-node-port-range=1-32767`
249+
250+
- 重启Api-Server,现在Kubernetes基本都是以静态Pods模式部署,Api-Server是一个直接由kubelet控制的静态Pod,删除后它会自动重启:
251+
252+
```bash
253+
# 获得 apiserver 的 pod 名字
254+
export apiserver_pods=$(kubectl get pods --selector=component=kube-apiserver -n kube-system --output=jsonpath={.items..metadata.name})
255+
# 删除 apiserver 的 pod
256+
kubectl delete pod $apiserver_pods -n kube-system
257+
```
258+
259+
- 验证修改结果:可以在pod中看到该参数即可
260+
261+
```bash
262+
kubectl describe pod $apiserver_pods -n kube-system
263+
```
264+
246265
## 启用kubectl命令自动补全功能 <Badge text="可选" type="warning"/>
247266
248267
由于kubectl命令在后面十分常用,而且Kubernetes许多资源名称都带有随机字符,要手工照着敲很容易出错,强烈推荐启用命令自动补全的功能,这里仅以bash和笔者常用的zsh为例,如果您使用其他shell,需自行调整:

exploration/projects/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
- Mock.js支持的纯前端演示:[https://bookstore.icyfenix.cn](https://bookstore.icyfenix.cn)
1212
- Vue.js 2实现前端工程:[https://github.com/fenixsoft/fenix-bookstore-frontend](https://github.com/fenixsoft/fenix-bookstore-frontend)
1313
- 后端工程:
14-
- SpringBoot实现单体架构:[https://github.com/fenixsoft/monolithic_arch_springboot](https://github.com/fenixsoft/monolithic_arch_springboot)
15-
- SpringCloud实现微服务架构:[https://github.com/fenixsoft/microservice_arch_springcloud](https://github.com/fenixsoft/microservice_arch_springcloud)
16-
- Kubernetes为基础设施的微服务架构:https://github.com/fenixsoft/microservice_arch_kubernetes
17-
- Knative实现的无服务架构:https://github.com/fenixsoft/serverless_arch_knative
14+
- Spring Boot 实现单体架构:[https://github.com/fenixsoft/monolithic_arch_springboot](https://github.com/fenixsoft/monolithic_arch_springboot)
15+
- Spring Cloud 实现微服务架构:[https://github.com/fenixsoft/microservice_arch_springcloud](https://github.com/fenixsoft/microservice_arch_springcloud)
16+
- Kubernetes 为基础设施的微服务架构:[https://github.com/fenixsoft/microservice_arch_kubernetes](https://github.com/fenixsoft/microservice_arch_kubernetes)
17+
- Istio 为基础设施的服务网格架构:https://github.com/fenixsoft/servicemesh_arch_istio
18+
- 基于云端的无服务架构:https://github.com/fenixsoft/serverless_arch

exploration/projects/microservice_arch_istio.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)