kubernetes 集群中 elasticsearch pod 运行 的基本身份验证
Basic authentication for elasticsearch pod running in kubernetes cluster
我们需要为 elasticsearch 和 kibana oss(Apache 许可证)运行 创建基本 (username/password) 身份验证到我们的 kubernetes 集群中。
我们在 AWS (EKS)、Google 云 (GKE)、本地安装中进行了多云安装,我们计划使用 Azure。
我考虑将具有基本身份验证 运行 的 nginx 反向代理作为每个 elasticsearch/kibana pod 中的 sidecar 容器。这将是一个简单且已知的解决方案。
问题是:k8s 集群中正确的解决方案是什么?我们可以从无数易于维护的解决方案中获取什么?
好吧,如果您使用的是 nginx ingress controller
,您可以像这样添加基本身份验证:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kibana
namespace: kibana
annotations:
kubernetes.io/ingress.class: "nginx"
# type of authentication
nginx.ingress.kubernetes.io/auth-type: basic
# name of the secret that contains the user/password definitions
nginx.ingress.kubernetes.io/auth-secret: my-secret-basic-auth
# message to display with an appropriate context why the authentication is required
nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - kibana-admin'
...
...
必须使用 htpasswd
创建 my-secret-basic-auth
:
$ htpasswd -c auth foo
New password: <bar>
New password:
Re-type new password:
Adding password for user foo
然后你需要创建秘密:
$ kubectl create secret generic my-secret-basic-auth --from-file=auth
secret "my-secret-basic-auth" created
这很简单且易于维护,但您将永远依附于 nginx ingress controller
。
我们需要为 elasticsearch 和 kibana oss(Apache 许可证)运行 创建基本 (username/password) 身份验证到我们的 kubernetes 集群中。 我们在 AWS (EKS)、Google 云 (GKE)、本地安装中进行了多云安装,我们计划使用 Azure。
我考虑将具有基本身份验证 运行 的 nginx 反向代理作为每个 elasticsearch/kibana pod 中的 sidecar 容器。这将是一个简单且已知的解决方案。
问题是:k8s 集群中正确的解决方案是什么?我们可以从无数易于维护的解决方案中获取什么?
好吧,如果您使用的是 nginx ingress controller
,您可以像这样添加基本身份验证:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kibana
namespace: kibana
annotations:
kubernetes.io/ingress.class: "nginx"
# type of authentication
nginx.ingress.kubernetes.io/auth-type: basic
# name of the secret that contains the user/password definitions
nginx.ingress.kubernetes.io/auth-secret: my-secret-basic-auth
# message to display with an appropriate context why the authentication is required
nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - kibana-admin'
...
...
必须使用 htpasswd
创建 my-secret-basic-auth
:
$ htpasswd -c auth foo
New password: <bar>
New password:
Re-type new password:
Adding password for user foo
然后你需要创建秘密:
$ kubectl create secret generic my-secret-basic-auth --from-file=auth
secret "my-secret-basic-auth" created
这很简单且易于维护,但您将永远依附于 nginx ingress controller
。