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]# 
相关推荐
xx~t25 分钟前
嵌入式学习——ARM1
linux·arm开发·嵌入式硬件·arm
xx~t27 分钟前
嵌入式——ARM1(详细篇)
linux·arm开发·嵌入式硬件·arm
orangapple1 小时前
在docker里启动 orthancteam/orthanc
docker
fengkai45452 小时前
八、Docker详解4-5
运维·docker
DYWorker0014 小时前
Linux驱动子系统:DMA-Buf —— Consumer和Provider(008)
linux·驱动开发
雯宝4 小时前
Linux 内核函数集
linux
GeW5 小时前
从挂科到高分通过:RHCE快速拿证的10个提分技巧
linux
鸠摩智首席音效师6 小时前
Linux /etc/nsswitch.conf 文件有什么作用 ?
linux
东城居士6 小时前
理解pinctrl和gpio子系统驱动
linux·嵌入式系统
H_oRIZoN_6 小时前
Linux入门DAY43 ARM 架构基础、寄存器、大小端、异常向量、交叉编译
linux·arm·linux应用编程