dubbo Services Exposure Services in kubernetes

Keywords: Java Dubbo Kubernetes

In some scenarios, dubbo consumer s may need to access dubbo provider s deployed in k8s during development. Especially in the self-built kubernetes cluster environment, the port of tcp is difficult to proxy, which leads to the difficulty of developing services within the development link cluster. Service can be used here to expose dubbo services using nodeport, but dubbo default registered IP address is The IP address of the service is automatically acquired to register, and the IP address is the IP address of the pod, which can not be accessed outside the cluster. Fortunately, dubbo provides a configuration that automatically defines the registered ip. We can specify the IP address as the host IP address when deploying the development debugging service. Examples of deployment are as follows:

# -------------------Service ---------------------- #
apiVersion: v1
kind: Service
metadata:
 name: java-test-svc
 namespace: default
spec:
 type: NodePort
 ports:
 - port: 30011
   targetPort: 30011
   nodePort: 30011
 selector:
  app: java-test
  tier: backend
---
# ------------------- Deployment ------------------- #
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: java-test-deployment
  namespace: default
spec:
  selector:
      matchLabels:
        app: java-test
        tier: backend
  replicas: 1
  template:
    metadata:
      labels:
        app: java-test
        tier: backend
    spec:
      nodeSelector:
        dubbo_provder: dubbo_provider
      containers:
        - name: java-test
          image: [your image]
          imagePullPolicy: Always
#          resources:
#            requests:
#              cpu: 100m
#              memory: 100Mi
#            limits:
#              cpu: 100m
#              memory: 100Mi
          env:
              - name:  APOLLO_META
                value: http://172.31.205.22:8080
              - name: DUBBO_IP_TO_REGISTRY
                value: 172.31.205.23
              - name: DUBBO_PORT_TO_REGISTRY
                value: "30011"
              - name: DUBBO_PORT_TO_BIND
                value: "30011"
          ports:
            - containerPort: 30011
      imagePullSecrets:
      - name: harbor-key
---
# ------------------- ingress ---------------------- #
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: java-test-ingress
  namespace: default
spec:
  rules:
  - host: javatest.com
    http:
      #port: 80
      paths:
      - path: /
        backend:
          serviceName: java-test-svc
          servicePort: 30011

Posted by Jakebert on Wed, 20 Mar 2019 19:03:27 -0700