- Getting Started with Kubernetes
- Jonathan Baier Jesse White
- 180字
- 2021-06-10 19:47:14
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.
推薦閱讀
- 大數(shù)據(jù)項(xiàng)目管理:從規(guī)劃到實(shí)現(xiàn)
- 蕩胸生層云:C語言開發(fā)修行實(shí)錄
- Java實(shí)用組件集
- 錯(cuò)覺:AI 如何通過數(shù)據(jù)挖掘誤導(dǎo)我們
- 并行數(shù)據(jù)挖掘及性能優(yōu)化:關(guān)聯(lián)規(guī)則與數(shù)據(jù)相關(guān)性分析
- Learning Apache Cassandra(Second Edition)
- Security Automation with Ansible 2
- 工業(yè)機(jī)器人入門實(shí)用教程(KUKA機(jī)器人)
- 水晶石精粹:3ds max & ZBrush三維數(shù)字靜幀藝術(shù)
- 21天學(xué)通C語言
- 精通數(shù)據(jù)科學(xué):從線性回歸到深度學(xué)習(xí)
- 基于人工免疫原理的檢測系統(tǒng)模型及其應(yīng)用
- 機(jī)器學(xué)習(xí)案例分析(基于Python語言)
- 中國戰(zhàn)略性新興產(chǎn)業(yè)研究與發(fā)展·數(shù)控系統(tǒng)
- 網(wǎng)絡(luò)安全概論