TIP
在 Kubernetes 上安装 Keep 的推荐方式是通过 Helm Chart。
按照这些步骤进行设置。
前置条件
Helm CLI
有关安装 helm 的说明,请参阅 Helm 文档。
Ingress Controller(可选)
INFO
如果满足以下条件,您可以跳过此步骤:
- 您已经安装了 ingress-nginx。
- 您不需要将 Keep 暴露给互联网/网络。
概述
ingress 控制器对于管理对 Kubernetes 集群中服务的外部访问至关重要。它充当智能路由器和负载均衡器,允许您通过单个入口点暴露多个服务,同时处理 SSL 终止和路由规则。
Keep 与两者配合使用效果最佳 ingress-nginx 和 HAProxy Ingress 控制器,但您也可以为其他 ingress 控制器自定义 helm chart。
Nginx Ingress Controller
检查 ingress-nginx 是否已安装
您可以检查是否已安装 ingress-nginx:
bash
# By default, the ingress-nginx will be installed under the ingress-nginx namespace
kubectl -n ingress-nginx get pods
NAME READY STATUS RESTARTS AGE
ingress-nginx-controller-d49697d5f-hjhbj 1/1 Running 0 4h19m
# Or check for the ingress class
kubectl get ingressclass
NAME CONTROLLER PARAMETERS AGE
nginx k8s.io/ingress-nginx <none> 4h19m安装 ingress-nginx
INFO
要阅读更多安装选项,请参阅 ingress-nginx 安装文档。
TIP
从 ingress-nginx 4.12 开始,您需要添加
--set controller.config.annotations-risk-level=Critical请参阅 https://github.com/kubernetes/ingress-nginx/issues/12618#issuecomment-2566084202
bash
# simplest way to install
# we set snippet-annotations to true to allow rewrites
# see https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#allow-snippet-annotations
helm upgrade --install ingress-nginx ingress-nginx \
--repo https://kubernetes.github.io/ingress-nginx \
--set controller.config.allow-snippet-annotations=true \
--set controller.config.annotations-risk-level=Critical \
--namespace ingress-nginx --create-namespace验证安装:
bash
kubectl get ingressclass
NAME CONTROLLER PARAMETERS AGE
nginx k8s.io/ingress-nginx <none> 4h19m验证是否启用了 snippet 注解:
bash
kubectl get configmap -n ingress-nginx ingress-nginx-controller -o yaml | grep allow-snippet-annotations
allow-snippet-annotations: "true"HAProxy Ingress Controller
安装 ingress-haproxy
INFO
要阅读更多安装选项,请参阅 haproxy-ingress 安装文档。
bash
# simplest way to install
helm upgrade --install haproxy-ingress haproxy-ingress \
--repo https://haproxy-ingress.github.io/charts \
--namespace ingress-haproxy --create-namespace验证安装:
bash
kubectl get ingressclass
NAME CONTROLLER PARAMETERS AGE
haproxy haproxy-ingress.github.io/controller <none> 4h19m验证控制器是否正在运行:
bash
kubectl get pods -n ingress-haproxy -l app.kubernetes.io/instance=haproxy-ingress
NAME READY STATUS RESTARTS AGE
haproxy-ingress-controller-x4n2z 1/1 Running 0 4h19m安装
使用 Ingress-NGINX(推荐)
bash
# Add the Helm repository
helm repo add keephq https://keephq.github.io/helm-charts
# Install Keep with ingress enabled
helm install keep keephq/keep -n keep --create-namespace使用 Ingress-HAProxy(推荐)
bash
# Add the Helm repository
helm repo add keephq https://keephq.github.io/helm-charts
# Install Keep with ingress enabled
helm install keep keephq/keep -n keep --create-namespace --set global.ingress.className=haproxy不使用 Ingress(不推荐)
bash
# Add the Helm repository
helm repo add keephq https://keephq.github.io/helm-charts
# Install Keep without ingress enabled.
# You won't be able to access Keep from the network.
helm install keep keephq/keep -n keep --create-namespace \
--set global.ingress.enabled=false访问 Keep
Ingress
如果您使用 ingress 安装了 Keep,您应该能够访问 Keep。
bash
kubectl -n keep get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
keep-ingress nginx * X.X.X.X 80 4h16mKeep 可在 http://X.X.X.X 访问 😃
不使用 Ingress(端口转发)
使用以下命令在没有 ingress 的情况下本地访问 Keep:
bash
# Forward the UI
kubectl port-forward svc/keep-frontend 3000:3000 -n keep &
# Forward the Backend
kubectl port-forward svc/keep-backend 8080:8080 -n keep &
# Forward WebSocket server (optional)
kubectl port-forward svc/keep-websocket 6001:6001 -n keep &Keep 可在 http://localhost:3000 访问 😃
配置 HTTPS
前置条件
- 域名:示例 - keep.yourcompany.com
- TLS 证书:私钥 (tls.key) 和证书 (tls.crt)
创建 TLS 密钥
假设:
tls.crt包含证书。tls.key包含私钥。
bash
# create the secret with kubectl
kubectl create secret tls keep-tls --cert=./tls.crt --key=./tls.key -n keep更新 Helm Values 以使用 TLS
bash
helm upgrade -n keep keep keephq/keep \
--set "global.ingress.hosts[0].host=keep.example.com" \
--set "global.ingress.tls[0].hosts[0]=keep.example.com" \
--set "global.ingress.tls[0].secretName=keep-tls"或者,更新您的 values.yaml:
bash
...
global:
ingress:
hosts:
- host: keep.example.com
tls:
- hosts:
- keep.example.com
secretName: keep-tls
...卸载
要删除 Keep 并清理:
bash
helm uninstall keep -n keep
kubectl delete namespace keep