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]# 
相关推荐
南棱笑笑生5 小时前
20251217给飞凌OK3588-C开发板适配Rockchip原厂的Buildroot【linux-5.10】后调通ov5645【只能预览】
linux·c语言·开发语言·rockchip
Sleepy MargulisItG6 小时前
【Linux网络编程】应用层协议:HTTP协议
linux·服务器·网络·http
G31135422736 小时前
Linux 内核设计中的核心思想与架构原则
linux·架构·php
zhuzewennamoamtf6 小时前
Linux内核platform抽象、数据结构、内核匹配机制
linux·运维·数据结构
运维栈记7 小时前
如何排错运行在Kubernetes集群中的服务?
云原生·容器·kubernetes
Kira Skyler8 小时前
ELF文件解析 elf.o 文件主要内容.md
linux
Linux编程用C8 小时前
Docker+Vscode搭建(本地/远程)开发环境
vscode·后端·docker
逐梦吧!旅行者8 小时前
Linux MySQL 5.7用户管理与用户密码的设置问题
linux·mysql
RisunJan8 小时前
Linux命令-grpck命令(验证和修复组配置文件(`/etc/group` 和 `/etc/gshadow`)完整性的工具)
linux·运维·服务器
loosed9 小时前
Ubuntu mysql8 tar.xz 安装
linux·ubuntu·adb