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]# 
相关推荐
m0_694845576 分钟前
服务器怎么跑Python项目?
linux·运维·服务器·python·云计算
开开心心就好1 小时前
AI抠图软件,本地运行超快速
网络·人工智能·网络协议·tcp/ip·docker·电脑·excel
Linux运维技术栈1 小时前
CentOS 7 升级系统内核级库 glibc 2.40 完整教程
linux·运维·centos·glibc·系统内核
刘延林.1 小时前
树莓派5-ollama-linux-arm64.tgz 下载
linux·运维·服务器
麟城Lincoln2 小时前
【Linux-云原生-笔记】Apache相关
linux·笔记·云原生·apache·webserver
ZZZKKKRTSAE2 小时前
玩转rhel9 Apache
linux·运维·服务器·apache·web
Z_zz_Z___3 小时前
DNS协议解析过程
linux·服务器·网络
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ3 小时前
Linux 下使用 vim 文本编辑器时的操作指令
linux·运维·vim
百锦再3 小时前
Rider 全面解析:跨平台 .NET IDE 的核心技术与高效实践指南
linux·ide·.net·sdk·core·rider
IT成长日记4 小时前
【Docker基础】Dockerfile指令速览:文件与目录操作指令详解
docker·容器·volume·add·dockerfile·workdir