k8s traefik ingress controller ip 为 容器 ip 问题解决
1.分别保存以下文件vi traefik.toml# Rules for metrics[metrics][metrics.prometheus]entryPoint = "traefik"buckets=[0.1,0.3,1.2,5.0]# Rules for API/Web interface[api]dashboard = truedebug = false[api.statistics]r
·
1.分别保存以下文件
vi traefik.toml
# Rules for metrics
[metrics]
[metrics.prometheus]
entryPoint = "traefik"
buckets=[0.1,0.3,1.2,5.0]
# Rules for API/Web interface
[api]
dashboard = true
debug = false
[api.statistics]
recentErrors = 10
vi traefik-ds.yaml
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: traefik-ingress-controller
namespace: kube-system
---
kind: DaemonSet
apiVersion: extensions/v1beta1
metadata:
name: traefik-ingress-controller
namespace: kube-system
labels:
k8s-app: traefik-ingress-lb
spec:
template:
metadata:
labels:
k8s-app: traefik-ingress-lb
name: traefik-ingress-lb
spec:
nodeSelector:
NodeType: Ingress
serviceAccountName: traefik-ingress-controller
terminationGracePeriodSeconds: 60
hostNetwork: true
volumes:
- name: config
configMap:
name: traefik-conf
containers:
- image: registry.sprod.yz.okeano/k8s/ingress/traefik:v1.7
name: traefik-ingress-lb
volumeMounts:
- mountPath: "/config"
name: "config"
ports:
- name: http
containerPort: 80
hostPort: 80
- name: admin
containerPort: 8080
hostPort: 8080
securityContext:
capabilities:
drop:
- ALL
add:
- NET_BIND_SERVICE
args:
- --configfile=/config/traefik.toml
- --api
- --kubernetes
- --logLevel=INFO
#- --web
#- --web.metrics.prometheus
#- --web.metrics.prometheus.buckets="0.1,0.3,1.2,5.0"
#- --web.address=:8580
#- --web.metrics.prometheus
---
kind: Service
apiVersion: v1
metadata:
name: traefik-ingress-service
namespace: kube-system
spec:
selector:
k8s-app: traefik-ingress-lb
ports:
- protocol: TCP
port: 80
name: http
- protocol: TCP
port: 8080
name: admin
2.执行以下命令
kubectl create cm traefik-conf -nkube-system --from-file=traefik.toml
kubectl delete -f traefik-ds.yaml
kubectl apply -f traefik-ds.yaml
3.查看ingress-controller部署在每个node上,且ip显示为node ip,不是容器分配的IP
curl节点的ip可以访问通,不再是confused
更多推荐
已为社区贡献8条内容
所有评论(0)