Istio-0.8.0在Minikube环境中快速启动Bookinfo示例

简介:

Istio-0.8.0在Minikube环境中快速启动Bookinfo示例

之前发表了从零开始应用Istio--入门示例,使用的istio版本比较低,在0.8.0版本下发现很多命令不一样了,所以总结一下,重新跑一下Bookinfo.

一. 安装Minikube环境

使用Minikube的本地实验环境, 系统为centos7.0, 国内环境安装可以参考https://yq.aliyun.com/articles/221687

安装VirtualBox

VirtualBox

安装kubectl

可参考官网提供的安装说明,Install kubectl binary via curl

通过命令安装:

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl

如果安装失败,或者无法访问可以直接下载

https://storage.googleapis.com/kubernetes-release/release/v1.11.1/bin/linux/amd64/kubectl

然后执行

chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

安装Minikube

参考Minikube - Kubernetes本地实验环境 使用阿里提供的Minikube版本, 我这里使用Kubernetes 1.10 release的版本

curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v0.28.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

启动

 minikube start \
    --registry-mirror=https://registry.docker-cn.com \
    --extra-config=controller-manager.cluster-signing-cert-file="/var/lib/localkube/certs/ca.crt" \
    --extra-config=controller-manager.cluster-signing-key-file="/var/lib/localkube/certs/ca.key" \
    --extra-config=apiserver.admission-control="NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota" \
    --kubernetes-version=v1.10.0

二. 安装istio

可以参考官网Quick Start

获取Istio release , 我本地使用的为0.8.0版本

$ curl -L https://git.io/getLatestIstio | sh -
或者在GitHub下载所需版本

进入istio目录

cd istio-0.8.0

添加istioctl 到PATH

export PATH=$PWD/bin:$PATH

安装, 这里为了方便安装了不带TLS的版本

$ kubectl apply -f install/kubernetes/istio-demo.yaml

查看是否安装正常,看istio-pilot, istio-ingressgateway, istio-policy, istio-telemetry, prometheus, 以及可选的istio-sidecar-injector服务是否部署

kubectl get svc -n istio-system

NAME                       TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                               AGE
istio-citadel              ClusterIP      10.110.18.88     <none>        8060/TCP,9093/TCP                                                     16h
istio-egressgateway        ClusterIP      10.105.97.56     <none>        80/TCP,443/TCP                                                        16h
istio-ingressgateway       LoadBalancer   10.109.76.80     <pending>     80:31380/TCP,443:31390/TCP,31400:31400/TCP                            16h
istio-pilot                ClusterIP      10.108.201.57    <none>        15003/TCP,15005/TCP,15007/TCP,15010/TCP,15011/TCP,8080/TCP,9093/TCP   16h
istio-policy               ClusterIP      10.100.249.185   <none>        9091/TCP,15004/TCP,9093/TCP                                           16h
istio-sidecar-injector     ClusterIP      10.110.68.171    <none>        443/TCP                                                               16h
istio-statsd-prom-bridge   ClusterIP      10.100.113.133   <none>        9102/TCP,9125/UDP                                                     16h
istio-telemetry            ClusterIP      10.109.5.24      <none>        9091/TCP,15004/TCP,9093/TCP,42422/TCP                                 16h
prometheus                 ClusterIP      10.99.110.28     <none>        9090/TCP

查看pods

kubectl get pods -n istio-system

NAME                                       READY     STATUS      RESTARTS   AGE
istio-citadel-dcb7955f6-vdcjk              1/1       Running     0          11h
istio-egressgateway-56b7758b44-l5fm5       1/1       Running     0          11h
istio-ingressgateway-56cfddbd5b-xbdcx      1/1       Running     0          11h
istio-pilot-cbd6bfd97-wgw9b                2/2       Running     0          11h
istio-policy-699fbb45cf-bc44r              2/2       Running     0          11h
istio-statsd-prom-bridge-949999c4c-nws5j   1/1       Running     0          11h
istio-telemetry-55b675d8c-kfvvj            2/2       Running     0          11h
prometheus-86cb6dd77c-5j48h                1/1       Running     0          11h

