NodePort:固定端口
## **************************************************
# 测试固定端口
#
## *************************************************
apiVersion: apps/v1
kind: Deployment
metadata:name: kevin-fixed-portnamespace: default
spec:# 副本数量#replicas: 3selector:matchLabels:app: kevin-fixed-porttemplate:metadata:labels:app: kevin-fixed-portspec:imagePullSecrets:- name: kevin-registry-secretcontainers:- name: nginx-fixed-portimage: 192.168.81.141:45678/library/nginx:20240725# 存活检查livenessProbe:httpGet:path: /index.htmlport: 80initialDelaySeconds: 5periodSeconds: 10# 就绪检查readinessProbe:httpGet:path: /index.htmlport: 80initialDelaySeconds: 6periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:name: kevin-fixed-portnamespace: default
spec:ports:- port: 80protocol: TCPtargetPort: 80nodePort: 30901selector:app: kevin-fixed-porttype: NodePort
[ root@k8s-master kevin]
default kevin-fixed-port-848d95cf86-5f6jp 1 /1 Running 0 21m 10.244 .58.209 k8s-node02 < none> < none>
default kevin-fixed-port-848d95cf86-wt5bh 1 /1 Running 0 21m 10.244 .235.226 k8s-master < none> < none>
default kevin-fixed-port-848d95cf86-xs6xl 1 /1 Running 0 21m 10.244 .58.208 k8s-node02 < none> < none>
[ root@k8s-master kevin]
[ root@k8s-master kevin]
kevin-fixed-port NodePort 10.109 .217.157 < none> 80 :30901/TCP 26m
[ root@k8s-master kevin]
[ root@k8s-master kevin]
< ! DOCTYPE html>
< html>
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .
< /html>
[ root@k8s-master kevin]