我在ubuntu上本地运行一个k3s集群,并对traefik+metallb进行了测试部署。
以下是我正在关注的教程的链接:https://technotim.live/posts/kube-traefik-cert-manager-le/#traefik
这是我的文件夹结构:
.
├── install.sh
├── metallb
│ ├── metallb.yaml
│ └── values.yaml
└── traefik
├── dashboard
│ ├── ingress.yaml
│ ├── middleware.yaml
│ └── secret-dashboard.yaml
├── default-headers.yaml
└── values.yaml
部署后服务的状态如下:
| NAMESPACE | NAME | TYPE | CLUSTER-IP | EXTERNAL-IP | PORT(S) | AGE | SELECTOR |
|-------------|-------------------------|---------------|----------------|-------------|-------------------------------|-----|----------|
| default | kubernetes | ClusterIP | 10.43.0.1 | none | 443/TCP | 70m | none |
| kube-system | kube-dns | ClusterIP | 10.43.0.10 | none | 53/UDP,53/TCP,9153/TCP | 69m | k8s-app=kube-dns |
| kube-system | metrics-server | ClusterIP | 10.43.160.178 | none | 443/TCP | 69m | k8s-app=metrics-server |
| traefik | metallb-webhook-service | ClusterIP | 10.43.76.91 | none | 443/TCP | 58m | app.kubernetes.io/component=controller,app.kubernetes.io/instance=metallb,app.kubernetes.io/name=metallb |
| traefik | traefik | LoadBalancer | 10.43.203.185 | pending | 6887:30092/TCP,6888:32664/TCP | 58m | app.kubernetes.io/instance=traefik-traefik,app.kubernetes.io/name=traefik |
共享我添加或修改的文件,这是我的metallb.yaml
:
apiVersion: v1
kind: ConfigMap
metadata:
namespace: traefik
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 192.168.0.240/28
这是我的metallb/values.yaml
,与默认相同:https://github.com/metallb/metallb/blob/main/charts/metallb/values.yaml
这是我的traefik/values.yaml
:
globalArguments:
- "--global.sendanonymoususage=false"
- "--global.checknewversion=false"
additionalArguments:
- "--serversTransport.insecureSkipVerify=true"
- "--log.level=INFO"
deployment:
enabled: true
replicas: 1
annotations: {}
podAnnotations: {}
additionalContainers: []
initContainers: []
ports:
web:
exposedPort: 6887
redirectTo:
port: websecure
priority: 10
websecure:
exposedPort: 6888
tls:
enabled: true
ingressRoute:
dashboard:
enabled: false
providers:
kubernetesCRD:
enabled: true
ingressClass: traefik-external
allowExternalNameServices: true
kubernetesIngress:
enabled: true
allowExternalNameServices: true
publishedService:
enabled: false
rbac:
enabled: true
service:
enabled: true
type: LoadBalancer
annotations: {}
labels: {}
spec:
loadBalancerIP: 192.168.0.245
loadBalancerSourceRanges:
- 192.168.0.240/28
externalIPs: []
这是我的install.sh
:
helm upgrade --install --namespace=traefik metallb metallb/metallb --values=metallb/values.yaml
kubectl apply -f metallb/metallb.yaml
helm upgrade --install --namespace=traefik traefik traefik/traefik --values=traefik/values.yaml
kubectl apply -f traefik/default-headers.yaml
kubectl apply -f traefik/dashboard/secret-dashboard.yaml
kubectl apply -f traefik/dashboard/middleware.yaml
kubectl apply -f traefik/dashboard/ingress.yaml
其余文件与教程中的相同。另外,我暂时在路由器上启用了 UPNP Igd,以允许应用程序转发端口。我的部署哪里出了问题?