技术向|利用 APISIX Ingress 实现 Istio 服务的安全暴露

本文详细介绍了如何利用Apache APISIX Ingress与Istio Service Mesh,将Kubernetes集群中的服务安全地暴露到集群外部。通过Kind创建本地集群,部署Istio和APISIX,结合BookInfo示例验证,展示了一种有效的服务暴露方案。同时提到了Kiali作为可视化工具辅助监控和管理流量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Service Mesh 简介

随着云原生技术的火热发展,Service Mesh 逐渐在微服务领域流行起来。当下 Service Mesh 比较流行的实现方案是 Istio和 Linkerd。

下图为 Service Mesh 示意图,通过引入 Sidecar Proxy 来完成微服务之间的互联及通信。

54b0db739416870e523215d6426ddd44.png

通过上图我们可以看出 Service Mesh 比较侧重传统意义上的东西向流量,即服务间的流量。当我们将 Service Mesh 与 Kubernetes 配合使用时,东西向流量对应的则是 Kubernetes 集群内的流量。

回到真实使用场景下,我们不会只接触到包含 Kubernetes 集群内的流量,大多数情况下都需要将一些服务暴露到集群外,供用户或其他服务使用。但将 Kubernetes 集群中的服务暴露到集群外时,我们就必须要考虑诸如安全性和可观测性等相关因素。

接下来我们将通过使用 Istio Service Mesh 和 Apache APISIX,为大家演示如何将启用 Service Mesh 的 Kubernetes 集群中服务安全暴露至集群外。

52d04145a07c1399f487e2cc465c8f90.png

第一步:准备 Kubernetes 集群

这里我们使用 Kind在本地创建一个临时集群用于演示。关于如何通过 Kind 命令进行安装可参考官方文档。

以下为用于创建演示集群所使用的 yaml 配置文件,将其保存为 kind-config.yaml

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker

然后使用此配置文件创建一个集群。

(MoeLove) ➜ kind create cluster --config kind-config.yaml 
Creating cluster "kind" ...
✓ Ensuring node image (kindest/node:v1.22.2) 🖼 
✓ Preparing nodes 📦 📦 📦 📦 
✓ Writing configuration 📜 
✓ Starting control-plane 🕹️ 
✓ Installing CNI 🔌 
✓ Installing StorageClass 💾 
✓ Joining worker nodes 🚜 
Set kubectl context to "kind-kind"
You can now use your cluster with:
kubectl cluster-info --context kind-kind
Not sure what to do next? 😅 Check out https://kind.sigs.k8s.io/docs/user/quick-start/

第二步:部署 Istio

在 Kubernetes 集群创建完毕后,我们来进行 Istio 的相关部署。

这里先创建一个名为 apisix-istio的目录,进入该目录后进行如下操作。

(MoeLove) ➜ mkdir apisix-istio
(MoeLove) ➜ cd apisix-istio
(MoeLove) ➜ curl -sL https://istio.io/downloadIstio | sh -
Downloading istio-1.12.1 from https://github.com/istio/istio/releases/download/1.12.1/istio-1.12.1-linux-amd64.tar.gz ...
Istio 1.12.1 Download Complete!
Istio has been successfully downloaded into the istio-1.12.1 folder on your system.
Next Steps:
See https://istio.io/latest/docs/setup/install/ to add Istio to your Kubernetes cluster.
To configure the istioctl client tool for your workstation,
add the /root/apisix-istio/istio-1.12.1/bin directory to your environment path variable with:
export PATH="$PATH:/root/apisix-istio/istio-1.12.1/bin"
Begin the Istio
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值