gpt4 book ai didi

kubernetes - kubernetes上的 key 斗篷:入口HTTPS必需错误

转载 作者:行者123 更新时间:2023-12-02 11:47:25 28 4
gpt4 key购买 nike

我有一个Kubernetes集群,在其中部署了以下部署和服务:

apiVersion: v1
kind: Service
metadata:
name: keycloak
labels:
app: keycloak
name: keycloak
spec:
type: NodePort
ports:
- name: http
protocol: TCP
port: 8080
selector:
app: keycloak
name: keycloak
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: keycloak
labels:
name: keycloak
app: keycloak
spec:
replicas: 1
selector:
matchLabels:
app: keycloak
template:
metadata:
name: keycloak
labels:
app: keycloak
name: keycloak
spec:
restartPolicy: Always
containers:
- name: keycloak
image: jboss/keycloak
ports:
- containerPort: 8080
protocol: TCP
resources:
requests:
cpu: 200m
memory: 256Mi
limits:
cpu: 400m
memory: 512Mi
env:
- name: KEYCLOAK_LOGLEVEL
value: "DEBUG"
- name: PROXY_ADDRESS_FORWARDING
value: "true"
- name: KEYCLOAK_USER
value: "admin"
- name: KEYCLOAK_PASSWORD
value: "password"
- name: DB_USER
valueFrom:
secretKeyRef:
name: postgres-secret
key: username
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: password
- name: DB_ADDR
valueFrom:
configMapKeyRef:
name: postgres-configmap
key: HOST
- name: DB_PORT
valueFrom:
configMapKeyRef:
name: postgres-configmap
key: PORT
- name: DB_DATABASE
valueFrom:
configMapKeyRef:
name: postgres-configmap
key: DATABASE
- name: DB_VENDOR
value: "postgres"


我运行keycloak的pod中的日志正在确认我的keycloak正在运行,并且正在使用提供的Postgres数据库。我尝试添加以下入口规则:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: keycloak
annotations:
kubernetes.io/tls-acme: "true"
kubernetes.io/ingress.class: "nginx"
ingress.kubernetes.io/force-ssl-redirect: "true"
spec:
rules:
- host: auth.mydomain.com
http:
paths:
- path: /
backend:
serviceName: keycloak
servicePort: 8080
- path: /auth
backend:
serviceName: keycloak
servicePort: 8080

我可以进入Keycloak主页,但是一旦单击管理控制台,我总是收到错误消息: We're sorry .... HTTPS required。将PROXY_ADDRESS_FORWARDING变量设置为“true”,无助于正确设置。我不只是想在端口8443上运行keycloak,所以我真的在寻找其他解决方案。

最佳答案

您需要在入口中设置TLS termination

spec:
tls:
- hosts:
- auth.mydomain.com
secretName: tls-secret

使用创建的 secret ,其中包含 auth.mydomain.com的证书:
apiVersion: v1
kind: Secret
metadata:
name: tls-secret
namespace: default
type: kubernetes.io/tls
data:
tls.crt:LS0S[...]0tLhsrQo=
tls.key:LS0t[...]LS1CRUdJ=

这将使您的入口 Controller 可以使用提供的TLS证书终止流量,并将未加密的HTTP流量转发到 keycloak服务。

关于kubernetes - kubernetes上的 key 斗篷:入口HTTPS必需错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56114790/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com