NodePort:固定端口

NodePort:固定端口

复制代码
## **************************************************
#  测试固定端口
#
## *************************************************
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kevin-fixed-port
  namespace: default
spec:
  # 副本数量
  #replicas: 3
  selector:
    matchLabels:
      app: kevin-fixed-port
  template:
    metadata:
      labels:
        app: kevin-fixed-port
    spec:
      imagePullSecrets:
      - name: kevin-registry-secret
      containers:
      - name: nginx-fixed-port
        image: 192.168.81.141:45678/library/nginx:20240725
        # 存活检查
        livenessProbe:
          httpGet:
            path: /index.html
            port: 80
          initialDelaySeconds: 5
          periodSeconds: 10
        # 就绪检查
        readinessProbe:
          httpGet:
            path: /index.html
            port: 80
          initialDelaySeconds: 6
          periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
  name: kevin-fixed-port
  namespace: default
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
    nodePort: 30901
  selector:
    app: kevin-fixed-port
  type: NodePort
  • 查看pod的情况
shell 复制代码
[root@k8s-master kevin]# kubectl get pod -A -o wide | grep 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]# kubectl get svc | grep kevin
kevin-fixed-port   NodePort    10.109.217.157   <none>        80:30901/TCP   26m
[root@k8s-master kevin]# 
[root@k8s-master kevin]# curl 10.109.217.157
<!DOCTYPE html>
<html>
.....................................
</html>
[root@k8s-master kevin]# 
相关推荐
讨厌下雨的天空6 分钟前
Linux信号
linux·运维·c++
赖small强22 分钟前
【Linux C/C++开发】第26章:系统级综合项目理论
linux·c语言·c++
SCandL15235 分钟前
安全上下文的修改实验
linux
qq_54702617937 分钟前
Docker 搭建单节点MySQL服务
mysql·adb·docker
ragnwang39 分钟前
Ubuntu /home 分区安全扩容教程
linux·运维·ubuntu
Azure++1 小时前
Centos安装clickhouse
linux·clickhouse·centos
濊繵1 小时前
Linux网络--应用层自定义协议与序列化
linux·服务器·网络
Yuriey1 小时前
K8s部署实践-基于Debian13(Trixie)
云原生·容器·kubernetes
潇凝子潇2 小时前
Linux 服务器实时监控Shell 脚本
linux·服务器·chrome
顾安r2 小时前
11.21 脚本 网页优化
linux·前端·javascript·算法·html