在kubernetes控制器中搜索注释



我试图找到注释来在Nginx控制器中进行一些基本的身份验证。互联网上的大多数资源都指定了此注释:"nginx.ingress.kuberenetes.io/…";

而我在nginx文档中发现:https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-annotations/它被切换到";nginx.org";

在外部文档中搜索答案似乎有点绕路。有没有一种方法可以浏览带有本地命令的控制器上支持哪些注释,也许类似于kubectl解释?

有什么想法吗?

您可以使用kubectl explain ingress,但它只会显示有关入口的Kubernetes资源的文档,类似

KIND:     Ingress
VERSION:  networking.k8s.io/v1
DESCRIPTION:
Ingress is a collection of rules that allow inbound connections to reach
the endpoints defined by a backend. An Ingress can be configured to give
services externally-reachable urls, load balance traffic, terminate SSL,
offer name based virtual hosting etc.
FIELDS:
apiVersion   <string>
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
kind <string>
Kind is a string value representing the REST resource this object
represents. Servers may infer this from the endpoint the client submits
requests to. Cannot be updated. In CamelCase. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
metadata <Object>
Standard object's metadata. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
spec <Object>
Spec is the desired state of the Ingress. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
status   <Object>
Status is the current state of the Ingress. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

简而言之,为了更好地检查舵图和官方文件,请进行注释

这就是如何将基本身份验证添加到入口

首先,创建基本的身份验证密钥

htpasswd -c auth admin
kubectl create secret generic basic-auth --from-file=auth

然后在注释中引用这个秘密

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/auth-type: basic
nginx.ingress.kubernetes.io/auth-secret: basic-auth
nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required to access Linkerd'
name: linker-basicauth-ingress
namespace: linkerd-viz
spec:
tls:
- hosts:
- mybasic-auth.example.com
secretName: ingres-tls-secret
rules:
- host: mybasic-auth.example.com
http:
paths:
- backend:
service:
name: web
port:
number:  8084
path: /
pathType: Prefix

nginx配置/注释.md

最新更新