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]# 
相关推荐
sunoo-2296 分钟前
【Linux 系统编程】学习第七天:线程属性 | 互斥锁 | 死锁 | 信号量 核心知识点 + 踩坑实战
linux·c语言·笔记·vscode·学习
请你吃div13 分钟前
Node 后端项目 Docker 自动部署教程(GitHub + 宝塔 + Self-hosted Runner)
后端·docker·node.js
小雪崩17 分钟前
嵌入式学习 day33:线程进阶
linux·c语言·学习
牢姐与蒯27 分钟前
Linux进程(四).进程优先级以及进程切换,进程调度
linux·运维·服务器·ubuntu
大爱编程♡36 分钟前
Linux C 语言文件 IO 与构建工具实战指南
linux·服务器
qq_349447951 小时前
K8S Helm安装
云原生·容器·kubernetes
百年੭ ᐕ)੭*⁾⁾1 小时前
Redash部署指南(Windows docker部署)
大数据·windows·docker·数据可视化·redash
tangyal1 小时前
kubernetes(k8s)基础理论与集群部署
kubernetes·k8s·部署·node·理论·pod·集群cluster
Linux运维技术栈1 小时前
深度拆解 Linux logrotate 重复切割问题:根因、排查与生产级根治方案
linux·logrotate
2401_834636992 小时前
Docker 容器化技术全解:从镜像构建到容器编排的完整教案2
运维·docker·容器