这样istio就安装完成了

注:
    如果没有安装Istio-sidecar-injector, 那么在部署应用时需要手动的注入Envoy,
    命令如下:
    kubectl create -f <(istioctl kube-inject -f <your-app-spec>.yaml)

(*)卸载

如果实验完成后不在需要Istio环境可以使用如下命令卸载Istio

$ kubectl delete -f install/kubernetes/istio-demo.yaml

三. 部署Bookinfo应用

使用如下命令安装应用容器,这会花费一点时间

kubectl apply -f samples/bookinfo/kube/bookinfo.yaml

为应用定义ingress网关

istioctl create -f samples/bookinfo/routing/bookinfo-gateway.yaml

查看所有的服务都处在运行(Running)状态

kubectl get services

NAME                       CLUSTER-IP   EXTERNAL-IP   PORT(S)              AGE
details                    10.0.0.31    <none>        9080/TCP             6m
kubernetes                 10.0.0.1     <none>        443/TCP              7d
productpage                10.0.0.120   <none>        9080/TCP             6m
ratings                    10.0.0.15    <none>        9080/TCP             6m
reviews                    10.0.0.170   <none>        9080/TCP             6m

查看pods

kubectl get pods

NAME                                        READY     STATUS    RESTARTS   AGE
details-v1-1520924117-48z17                 2/2       Running   0          6m
productpage-v1-560495357-jk1lz              2/2       Running   0          6m
ratings-v1-734492171-rnr5l                  2/2       Running   0          6m
reviews-v1-874083890-f0qf0                  2/2       Running   0          6m
reviews-v2-1343845940-b34q5                 2/2       Running   0          6m
reviews-v3-1813607990-8ch52                 2/2       Running   0          6m

使用ngress的IP 和 port访问应用

这里主要介绍Minikube方式,如果是其他环境请参考Determining the ingress IP and ports

执行
kubectl get svc istio-ingressgateway -n istio-system

NAME                   TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)                                      AGE
istio-ingressgateway   LoadBalancer   10.109.76.80   <pending>     80:31380/TCP,443:31390/TCP,31400:31400/TCP   16h

此处EXTERNAL-IP 的值为<pending> 在这种情况下可以通过服务的node port访问gateway

获取访问端口

export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http")].nodePort}')

Minikube环境下获取访问IP

export INGRESS_HOST=$(minikube ip)

Set GATEWAY_URL:

export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT

访问

curl -o /dev/null -s -w "%{http_code}\n" http://${GATEWAY_URL}/productpage

结果 200

如果Minikube 的IP本地可以访问,可以用浏览器打开http://$GATEWAY_URL/productpage访问Bookinfo的web页面.

Cleanup Bookinfo

删除路由,终止应用pods

samples/bookinfo/kube/cleanup.sh

确认是否关闭

