下面的示例入口资源用于测试入口banana.yaml
kind: Pod
apiVersion: v1
metadata:
name: banana-app
namespace: nginx-ingress
labels:
app: banana
spec:
containers:
- name: banana-app
image: hashicorp/http-echo
args:
- "-text=banana"
---
kind: Service
apiVersion: v1
metadata:
name: banana-service
namespace: nginx-ingress
spec:
selector:
app: banana
ports:
- port: 5678
apple.yaml
kind: Pod
apiVersion: v1
metadata:
name: apple-app
namespace: nginx-ingress
labels:
app: apple
spec:
containers:
- name: apple-app
image: hashicorp/http-echo
args:
- "-text=apple"
---
kind: Service
apiVersion: v1
metadata:
name: apple-service
namespace: nginx-ingress
spec:
selector:
app: apple
ports:
- port: 5678 #
IngressFile.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: example-ingress
namespace: nginx-ingress
annotations:
ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.class: nginx
spec:
rules:
- http:
paths:
- path: /apple
backend:
serviceName: apple-service
servicePort: 5678
- path: /banana
backend:
serviceName: banana-service
servicePort: 5678
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-ingress apple-service ClusterIP 10.111.230.109 <none> 5678/TCP 95m
nginx-ingress banana-service ClusterIP 10.102.139.127 <none> 5678/TCP 95m
nginx-ingress nginx-ingress NodePort 10.97.65.187 <none> 80:30207/TCP,443:31031/TCP 6d23h
[root@kube01 ingress]# kubectl get ing
NAME HOSTS ADDRESS PORTS AGE
example-ingress * 80 131m
[root@kube01 ingress]# kubectl describe ing example-ingress
Name: example-ingress
Namespace: default
Address:
Default backend: default-http-backend:80 (<none>)
Rules:
Host Path Backends
---- ---- --------
*
/apple apple-service:5678 (10.244.2.7:5678)
/banana banana-service:5678 (10.244.1.11:5678)
Annotations:
ingress.kubernetes.io/rewrite-target: /
Events: <none>
[root@kube01 ingress]# curl http://10.244.2.7:5678/apple
apple
[root@kube01 ingress]# curl http://10.244.1.11:5678/banana
banana
[root@kube01 ingress]#
[root@kube01 ingress]# curl http://xx.xx.xx.193:30207/apple
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.17.2</center>
</body>
</html>
[root@kube01 ingress]# curl http://xx.xx.xx.193:30207/banana
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.17.2</center>
</body>
</html>
[root@kube01 ingress]#
root@nginx-ingress-685d7964cd-djvgf:/etc/nginx# cat nginx.conf
user nginx;
worker_processes auto;
daemon off;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65s;
keepalive_requests 100;
#gzip on;
server_names_hash_max_size 512;
variables_hash_bucket_size 256;
variables_hash_max_size 1024;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80 default_server;
listen 443 ssl default_server;
ssl_certificate /etc/nginx/secrets/default;
ssl_certificate_key /etc/nginx/secrets/default;
server_name _;
server_tokens "on";
access_log off;
location / {
return 404;
}
}
# stub_status
server {
listen 8080;
allow 127.0.0.1;
deny all;
location /stub_status {
stub_status;
}
}
include /etc/nginx/config-version.conf;
include /etc/nginx/conf.d/*.conf;
server {
listen unix:/var/run/nginx-502-server.sock;
access_log off;
location / {
return 502;
}
}
}
stream {
log_format stream-main '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time';
access_log /var/log/nginx/stream-access.log stream-main;
}
root@nginx-ingress-685d7964cd-djvgf:/etc/nginx#
我没有什么评论(我注意到的):
1,您的入口在默认命名空间中工作:
Namespace: default
instead of nginx-ingress namespace
2,在Kubectl description ing example-ingress
中,没有类似以下注释:
kubernetes.io/ingress.class: nginx
我创建了一个部署、一个服务和一个入口,以便能够从我的主机访问NGINX web服务器,但我一直没有找到404。经过长时间的故障排除,我已经到了一个非常欢迎帮助的地步。 步骤和相关yaml文件如下所示。 启用Minikube NGINX入口控制器 minikube插件支持入口 创建NGINX web服务器部署 创建ClusterIP服务以管理对POD的访问 创建入口以从集群外部访问服务 测验 连接到
来自服务器的错误(InternalError):创建“stdin”时出错:发生内部错误:调用webhook“validate.nginx.ingress.kubernetes.io”失败:Post https://ingress-nginx-controller-crission.ingress-nginx.svc:443/extensions/v1beta1/ingress?timeout=30
我正在AWS EKS上设置NGINX入口控制器。 我浏览了k8s入口资源,它非常有助于理解我们将LB端口映射到k8s服务端口,例如file Def。我安装了nginx控制器,直到必要的步骤。然后教程指示我创建一个入口资源。 我错过了什么?
GKE入口可以与Google的托管SSL证书一起使用。这些证书被部署在负载均衡器的边缘服务器中,这导致了非常低的TTFB(到第一个字节的时间) GKE入口有什么问题
我试图创建一个入口控制器,它指向我通过Nodeport公开的服务。 以下是入口控制器的yaml文件(摘自https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/):
当块注释掉时,入口可以在端口80处正常工作。但是,当我定义时,端口80上的请求返回404,这可能是挑战失败的原因。 注意:在使用我的产品时,我会得到相同的响应。 ::编辑以添加更多配置:: 服务清单: Nginx日志: 2019/12/08 14:45:44[emerg]62#62:无法加载证书“/etc/NGINX/secrets/default-myapp-cert”:PEM_read_bio