Istio的Ingress与Egress网关

本文介绍了Istio中的Ingress和Egress网关。Ingress作为前端应用的代理网格,负责将流量转发至后端的VirtualService。通过部署httpbin服务和创建Ingress Gateway及Virtual Service的实验,展示了Ingress的工作流程。同时,Egress网关用于管理集群内部服务流量出集群的控制,通过设置Service Entry和路由,确保流量通过Egress Gateway进行控制。
摘要由CSDN通过智能技术生成

一、认识Ingress
  在Istio的流量控制中,Ingress可以理解为前端应用的一个代理网格,当被转发到代理容器的流量到达服务前,会先经过该服务的Ingress Gateway,之后;再有Ingress Gateway转发至后端的VirtualService资源对象上。
  在这里插入图片描述

二、Ingress实验

1)部署httpbin服务

cat ../../samples/httpbin/httpbin.yaml 
# Copyright Istio Authors
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

##################################################################################################
# httpbin service
##################################################################################################
apiVersion: v1
kind: ServiceAccount
metadata:
  name: httpbin
---
apiVersion: v1
kind: Service
metadata:
  name: httpbin
  labels:
    app: httpbin
    service: httpbin
spec:
  ports:
  - name: http
    port: 8000
    targetPort: 80
  selector:
    app: httpbin
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpbin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: httpbin
      version: v1
  template:
    metadata:
      labels:
        app: httpbin
        version: v1
    spec:
      serviceAccountName: httpbin
      containers:
      - image: docker.io/kennethreitz/httpbin
        imagePullPolicy: IfNotPresent
        name: httpbin
        ports:
        - containerPort: 80

➜  kubectl apply -f ../../samples/httpbin/httpbin.yaml 
serviceaccount/httpbin created
service/httpbin created
deployment.apps/httpbin created

2)查看httpbin服务状态

➜  kubectl get pods -o wide | grep httpbin
httpbin-74fb669cc6-vn897          2/2     Running   0          4m15s   10.1.8.133   docker-desktop   <none>           <none>

➜  kubectl get rs -o wide | grep httpbin 
httpbin-74fb669cc6          1         1         1       7m5s   httpbin       docker.io/kennethreitz/httpbin                            app=httpbin,pod-template-hash=74fb669cc6,version=v1

➜  kubectl get deploy -o wide | grep httpbin 
httpbin          1/1     1            1           6m52s   httpbin       docker.io/kennethreitz/httpbin                            app=httpbin,version=v1

➜  kubectl get svc  httpbin 
NAME      TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
httpbin   ClusterIP   10.110.191.190   <none>        8000/TCP   12m

➜  kubectl describe svc httpbin         
Name:              httpbin
Namespace:         default
Labels:            app=httpbin
                   service=httpbin
Annotations:       <none>
Selector:          app=httpbin
Type:              ClusterIP
IP:                10.110.191.190
Port:              http  8000/TCP
TargetPort:        80/TCP
Endpoints:         10.1.8.133:80
Session Affinity:  None
Events:            <none>


➜  kubectl describe pods httpbin-74fb669cc6-vn897  
Name:         httpbin-74fb669cc6-vn897
Namespace:    default
Priority:     0
Node:         docker-desktop/192.168.65.4
Start Time:   Sat, 03 Jul 2021 17:23:17 +0800
Labels:       app=httpbin
              istio.io/rev=default
              pod-template-hash=74fb669cc6
              security.istio.io/tlsMode=istio
              service.istio.io/canonical-name=httpbin
              service.istio.io/canonical-revision=v1
              version=v1
Annotations:  kubectl.kubernetes.io/default-container: httpbin
              kubectl.kubernetes.io/default-logs-container: httpbin
              prometheus.io/path: /stats/prometheus
              prometheus.io/port: 15020
              prometheus.io/scrape: true
              sidecar.istio.io/status:
                {
   "initContainers":["istio-init"],"containers":["istio-proxy"]</
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值