- 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.
推薦閱讀
- 機器學習實戰:基于Sophon平臺的機器學習理論與實踐
- 電氣自動化專業英語(第3版)
- 嵌入式系統應用
- Linux Mint System Administrator’s Beginner's Guide
- 樂高機器人EV3設計指南:創造者的搭建邏輯
- R Machine Learning By Example
- 輕松學Java
- MCSA Windows Server 2016 Certification Guide:Exam 70-741
- 離散事件系統建模與仿真
- 完全掌握AutoCAD 2008中文版:機械篇
- 悟透AutoCAD 2009案例自學手冊
- 寒江獨釣:Windows內核安全編程
- 智慧未來
- 計算機硬件技術基礎(第2版)
- Practical Network Automation