我正在尝试在3个覆盆子pis上构建k3s集群。所有3个版本都在Raspbian Buster Lite上运行最新版本。我部署了k3s集群,一切似乎都可以正常工作,而且似乎可以开始部署pod了。我正在尝试部署一个最小的Consul容器,并且它可以工作,但是我似乎无法将其暴露给外界(甚至暴露给我的本地网络)。
起初,我尝试使用traefik ingress公开它,但是当那不起作用时,我想看看用nodePort公开它是否可以工作,但是令我惊讶的是当它也不起作用时。后来我读到Kubernetes在最新版本的IPtables上有问题(我看到它没有对iptables-save写入任何规则,而仅对iptables-legacy写入任何规则),所以我尝试执行以下命令:
update-alternatives --set iptables / usr / sbin / iptables-legacy
然后重新部署了我的豆荚,但无济于事。有人遇到过吗?
这是我使用的2支Yaml:
没有traefik:
apiVersion: apps/v1
kind: Deployment
metadata:
name: consul
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: consul
template:
metadata:
labels:
app: consul
spec:
containers:
- name: consul
image: consul:latest
---
apiVersion: v1
kind: Service
metadata:
name: consul
namespace: default
spec:
selector:
app: consul
type: NodePort
ports:
- name: http
port: 8500
targetPort: 8500
nodePort: 30036
protocol: TCP
使用traefik:
apiVersion: apps/v1
kind: Deployment
metadata:
name: consul
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: consul
template:
metadata:
labels:
app: consul
spec:
containers:
- name: consul
image: consul:latest
---
apiVersion: v1
kind: Service
metadata:
name: consul
namespace: default
spec:
ports:
- name: http
targetPort: 8500
port: 80
selector:
app: consul
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: consul
annotations:
kubernetes.io/ingress.class: "traefik"
spec:
rules:
- host: consul.example.org
# I tried adding consul.example.org to my hosts file, but to no effect.
http:
paths:
- path: /
backend:
serviceName: consul
servicePort: http