The ingress-nginx kubectl 插件
安装
安装 krew, 运行
kubectl krew install ingress-nginx安装插件然后运行
kubectl ingress-nginx --help确保插件已正确安装并获取命令列表:
kubectl ingress-nginx --help
A kubectl plugin for inspecting your ingress-nginx deployments
Usage:
ingress-nginx [command]
Available Commands:
backends Inspect the dynamic backend information of an ingress-nginx instance
certs Output the certificate data stored in an ingress-nginx pod
conf Inspect the generated nginx.conf
exec Execute a command inside an ingress-nginx pod
general Inspect the other dynamic ingress-nginx information
help Help about any command
info Show information about the ingress-nginx service
ingresses Provide a short summary of all of the ingress definitions
lint Inspect kubernetes resources for possible issues
logs Get the kubernetes logs for an ingress-nginx pod
ssh ssh into a running ingress-nginx pod
Flags:
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--cache-dir string Default HTTP cache directory (default "/Users/alexkursell/.kube/http-cache")
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use
--context string The name of the kubeconfig context to use
-h, --help help for ingress-nginx
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
--kubeconfig string Path to the kubeconfig file to use for CLI requests.
-n, --namespace string If present, the namespace scope for this CLI request
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
-s, --server string The address and port of the Kubernetes API server
--token string Bearer token for authentication to the API server
--user string The name of the kubeconfig user to use
Use "ingress-nginx [command] --help" for more information about a command.如果刚刚发布了新的ingress-nginx版本,则该插件可能尚未在存储库中更新。在这种情况下,您可以通过运行以下命令安装最新版本的插件:
用最新发布的版本替换0.24.0。
常用参数
每个子命令都支持基本的
kubectl配置参数,像--namespace,--context,--client-key等.对特定的Ingress-nginx Pod(
backend,certs,conf,exec,exec,general,logs,ssh)起作用的子命令支持--deployment <deployment>和--pod <pod>参数,以从deployment中选择一个Pod使用给定名称,或使用给定名称的pod。 --deployment参数默认为nginx-ingress-controller检查资源的子命令 (
ingresses,lint) 支持--all-namespaces标志,这使它们可以检查每个命名空间中的资源。
子命令
请注意 backends, general, certs, 和 conf 依赖 ingress-nginx 0.23.0版本及以上.
backends
运行 kubectl ingress-nginx backends 以获取ingress-nginx controller当前已知的后端的JSON数组:
添加--list选项以仅显示后端名称。添加--backend <backend>选项以仅显示具有给定名称的后端
certs
使用kubectl ingress-nginx certs --host <主机名>转储给定位置的SSL证书/密钥信息. 要求--enable-dynamic-certificates为true(这是0.24.0版的默认值)
WARNING: 此命令将转储敏感的私钥信息。不要盲目分享输出,当然也不要在任何地方记录它
conf
使用kubectl ingress-nginx conf转储生成的nginx.conf文件。添加--host <hostname>选项以仅查看该主机的server块:
exec
kubectl ingress-nginx exec 与 kubectl exec完全相同,具有相同的命令标志。它将自动选择一个ingress-nginx pod来运行命令
general
kubectl ingress-nginx general将其他控制器状态转储为JSON对象。当前,它仅显示特定控制器容器已知的控制器容器的数量。
info
显示Ingress-nginx服务的内部和外部IP/CNAMES
如果您的ingress-nginx LoadBalancer服务未命名为ingress-nginx,请使用--service <service>参数
ingresses
kubectl ingress-nginx ingresses,或者kubectl ingress-nginx ing,显示了名称空间中入口定义的更详细视图。相比
vs
lint
kubectl ingress-nginx lint可以检查名称空间或整个集群是否存在潜在的配置问题。在Ingress-nginx版本之间升级时,此命令特别有用。
要显示仅针对特定ingress-nginx版本添加的棉绒,请使用--from-version和--to-version标志
logs
kubectl ingress-nginx logs 几乎与 kubectl logs相似,与更少的标志。它将自动选择一个ingress-nginx Pod来读取日志。
ssh
kubectl ingress-nginx ssh与kubectl ingress-nginx exec -it --/bin/bash完全相同。 如果您想快速放入正在运行的ingress-nginx`容器内的shell中,请使用它
Last updated
Was this helpful?