[英]Kubernetes Istio Gateway & VirtualService Config Flask Example
I try to get some hands on experience with K8s & istio.我尝试获得一些 K8s 和 istio 的实践经验。 I am using minikube and I try to deploy a dummy flask web-app.
我正在使用 minikube,我尝试部署一个虚拟 flask 网络应用程序。 However, for some reason I do not manage to get the istio routing working.
但是,出于某种原因,我无法使 istio 路由正常工作。
Eg例如
curl -v -H 'Host: hello.com' 'http://127.0.0.1/' --> 503 Service Unavailable
Do you see any issue in my specs?你在我的规格中看到任何问题吗?
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: flask-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "hello.com"
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: flaskvirtualservice
spec:
hosts:
- "hello.com"
gateways:
- flask-gateway
http:
- route:
- destination:
host: flask.default.svc.cluster.local
port:
number: 5000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: flask
labels:
app: flask
spec:
replicas: 1
selector:
matchLabels:
app: flask
template:
metadata:
labels:
app: flask
spec:
containers:
- name: flask
image: digitalocean/flask-helloworld
ports:
- containerPort: 5000
---
apiVersion: v1
kind: Service
metadata:
name: flask-service
spec:
selector:
app.kubernetes.io/name: flask
ports:
- name: name-of-service-port
protocol: TCP
port: 80
targetPort: 5000
Thanks for your support here!在此感谢您的支持!
Cheers干杯
EDIT:编辑:
here the updated service definition这里是更新的服务定义
apiVersion: v1
kind: Service
metadata:
name: flask
labels:
app: flask
service: flask
spec:
ports:
- port: 5000
name: http
selector:
app: flask
I would suggest you look at this sample from the istio repo:我建议您查看 istio 存储库中的示例:
https://github.com/istio/istio/tree/master/samples/helloworld https://github.com/istio/istio/tree/master/samples/helloworld
This helloworld
app is a flask app and you can find the python source code in src
这个
helloworld
app是一个flask的app,你可以在src
中找到python的源代码
In your yaml you do not have ---
between your Gateway
and VirtualService
.在您的 yaml 中,您的
Gateway
和VirtualService
之间没有---
。
You also don't make mention of DNS
IE you need to make sure that the box you are running curl
on has the ability to resolve your domain hello.com
to the istio service ip. Since you are using minikube you could add an entry to your OS hosts file.您也没有提及
DNS
IE,您需要确保运行curl
的设备能够将您的域hello.com
解析为 istio 服务 ip。由于您使用的是 minikube,因此您可以添加一个条目到您的操作系统主机文件。
It has the ability to send requests to it, IE if you are outside the cluster you need an external ip or do something with kubectl port-forward...
它有能力向它发送请求,IE,如果你在集群之外,你需要一个外部 ip 或者用
kubectl port-forward...
I hope this helps you sort things out!我希望这可以帮助您解决问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.