httpbin, whoami, qotm (quote of the moment) 服务特别适合用来作为测试
kubectl create namespace httpbin
kubectl create deploy httpbin --image=citizenstig/httpbin --port=8000 -n httpbin
kubectl expose deployment httpbin --name=httpbin -n httpbin --port=80 --target-port=8000
kubectl create ns whoami
kubectl create deploy whoami --image=containous/whoami --port=80 -n whoami --replicas=3
kubectl expose deployment whoami --name=whoami -n whoami --port=80 --target-port=80
kubectl create ns qotm
kubectl create deploy qotm --image=datawire/qotm:1.7 --port=5000 -n qotm --replicas=3
kubectl expose deployment qotm --name=qotm -n qotm --port=80 --target-port=5000
// https://github.com/kubernetes-up-and-running/kuard
kubectl run --restart=Never --image=gcr.io/kuar-demo/kuard-amd64:blue kuard
kubectl port-forward kuard 8080:8080
tips:
-
docker for mac stable channel 比较新的版本支持kubernetes single node cluster了。也可试试edge channel.
-
较新版本的docker for mac 或 minikube支持 type=LoadBalancer类型 的service了(通过vpnkit), minikube tunnel也支持. 因此mac中不需要 MetalLB的方案,除非线上vps的microk8s
-
mac 中 k3d 可以创建multi-nodes kubernetes cluster. 非常方便本地开发测试
k3d version
k3d version v1.7.0
k3s version v1.17.3-k3s1
tips: k3s 1.17 里自带的traefik是 1.xx版本的 非2.0的
# 会自动安装traefik 1.x
k3d create --name="demo" --workers="2" --publish "80:80" --publish "443:443" --api-port=16443
# --server-arg "--no-deploy=traefik" 禁止自动安装traefik 1.x, 然后通过helm 3 安装 traefik 2.x
k3d create --name k3s-traefik-v2 --workers 2 --publish "80:80" --publish "443:443" --server-arg "--no-deploy=traefik"
helm install traefik traefik/traefik --set dashboard.ingressRoute=true
- 需要添加相关的记录到 /etc/hosts
istio 1.5.4 通过 Ingress Gateway 和 VirtualService 可以实现同样的效果
文档链接
https://istio.io/docs/tasks/traffic-management/ingress/ingress-control/#accessing-ingress-services-using-a-browser
注解:
httpbin-gateway 的host 要设为 *,because you can’t pass the Host header to a browser like you did with curl
httpbin virtualservice 的host 设为 *, 表示不限定, localhost/headers 或 httpbin.example.io/headers 都可以打开
设置了match,那么只能打开 /headers 这个页面。 如果去掉 match 部分,就可以打开 httpbin.exmaple.io 的其他页面了
试试这个