[jboss-jira] [JBoss JIRA] (JGRP-2139) Implement DNS-based PING

Sebastian Łaskawiec (JIRA) issues at jboss.org
Mon Dec 12 22:17:00 EST 2016


    [ https://issues.jboss.org/browse/JGRP-2139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13337456#comment-13337456 ] 

Sebastian Łaskawiec commented on JGRP-2139:
-------------------------------------------

A very naive implementation may look like the following:
{code}
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
env.put("java.naming.provider.url", "dns://192.168.0.17");
DirContext ictx = new InitialDirContext(env);
Attributes attrs1 = ictx.getAttributes("infinispan-server.myproject.svc.cluster.local", new String[]{"A"});
// prints out:
// Attributes: {a=A: 172.17.0.5, 172.17.0.6, 172.17.0.8}
{code}

The main idea is that Pods need to governed by a [Headless Service|http://kubernetes.io/docs/user-guide/services/#headless-services]. Here's an example:
{noformat}
apiVersion: v1
kind: List
items: 
- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: infinispan-server
    namespace: myproject
    labels:
      app: infinispan-server
  spec:
    triggers:
      - type: ConfigChange
    replicas: 1
    test: false
    selector:
      app: infinispan-server
      deploymentconfig: infinispan-server
    template:
      metadata:
        creationTimestamp: null
        labels:
          app: infinispan-server
          deploymentconfig: infinispan-server
      spec:
        containers:
        - name: infinispan-server
          image: 'jboss/infinispan-server:8.2.5.Final'
          args:
            - cloud
            - '-Djboss.default.jgroups.stack=kubernetes'
          ports:
            - containerPort: 7600
              protocol: TCP
            - containerPort: 8080
              protocol: TCP
            - containerPort: 8181
              protocol: TCP
            - containerPort: 8888
              protocol: TCP
            - containerPort: 9990
              protocol: TCP
            - containerPort: 11211
              protocol: TCP
            - containerPort: 11222
              protocol: TCP
            - containerPort: 57600
              protocol: TCP
          env:
            - name: OPENSHIFT_KUBE_PING_NAMESPACE
              valueFrom: {fieldRef: {apiVersion: v1, fieldPath: metadata.namespace}}
          resources:
          terminationMessagePath: /dev/termination-log
          imagePullPolicy: Always
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      securityContext:
- apiVersion: v1
  kind: Service
  metadata:
    name: infinispan-server
    labels:
      app: infinispan-server
  spec:
    clusterIP: None
    type: ClusterIP
    ports:
      - name: 8080-tcp
        protocol: TCP
        port: 8080
        targetPort: 8080
    selector:
      app: infinispan-server
      deploymentconfig: infinispan-server
- apiVersion: v1
  kind: Route
  metadata:
    name: infinispan-server
    labels:
      app: infinispan-server
  spec:
    to:
      kind: Service
      name: infinispan-server
    port:
      targetPort: 8080-tcp
{noformat}

> Implement DNS-based PING
> ------------------------
>
>                 Key: JGRP-2139
>                 URL: https://issues.jboss.org/browse/JGRP-2139
>             Project: JGroups
>          Issue Type: Enhancement
>         Environment: * OpenShift and Kubernetes (service discovery is done using SRV records)
> * Any other environment that use {{A}} or {{SRV}} DNS records
>            Reporter: Sebastian Łaskawiec
>            Assignee: Sebastian Łaskawiec
>
> DNS Discovery might be very useful in Cloud environments (such as Kubernetes or OpenShift). They expose Services (which act as Load Balancers and Clustered Virtual IPs for Pods (Docker Containers)) with DNS {{SRV}} entries using the following scheme: {{_port._proto.ENDPOINT.service.namespace.sv.cluster.local}} (see [this issue|https://github.com/kubernetes/kubernetes/issues/29420] for more information). 
> The implementation should also allow the following:
> * Change the DNS Server address
> * Change or override TTL values
> * Change DNS record type (either {{A}} or {{SRV}}
> ** If the record type is {{SRV}}, it should also allow parting port
> The implementation might be based on Oracle DNS tutorial: http://docs.oracle.com/javase/7/docs/technotes/guides/jndi/jndi-dns.html



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)



More information about the jboss-jira mailing list