You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
➜ kubectl create -f nginx-controller.yaml
➜ kubectl get deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-deployment 3 3 3 3 10m
➜ kubectl get pod
nginx-deployment-1969926507-cs4xb 1/1 Running 0 11m
nginx-deployment-1969926507-dc8nh 1/1 Running 0 11m
nginx-deployment-1969926507-nmtxp 1/1 Running 0 11m
➜ kubectl create -f nginx-service.yaml
➜ kubectl get service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-service 10.0.0.104 <nodes> 80:30001/TCP 9m
备注: 这里的 80:30001, 对应的是:service端口:主机Node端口
验证
➜ minikube ip
192.168.99.100
➜ test curl 192.168.99.100:30001
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
目标
使用Minikube,在Kubernetes上搭建一个Nginx集群(3个节点)
备注:对于如何安装环境,请点击这里
开发环境
yaml配置文件
创建 nginx-controller.yaml
创建 nginx-service.yaml
创建步骤
备注: 这里的
80:30001
, 对应的是:service端口:主机Node端口
验证
网络拓扑图
网络映射关系:
主机Node-192.168.99.100:30001 <----> Service-10.0.0.104:80 <----> Deployment(3个Pod)-(端口:80; Label:
name: nginx
)Service 通过 Label Select 找到 “name: nginx” 标签的Pod,通过内部的iptables进行路由映射,映射到对应Pod的80端口。
The text was updated successfully, but these errors were encountered: