DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Can You Run a MariaDB Cluster on a $150 Kubernetes Lab? I Gave It a Shot
  • How Kubernetes Cluster Sizing Affects Performance and Cost Efficiency in Cloud Deployments
  • The Production-Ready Kubernetes Service Checklist
  • 10 Best Practices for Managing Kubernetes at Scale

Trending

  • Why AI Forces a Rethink of Everything We Know About Software Security
  • Swift Concurrency Part 4: Actors, Executors, and Reentrancy
  • Lease Coordination Under Serializable Isolation in CockroachDB
  • The Prompt Isn't Hiding Inside the Image
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Keycloak Cluster Setup With kube_ping

Keycloak Cluster Setup With kube_ping

Take a look at how to auto-discover using kube_ping and Keycloak.

By 
Arvind Rajpurohit user avatar
Arvind Rajpurohit
·
Jan. 12, 19 · Code Snippet
Likes (7)
Comment
Save
Tweet
Share
19.8K Views

Join the DZone community and get the full member experience.

Join For Free

Keycloak is an open source software which provides single sign-on with Identity Management and access management. Keycoak uses different types of pings to discover other members of cluster. We are going to use kube_ping as discovery (JGROUPS_DISCOVERY_PROTOCOL).

How kube_ping Works

Let's assume we launch a cluster of 3 pods in Kubernetes in the default Namespace. When discovery starts, kube_ping asks for a list of the IP addresses of all pods from Kubernetes.

Kubernetes returns the list of IP addresses. kube_ping sends discovery requests to members using the IP address and port range.

Prerequisites:

1. Working Kubernetes cluster

2. A running MySQL Instance.


Creating Deployment Object in K8s Cluster

apiVersion: v1
items:
- apiVersion: extensions/v1beta1
  kind: Deployment
  spec:
    replicas: 3
    template:
       metadata:
         labels:
           app: keycloak
           name: keycloak
       spec:
        containers:
        - env:
          - name: KEYCLOAK_HOSTNAME
            value: {{keycloak host name}}
          - name: KEYCLOAK_LOGLEVEL
            value: DEBUG
          - name: ROOT_LOGLEVEL
            value: DEBUG
          - name: KEYCLOAK_USER
            value: {{keyclock admin user}}
          - name: DB_VENDOR
            value: mysql
          - name: DB_ADDR
            value: {{mysql host}}
          - name: DB_USER
            value: {{mysql user}}
          - name: DB_PASSWORD
            value: {{mysql password}}
          - name: JGROUPS_DISCOVERY_PROTOCOL
            value: kubernetes.KUBE_PING
          - name: JGROUPS_DISCOVERY_PROPERTIES
            value: port_range=0,dump_requests=true
          - name: connectTimeout
            value: "600000"
          - name: KEYCLOAK_PASSWORD
            value: {{keyclock admin password}}
          - name: remoteTimeout
            value: "600000"
          image: jboss/keycloak:4.5.0
          imagePullPolicy: Never
          name: keycloak
          ports:
          - containerPort: 8080
            name: http
            protocol: TCP
          - containerPort: 8443
            name: https
            protocol: TCP


Creating Service Object in K8s Cluster

apiVersion: v1
kind: Service
metadata:
  name: keycloak
  labels:
    app: keycloak
    name: keycloak
spec:
  type: NodePort
  ports:
    - name: http
      protocol: TCP
      port: 8080
      nodePort: 30000
  selector:
    app: keycloak
    name: keycloak


This creates the endpoint of Keycloak. Now the Keycloak admin consol will be available at http://{{hostip}}:30000.

Kubernetes cluster Keycloak

Opinions expressed by DZone contributors are their own.

Related

  • Can You Run a MariaDB Cluster on a $150 Kubernetes Lab? I Gave It a Shot
  • How Kubernetes Cluster Sizing Affects Performance and Cost Efficiency in Cloud Deployments
  • The Production-Ready Kubernetes Service Checklist
  • 10 Best Practices for Managing Kubernetes at Scale

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook