清理环境
[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
标签:ingress,httpbin,master01,istio,k8s,root,控制器 From: https://www.cnblogs.com/fenghua001/p/17450921.html