k8s v1.35配置gateway, istio通过metalb vip访问

K8S V1.35新版已经不支持ingress了,所以要用istio代替。本文记录安装设置过程,供大家参考学习。

安装istio

  1. 下载
    从https://github.com/istio/istio/releases 下载并解压
  2. 安装
    执行命令
sh 复制代码
./bin/istioctl install --set profile=default -y

Gateway api 安装

sh 复制代码
kubectl apply --server-side -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.4.1/standard-install.yaml

部署应用

yaml 复制代码
---
# 1.业务service
apiVersion: v1
kind: Service
metadata:
 name: tmp-gateway-service
 namespace: irmp-prod
spec:
 ports:
   - port: 8080
     targetPort: 8080
 selector:
   app: tmp-gateway
 type: ClusterIP

# 2. Gateway - 让 Istio 自动创建 Service
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
 name: tmp-gateway-gw
 namespace: irmp-prod
spec:
 gatewayClassName: istio
 listeners:
   - name: default
     hostname: "*.irmp.com"
     port: 80
     protocol: HTTP
     allowedRoutes:
       namespaces:
         from: All
---
# 3. HTTPRoute
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
 name: gw-httproute
 namespace: irmp-prod
spec:
 parentRefs:
   - name: tmp-gateway-gw
 hostnames:
   - "gw.irmp.com"
 rules:
   - matches:
       - path:
           type: PathPrefix
           value: /
     backendRefs:
       - name: tmp-gateway-service
         port: 8080

Gateway部署之后,它会自动安装一个tmp-gateway-gw-istio的Service,可以查看这个service的VIP,通过VIP可以访问你的服务了:

sh 复制代码
 export GW_IP=$(kubectl get svc tmp-gateway-gw-istio -n irmp-prod -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
 echo ${GW_IP}
 curl -H "Host: gw.irmp.com" http://${GW_IP}/
相关推荐
谢亮_vipxieliang18 小时前
Kubernetes 的“操作系统化”:从容器编排到 AI 基础设施控制平面
人工智能·平面·kubernetes
Raas10019 小时前
MAI Gateway(魔芋企业级AI网关)能力解析:AI网关能做故障转移吗?AI网关核心功能详解
大数据·人工智能·网关·ai·gateway·mai gateway
sbjdhjd21 小时前
云安全 | Docker 容器逃逸复盘(三):docker.sock 挂载与 Docker-in-Docker 风险
经验分享·网络安全·docker·云原生·容器·kubernetes·云安全
热爱Liunx的丘丘人21 小时前
1、什么是K8s
云原生·容器·kubernetes
流烟默1 天前
网关 Sentinel 限流实战:API 分组、规则加载与全量匹配踩坑记
nacos·gateway·sentinel·流控规则
Joy T1 天前
从 Nginx 到 Gateway 再到微服务:一次 AI 请求的完整链路
nginx·微服务·gateway·controller·路由转发·ai service·接口错误排查
小匠石钧知1 天前
07_在k8s集群中安装ingress-nginx
nginx·容器·kubernetes·ingress
Thomas.Sir1 天前
第19课:Gateway过滤器、全局拦截、请求响应统一处理
spring cloud·gateway
谢亮_vipxieliang2 天前
Kubernetes 1.36 深度解读:从 kubelet 安全到 GPU 原生调度的 70 项改进
安全·kubernetes·kubelet
wzq11_6662 天前
kubernetes集群——灰度发布
云原生·容器·kubernetes