连接被拒绝,尝试在成功部署到Kubernetes后加载Keycloak时在浏览器上。

huangapple go评论69阅读模式
英文:

Connection Refused when trying to load keycloak on the browser after deployed it on Kubernetes successfully

问题

I just follow the Keycloak Documentation for Kubernetes.

https://www.keycloak.org/getting-started/getting-started-kube

But After deployed it like exactly how they are saying in the documentation.

When I try to load the Keycloak page, I'm getting this,

if you can give me a solution or explain why this is happening, Really appreciate it!

My ingress config (keycloak-ingress.yaml) is,

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: keycloak
spec:
  tls:
    - hosts:
      - keycloak.192.168.49.2.nip.io
  rules:
  - host: keycloak.192.168.49.2.nip.io
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: keycloak
            port:
              number: 8080
英文:

I just follow the Keycloak Documentation for Kubernetes.

https://www.keycloak.org/getting-started/getting-started-kube

连接被拒绝,尝试在成功部署到Kubernetes后加载Keycloak时在浏览器上。

But After deployed it like exactly how they are saying in the documentation.

When I try to load the keyclaok page, I'm getting this,

连接被拒绝,尝试在成功部署到Kubernetes后加载Keycloak时在浏览器上。

if you can give me a solution or explain why this is happening, Really appreciate it!

My ingress config (keycloak-ingress.yaml) is,

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: keycloak
spec:
  tls:
    - hosts:
      - keycloak.192.168.49.2.nip.io
  rules:
  - host: keycloak.192.168.49.2.nip.io
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: keycloak
            port:
              number: 8080

答案1

得分: 1

请确保您已更新入口文件的正确minikubeIP

还要检查http而不是https以及KEYCLOAK_HOSTNAME的值。

尝试以下YAML:

apiVersion: v1
kind: Service
metadata:
  name: keycloak
  labels:
    app: keycloak
spec:
  ports:
  - name: http
    port: 8080
    targetPort: 8080
  selector:
    app: keycloak
  type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: keycloak
  labels:
    app: keycloak
spec:
  replicas: 1
  selector:
    matchLabels:
      app: keycloak
  template:
    metadata:
      labels:
        app: keycloak
    spec:
      containers:
      - name: keycloak
        image: quay.io/keycloak/keycloak:20.0.3
        args: ["start-dev"]
        env:
        - name: KEYCLOAK_ADMIN
          value: "admin"
        - name: KEYCLOAK_ADMIN_PASSWORD
          value: "admin"
        - name: KC_PROXY
          value: "edge"
        ports:
        - name: http
          containerPort: 8080
        readinessProbe:
          httpGet:
            path: /realms/master
            port: 8080

它将为您创建LB服务,这样您将能够在没有入口配置的情况下访问它。运行 kubectl get svc -n <namespace-name> 并检查外部IP,然后尝试在浏览器中打开它。

额外信息:

如果默认的YAML不起作用,您可以参考此YAML。我正在使用Postgres并使用它部署Keycloak。

GitHub存储库路径:https://github.com/harsh4870/Keycloack-postgres-kubernetes-deployment

参考:https://faun.pub/keycloak-kubernetes-deployment-409d6ccd8a39

英文:

Make sure you have updated the ingress file with the proper IP of minikube.

Also check with http instead https & KEYCLOAK_HOSTNAME value

Try below YAML :

apiVersion: v1
kind: Service
metadata:
  name: keycloak
  labels:
    app: keycloak
spec:
  ports:
  - name: http
    port: 8080
    targetPort: 8080
  selector:
    app: keycloak
  type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: keycloak
  labels:
    app: keycloak
spec:
  replicas: 1
  selector:
    matchLabels:
      app: keycloak
  template:
    metadata:
      labels:
        app: keycloak
    spec:
      containers:
      - name: keycloak
        image: quay.io/keycloak/keycloak:20.0.3
        args: [&quot;start-dev&quot;]
        env:
        - name: KEYCLOAK_ADMIN
          value: &quot;admin&quot;
        - name: KEYCLOAK_ADMIN_PASSWORD
          value: &quot;admin&quot;
        - name: KC_PROXY
          value: &quot;edge&quot;
        ports:
        - name: http
          containerPort: 8080
        readinessProbe:
          httpGet:
            path: /realms/master
            port: 8080

it will creat the LB service for you so you will be able to access it without ingress config. Run kubectl get svc -n &lt;namespace-name&gt; and check External IP and try opening that in browser.

Extra :

You can refer to this YAML if the default one is not working. i am using Postgres & Dpeloying the Keycloak with that.

GitHub repo path : https://github.com/harsh4870/Keycloack-postgres-kubernetes-deployment

Ref : https://faun.pub/keycloak-kubernetes-deployment-409d6ccd8a39

huangapple
  • 本文由 发表于 2023年2月10日 14:43:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75407718.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定