官术网_书友最值得收藏!

Multiple ports

Another custom port use case is that of multiple ports. Many applications expose multiple ports, such as HTTP on port 80 and port 8888 for web servers. The following example shows our app responding on both ports. Once again, we'll also need to add a firewall rule for this port, as we did for the list nodejs-service-nodeport.yaml previously. Save the listing as nodejs-multi-controller.yaml and nodejs-multi-service.yaml:

apiVersion: v1 
kind: ReplicationController
metadata:
name: node-js-multi
labels:
name: node-js-multi
spec:
replicas: 3
selector:
name: node-js-multi
template:
metadata:
labels:
name: node-js-multi
spec:
      containers: 
- name: node-js-multi
image: jonbaier/node-express-multi:latest
ports:
- containerPort: 80
- containerPort: 8888
apiVersion: v1 
kind: Service
metadata:
name: node-js-multi
labels:
name: node-js-multi
spec:
type: LoadBalancer
ports:
- name: http
protocol: TCP
port: 80
- name: fake-admin-http
protocol: TCP
port: 8888
selector:
name: node-js-multi
The application and container itself must be listening on both ports for this to work. In this example, port 8888 is used to represent a fake admin interface. If, for example, you want to listen on port 443, you would need a proper SSL socket listening on the server.
主站蜘蛛池模板: 科尔| 滦南县| 泰兴市| 九龙坡区| 安康市| 万源市| 宣恩县| 西乌珠穆沁旗| 石狮市| 会宁县| 徐闻县| 安平县| 康定县| 南皮县| 全州县| 乳源| 铜山县| 博白县| 通化市| 武威市| 韩城市| 宝应县| 蓬溪县| 桑日县| 瑞昌市| 浑源县| 睢宁县| 博白县| 平武县| 淮南市| 宜兴市| 内乡县| 桐柏县| 新巴尔虎右旗| 河源市| 宁河县| 吉安市| 南漳县| 平阳县| 民和| 贺兰县|