FLOWERS_WAN

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

ingress 调用istio ingress 控制器

清理环境

[root@k8s-master01 httpbin]#   kubectl delete -f httpbin-gateway1.yaml -n istio
gateway.networking.istio.io "httpbin-gateway" deleted
virtualservice.networking.istio.io "httpbin" deleted

[root@k8s-master01 httpbin]#
[root@k8s-master01 httpbin]# kubectl delete svc -n istio httpbin
service "httpbin" deleted
[root@k8s-master01 httpbin]# kubectl delete deploy -n istio httpbin
deployment.apps "httpbin" deleted
使用istio gateway ,而不是使用ingress,主要是因为可以使用istio提供的所有功能,比如丰富的流量管理和安全的功能。

 

 

部署服务

[root@k8s-master01 httpbin]# kubectl apply -f httpbin.yaml -n istio
serviceaccount/httpbin created
service/httpbin created
deployment.apps/httpbin created

确定ingress的IP和端口号

[root@k8s-master01 httpbin]#  export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o js
onpath='{.status.loadBalancer.ingress[0].ip}')[root@k8s-master01 httpbin]# export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jso
npath='{.spec.ports[?(@.name=="http2")].port}')[root@k8s-master01 httpbin]# export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway
 -o jsonpath='{.spec.ports[?(@.name=="https")].port}')[root@k8s-master01 httpbin]#
[root@k8s-master01 httpbin]#
[root@k8s-master01 httpbin]#
[root@k8s-master01 httpbin]# echo $INGRESS_HOST
192.168.30.240
[root@k8s-master01 httpbin]# echo $INGRESS_PORT
80
[root@k8s-master01 httpbin]# echo $SECURE_INGRESS_PORT
443

使用ingres资源配置ingress

kubernetes ingress 资源暴露http 和 https 的资源给外部集群的外部。让外部来访问。

 

1. 创建istio gateway 

[root@k8s-master01 httpbin]# vim istio-ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/ingress.class: istio
spec:
  rules:
  - host: httpbin.example.com
    http:
      paths:
      - path: /status/.*
        backend:
          serviceName: httpbin
          servicePort: 8000

 

posted on   FLOWERS_WAN  阅读(62)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具
· Manus的开源复刻OpenManus初探
点击右上角即可分享
微信分享提示