我的入口为:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: mongoexpress-ingress
spec:
rules:
- host: mylocalmongoexpress.com
http:
paths:
- backend:
serviceName: mongoexpress-service
servicePort: 8081
Run Code Online (Sandbox Code Playgroud)
当我运行“kubectl apply -f mongoexpress-ingress.yaml”时,出现错误:
错误:验证“mongoexpress-ingress.yaml”时出错:验证数据时出错:[ValidationError(Ingress.spec.rules[0].http.paths[0].backend):io.k8s.api 中的未知字段“serviceName”。 networking.v1.IngressBackend,ValidationError(Ingress.spec.rules [0] .http.paths [0] .backend):io.k8s.api.networking.v1.IngressBackend中的未知字段“servicePort”,ValidationError(Ingress.spec .rules[0].http.paths[0]): io.k8s.api.networking.v1.HTTPIngressPath] 中缺少必填字段“pathType”;如果您选择忽略这些错误,请使用 --validate=false 关闭验证
浏览在线资源,我在 yaml 文件中找不到问题。
那么我在这里缺少什么?
我在一台机器上执行了 kubeadm init 。我按照网络等上的所有说明进行操作,最终得到以下结果:
kubectl get nodes:
NAME STATUS ROLES AGE VERSION
slchvdvcybld001 Ready control-plane 140m v1.24.2
slchvdvcydtb001 Ready <none> 136m v1.24.2
slchvdvcytst001 Ready <none> 137m v1.24.2
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,没有节点是 Master 或 Worker 或类似的节点。
我没有任何特殊的设置,我所做的就是安装它并进行初始化。
日志文件中没有错误。仪表板是绿色的,所有东西都是绿色的。
这些是 kubectl 等的版本:
Client Version: v1.24.2
Kustomize Version: v4.5.4
Server Version: v1.24.2
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 minikube 中应用入口规则,但收到此错误
error: resource mapping not found for name: "dashboard-ingress" namespace: "kubernetes-dashboard" from "Desktop/minikube/dashboard-ingress.yaml": no matches for kind "Ingress" in version "networking.k8.io/v1"
Run Code Online (Sandbox Code Playgroud)
仪表板-ingress.yaml
apiVersion: networking.k8.io/v1
kind: Ingress
metadata:
name: dashboard-ingress
namespace: kubernetes-dashboard
spec:
rules:
- host: dashboard.com
http:
paths:
- backend:
serviceName: kubernetes-dashboard
servicePort: 80
Run Code Online (Sandbox Code Playgroud) 我正在尝试为limit_reqKubernetes ingress-nginx 中的特定路径设置速率限制选项,以防止强制身份验证。
我已经limit_req_zone使用 ConfigMap定义了:
http-snippet: |
limit_req_zone $the_real_ip zone=authentication_ratelimit:10m rate=1r/s;
Run Code Online (Sandbox Code Playgroud)
接下来,我使用注解添加自定义位置块:
nginx.ingress.kubernetes.io/configuration-snippet: |
location ~* "^/authenticate$" {
limit_req zone=authentication_ratelimit nodelay;
more_set_headers "x-test: matched";
}
Run Code Online (Sandbox Code Playgroud)
这会产生 nginx.conf:
server {
# - - 8< - -
location / {
# - - 8< - -
location ~* "^/authenticate$" {
limit_req zone=authentication_ratelimit nodelay;
more_set_headers "x-test: matched";
}
proxy_pass http://upstream_balancer;
proxy_redirect off;
}
Run Code Online (Sandbox Code Playgroud)
结果是/authenticate总是返回 HTTP 503(带有 x-test 标头)。来自入口访问日志的消息:
<ip> - [<ip>] - - [04/Jan/2019:15:22:07 +0000] "POST /authenticate …Run Code Online (Sandbox Code Playgroud) 我有一个使用https的后端。我想根据URL /路径将后端的负载分开。
我决定使用ingress进行基于url / path的逻辑,以将流量移至不同的后端(相同的后端,只是复制到不同的NodePorts)
我的问题是如何配置入口以接收https请求并将这些https请求转发到https后端?
谢谢
编辑:我添加了yaml文件:
spec:
rules:
- http:
paths:
- backend:
serviceName: service
servicePort: 9443
path: /carbon
- backend:
serviceName: service2
servicePort: 9443
path: /oauth
Run Code Online (Sandbox Code Playgroud)
由于某种原因,我无法将规则表http更改为https
我正在创建一个配置以在 AWS 上的 Kubernetes 集群中托管一些应用程序。我有两个不同的应用程序,具有单独的服务/pod/选择器,但我现在想用一个入口公开它们。
所以我创建了以下入口控制器
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /foo
backend:
serviceName: foo
servicePort: 8080
- path: /bar
backend:
serviceName: bar
servicePort: 8080
Run Code Online (Sandbox Code Playgroud)
并且入口从 AWS 获取 ELB 没有任何问题,但是当我尝试浏览应用程序(使用 Tomcat appserver 的 Java 应用程序)时,我总是收到以下页面
这是经典的旧 Tomcat 欢迎页面,但每个请求总是返回 index.html(未加载 css/img),而且如果我尝试为应用程序使用正确的上下文路径,我会收到此页面。
如果我使用服务 (LoadBalancer) 公开应用程序,我可以使用它而不会出现这些问题,所以我认为入口配置有问题。
有任何想法吗?
更新
如果我使用这样的单一路径的入口
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: foo
servicePort: …Run Code Online (Sandbox Code Playgroud) tomcat kubernetes kubernetes-ingress amazon-eks nginx-ingress
我正在 Kubernetes 上部署许多微服务和角度前端的 docker 容器。我已经使用入口控制器公开了服务,使用它指定了每个服务,并在后端指定了路径。
apiVersion: extensions/v1beta1
kind: Ingress
Run Code Online (Sandbox Code Playgroud)
对于我的前端,我创建了一个类型为 loadbalancer 的服务。
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/azure-load-balancer-resource-group: my-resource-group
name: myapp-svc
namespace: ui
spec:
loadBalancerIP: SOME_IP_ADDRESS
type: LoadBalancer
ports:
- port: 80
selector:
app: myapp
Run Code Online (Sandbox Code Playgroud)
这工作正常,但现在我有两个 IP 地址,一个用于 UI 负载均衡器,另一个用于入口控制器(用于 API)。
我可以只用一个 IP 地址来做到这一点吗?
如何在不创建外部负载均衡器的情况下使用入口控制器本身公开 UI?
paths:
- backend:
serviceName: booknotes-front-end-service
servicePort: 80
path: /
- backend:
serviceName: booknotes-back-end-service
servicePort: 3000
path: /api
Run Code Online (Sandbox Code Playgroud)
这是我的 ingres-nginx 资源中的规则。我尝试将所有从开始的流量定向/api到我的后端服务,该服务正常工作,但是如果我后端的某些路由类似于 /api/users 它不起作用,我的后端发送响应未找到,当我在本地运行这条路线工作正常。此外,我尝试从我的 koa 路由中删除 /api 前缀并将其更改为/users,然后我也更改 path: /api为,path: /users并且这些东西正常工作。我应该怎么做才能修复它?如果您需要其他信息,请告诉我!
kubernetes google-kubernetes-engine kubernetes-ingress nginx-ingress
我有一个KongIngress关于 Ingress 资源的对象配置属性,它调用 kong 作为 Ingress 控制器。我实际上有这个配置:
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
name: echo-site-ingress
namespace: hello-world
annotations:
kubernetes.io/ingress.class: "kong"
proxy:
protocols:
- http
- https
# path: /
route:
methods:
- POST
- GET
strip_path: true
preserve_host: true
---
#My Ingress resource
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
kubernetes.io/ingress.class: kong
plugins.konghq.com: helloworld-customer-acceptance-basic-auth, hello-world-customer-acceptance-acl
name: echo-site-ingress
namespace: hello-world
spec:
rules:
- host: hello-world.bgarcial.me
http:
paths:
- backend:
serviceName: echo
servicePort: 80
path: /
tls:
- hosts:
- …Run Code Online (Sandbox Code Playgroud) basic-authentication kong kubernetes-ingress kong-plugin kong-ingress
我的请求是通过 Cloudflare 代理的,Cloudflare 会根据 IP 地址在 http 标头中设置一个标头,指示国家/地区。我想根据 Nginx 入口控制器中的此标头使用某些路径重定向请求。我该怎么做呢?
kubernetes ×8
amazon-eks ×1
azure-aks ×1
kong ×1
kong-ingress ×1
kong-plugin ×1
kubectl ×1
minikube ×1
nginx ×1
tomcat ×1