istioctl get gateway           #-- there should be no more gateway
istioctl get virtualservices   #-- there should be no more virtual services
kubectl get pods               #-- the Bookinfo pods should be deleted
相关实践学习
深入解析Docker容器化技术
Docker是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化,容器是完全使用沙箱机制,相互之间不会有任何接口。Docker是世界领先的软件容器平台。开发人员利用Docker可以消除协作编码时“在我的机器上可正常工作”的问题。运维人员利用Docker可以在隔离容器中并行运行和管理应用,获得更好的计算密度。企业利用Docker可以构建敏捷的软件交付管道,以更快的速度、更高的安全性和可靠的信誉为Linux和Windows Server应用发布新功能。 在本套课程中,我们将全面的讲解Docker技术栈,从环境安装到容器、镜像操作以及生产环境如何部署开发的微服务应用。本课程由黑马程序员提供。 &nbsp; &nbsp; 相关的阿里云产品:容器服务 ACK 容器服务 Kubernetes 版(简称 ACK)提供高性能可伸缩的容器应用管理能力,支持企业级容器化应用的全生命周期管理。整合阿里云虚拟化、存储、网络和安全能力,打造云端最佳容器化应用运行环境。 了解产品详情: https://www.aliyun.com/product/kubernetes
目录
相关文章
|
Kubernetes 监控 容器
Istio安装及Bookinfo环境部署
文章详细介绍了如何在Kubernetes集群上安装和配置Istio服务网格,并通过部署Bookinfo示例应用来演示Istio的核心功能,如流量管理、服务监控和故障注入等。
573 2
Istio安装及Bookinfo环境部署
|
数据采集 算法 网络协议
基于istio的流量镜像构建真实流量的staging环境
istio 作为一个强大的服务网格工具,除了常见的熔断,限流,故障注入,A/B发布之外还可以用来做流量镜像(traffic mirror)的任务,流量镜像对于调试,测试和数据采集都是非常重要的,这里介绍基于istio的流量镜像构建staging环境。
2590 0
基于istio的流量镜像构建真实流量的staging环境
|
Kubernetes Cloud Native 安全
k8s 上 go 微服务实战: go 实现 istio bookinfo 微服务
在完成 `k8s 上快速部署 go 服务` 和 `k8s: istio 入门` 后, 继续 **膨胀**, 使用 go 来实现 istio 提供的 bookinfo 微服务 demo
919 0
|
Dubbo Java 应用服务中间件
开源微服务如何选型?Spring Cloud、Dubbo、gRPC、Istio 详细对比
开源微服务如何选型?Spring Cloud、Dubbo、gRPC、Istio 详细对比
2193 124
|
开发框架 Dubbo Cloud Native
带你读《Apache Dubbo微服务开发从入门到精通》——四、 与gRPC、Spring Cloud、Istio的关系
带你读《Apache Dubbo微服务开发从入门到精通》——四、 与gRPC、Spring Cloud、Istio的关系
736 98
|
Kubernetes 安全 微服务
使用 Istio 缓解电信 5G IoT 微服务 Pod 架构的安全挑战
在5G电信领域,Kubernetes集群中部署微服务至关重要,但也带来了重大的安全挑战。Istio作为一个强大的开源服务网格,能有效地管理这些微服务间的通信,通过其控制平面自动将Sidecar代理注入到各微服务Pod中,确保了安全且高效的通信。Istio的架构由数据平面和控制平面组成,其中Sidecar代理作为Envoy代理运行在每个Pod中,拦截并管理网络流量。此外,Istio支持多种Kubernetes发行版和服务,如EKS等,不仅增强了安全性,还提高了应用性能和可观测性。
540 2
使用 Istio 缓解电信 5G IoT 微服务 Pod 架构的安全挑战
|
Kubernetes 前端开发 Dubbo
Spring Boot+gRPC构建微服务并部署到Istio(详细教程)
Spring Boot+gRPC构建微服务并部署到Istio(详细教程)
|
监控 安全 Cloud Native
云原生安全:Istio在微服务架构中的安全策略与实践
【10月更文挑战第26天】随着云计算的发展,云原生架构成为企业数字化转型的关键。微服务作为其核心组件,虽具备灵活性和可扩展性,但也带来安全挑战。Istio作为开源服务网格,通过双向TLS加密、细粒度访问控制和强大的审计监控功能,有效保障微服务间的通信安全,成为云原生安全的重要工具。
484 2
|
Kubernetes 安全 微服务
使用 Istio 缓解电信 5G IoT 微服务 Pod 架构的安全挑战
使用 Istio 缓解电信 5G IoT 微服务 Pod 架构的安全挑战
724 8
|
Kubernetes 负载均衡 安全
Istio在微服务中释放服务网格的力量
Istio在微服务中释放服务网格的力量
612 4