026.掌握Service-外部访问
一 集群外部访问
1.1 外部访问——映射Pod到物理机
1 apiVersion: v1
2 kind: Pod
3 metadata:
4 name: webapp
5 labels:
6 app: webapp
7 spec:
8 containers:
9 - name: webapp
10 image: tomcat
11 ports:
12 - containerPort: 8080
13 hostPort: 8081
1 apiVersion: v1
2 kind: Pod
3 metadata:
4 name: webapp2
5 labels:
6 app: webapp2
7 spec:
8 hostNetwork: true
9 containers:
10 - name: webapp2
11 image: tomcat
12 ports:
13 - containerPort: 8080
14 hostPort: 8080
1.2 外部访问——映射Service到物理机
1 apiVersion: v1
2 kind: Service
3 metadata:
4 name: webapp
5 spec:
6 type: NodePort
7 ports:
8 - port: 8080
9 targetPort: 8080
10 nodePort: 8081
11 selector:
12 app: webapp
1 ExecStart=/opt/k8s/bin/kube-apiserver \
2 ……
3 --service-node-port-range=1-65535 \ #添加此参数
4 ……
1 apiVersion: v1
2 kind: Service
3 metadata:
4 name: my-service
5 spec:
6 type: LoadBalancer
7 selector:
8 app: MyApp
9 ports:
10 - protocol: TCP
11 port: 80
12 targetPort: 9376
13 nodePort: 30061
14 clusterIP: 10.0.171.239
15 status:
16 loadBalancer:
17 ingress:
18 - ip: 47.96.145.131

026.掌握Service-外部访问的更多相关文章
- 【Kubernetes】Kubernetes的Service外部访问方式:NodePort和LoadBalancer
Kubernetes的Pod的寿命是有限的,它们不会复活,因此尽管每个Pod都有自己的IP地址,但是这些IP地址是不可靠的,会随着Pod的消亡而消失. 这就带来一个问题,如果一些Pod的集合(称之为b ...
- 【Azure微服务 Service Fabric 】Service Fabric中应用开启外部访问端口及微服务之间通过反向代理端口访问问题
问题描述 1) 当成功的在Service Fabric集群中部署了应用后,如何来访问呢?如果是一个Web服务,它的URL又是什么呢? 2) 当Service Fabric集群中,服务之间如需要相互访问 ...
- ubuntu系统lamp环境搭建、数据库迁移、设置数据库外部访问
sudo passwd root设置两次密码su输入设置的密码exit (退出root帐号) 1.sudo apt-get update 2.sudo apt-get install apache2 ...
- centos 下安装jdk、tomcat 以及tomcat无法从外部访问的解决办法
centos 下安装jdk.tomcat 以及tomcat无法从外部访问的解决办法 原创 2014年08月28日 10:24:33 标签: selinux enforce cent 2223 昨天在c ...
- 解决CentOS7安装Tomcat不能被外部访问的问题
在CentOS7安装了Tomcat,在服务器内部使用火狐浏览器通过localhost:8080是可以访问的,但是不能被外部访问,主要原因是因为防火墙的存在,导致端口不能被访问.CentOS是使用fir ...
- Kubernetes的三种外部访问方式:NodePort、LoadBalancer和Ingress(转发)
原文 http://cloud.51cto.com/art/201804/570386.htm Kubernetes的三种外部访问方式:NodePort.LoadBalancer和Ingress 最近 ...
- [转帖] 外部访问k8s 里面pod的方式方法
https://jimmysong.io/posts/accessing-kubernetes-pods-from-outside-of-the-cluster/ 从外部访问Kubernetes中的P ...
- 通过NAT实例实现外部访问AWS的ElastiCache资源
ElastiCache作为AWS的内存缓存组建可以说做的一点也不友好了, 你可以通过ElastiCache创建redis,memcache的实例,却不能被外部访问. 背景 人傻钱多的客户总有人傻钱多的 ...
- 【转载】浅析从外部访问 Kubernetes 集群中应用的几种方式
一般情况下,Kubernetes 的 Cluster Network 是属于私有网络,只能在 Cluster Network 内部才能访问部署的应用.那么如何才能将 Kubernetes 集群中的应用 ...
随机推荐
- F5 BIG-IP之二 LTM实验一
- 吴裕雄--天生自然 Hadoop大数据分布式处理:关闭CenterOS 7防火墙
使用命令:systemctl status firewalld.service 查看防火墙状态 执行后可以看到绿色字样标注的“active(running)”,说明防火墙是开启状态 使用命令:syst ...
- ospf实验二
R1,R2,R3为17.1.1.0网段 1. R4先做rip #rip 1 #version 2 #undo sum.. #netwokr 14.0.0.0 实验第四条 标记tag 100 在R4上做 ...
- [LC] 169. Majority Element
Given an array of size n, find the majority element. The majority element is the element that appear ...
- Nginx笔记总结十三:sub_filter内容替换
Nginx变异安装加上参数 --with-http_sub_module 配置文件: location ~* ^/portalproxy/([-]*)/portal(.*)$ { #sub_filte ...
- CORS’s source, Principle and Implementation
跨域资源共享(CORS) 是一种机制,它使用额外的 HTTP 头来告诉浏览器 让运行在一个 origin (domain) 上的Web应用被准许访问来自不同源服务器上的指定的资源.当一个资源从与该资源 ...
- c++入门资源
http://www.cnblogs.com/jackyyang7/articles/2479482.htmlvs2010编译器的使用 https://www.cnblogs.com/me115/ar ...
- Java Timer和TimerTask
Timer是JDK中提供的一个定时器工具,使用的时候会在主线程之外起一个单独的线程执行指定的任务,可以指定一次或多次. TimerTask是一个实现了Runnable接口的抽象类,代表一个可被执行的任 ...
- tips [ 18870 ]
Created at 2017-08-23 Updated at 2018-01-31 Category 东方大陆 Tag 东方大陆 上面有编辑时间的,别吐槽说什么过期内容了使用 lightPIC图床 ...
- e代驾狂野裁员 O2O逐渐恢复理智?
O2O逐渐恢复理智?" title="e代驾狂野裁员 O2O逐渐恢复理智?"> 近段时间以来,O2O行业堪称"哀鸿遍野",十分凄惨.巨头 ...