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
Use ambassador edge stack
https://www.getambassador.io/docs/latest/topics/install/helm/
note:
这些地方容易踩坑,这是实践出来的
namespace 可以是任意存在的namespace名称
service 的格式是
<NAMESPACE>.<SERVICE>:<PORT>
如果和指向的服务在一个namespace,可以省略掉
如果是服务是80端口,可以省略掉
如果prefix指定了第二个斜杠 那么在浏览器访问 /prefix/ 的时候就不能省略掉第二个/
tips:
端口可以查看
kubectl get svc,mapping -A
, 或者kubectl expose deployment
的时候通过 --port --target-port来指定