Kubernetes headless service and ambassador

232 views
Skip to first unread message

SR

unread,
May 20, 2019, 5:40:05 AM5/20/19
to Hazelcast
I have deployed my service as headless server and did follow the kubernetes configuration as mentioned in this linke (http://vertx.io/docs/vertx-hazelcast/java/#_using_this_cluster_manager). My service is load balanced and proxied by ambassador. Once the service changed to headless ambassador is not able to discover my services. Which means it was looking for clusterIP and it is missing now as the services are headless. What is that I need to  include in my deployment.yaml so these services are discovered by ambassador.

Members are definitely discovered by hazelcast by seeing the following in the console

Members {size:2, ver:4} [ May 18th 2019, 06:38:24.841 ]
May 18th 2019, 06:38:24.841 Member [IP1]:5701 - xxxxxxx-xxxx-xxxx-b6db-45489c6bee5e
May 18th 2019, 06:38:24.841 Member [IP2]:5701 - xxxxxxx-xxxx-xxxx-b3e3-517938caeab4
]


Here is my service.yaml

apiVersion: v1
kind: Service
metadata:
  name: abt-login-service
  labels:
    chart: "abt-login-service-0.1.0-SNAPSHOT"
  annotations:
    fabric8.io/expose: "true"

      ---
      apiVersion: ambassador/v1
      name:  login_mapping
      ambassador_id: default
      kind: Mapping
      prefix: /login/
      service: abt-login-service.default.svc.cluster.local
      use_websocket: true
spec:
  type: ClusterIP
  clusterIP: None
  selector:
    app: RELEASE-NAME-abt-login-service
  ports:
  - port: 80
    targetPort: 8080
    protocol: TCP
    name: http
  - name: hz-port-name
    port: 5701
    protocol: TCP


Deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: RELEASE-NAME-abt-login-service
  labels:
    draft: draft-app
    chart: "abt-login-service-0.1.0-SNAPSHOT"
spec:
  replicas: 2
  selector:
    matchLabels:
     app: RELEASE-NAME-abt-login-service
  minReadySeconds: 30
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    metadata:
      labels:
        draft: draft-app
        app: RELEASE-NAME-abt-login-service
        component: abt-login-service
    spec:
      serviceAccountName: vault-auth
      containers:
      - name: abt-login-service
        env:
        - name: SPRING_PROFILES_ACTIVE
          value:  "dev"
        - name: _JAVA_OPTIONS
          value:  "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=2 -Dsun.zip.disableMemoryMapping=true -XX:+UseParallelGC -XX:Min
HeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dhazelcast.diagnostics.enabled=true
"
        image: "draft:dev"
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
        ports:
        - containerPort: 5701
        livenessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 60
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        readinessProbe:
          httpGet:
            path: /health
            port: 8080
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources:
            limits:
              cpu: 500m
              memory: 1024Mi
            requests:
              cpu: 400m
              memory: 512Mi

      terminationGracePeriodSeconds: 10

Rafal Leszko

unread,
May 21, 2019, 5:22:52 AM5/21/19
to haze...@googlegroups.com
Hi SR,

Thanks for asking the question. 

If you use headless service it does not have the IP, so that is actually your problem. I see two solutions to your issue:
1. Create two services (one headless, to support Hazelcast discovery, one as you had before to support ambassador).
2. Use Kubernetes API (instead of DNS Lookup) for Hazelcast discovery.

You can read more about Hazelcast Kubernetes discovery at: https://github.com/hazelcast/hazelcast-kubernetes.

Hope it helps,
Rafał

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at https://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/3b3a0e00-3686-44cc-88a5-3a0328722419%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Rafał Leszko
Software Engineer
@RafalLeszko
Reply all
Reply to author
Forward
0 new messages