0

I'm running Hazelcast statefulset on dev branch. This is my statefulset YAML file:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: hazelcast
  namespace: dev
  labels:
    app: hazelcast
spec:
  replicas: 3
  serviceName: hazelcast-service
  selector:
    matchLabels:
      app: hazelcast
  template:
    metadata:
      labels:
        app: hazelcast
    spec:
      containers:
      - name: hazelcast
        image: hazelcast:3.12.4
        ports:
        - name: hazelcast
          containerPort: 5701
        livenessProbe:
          httpGet:
            path: /hazelcast/health/node-state
            port: 5701
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /hazelcast/health/node-state
            port: 5701
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 1
          successThreshold: 1
          failureThreshold: 1
        volumeMounts:
        - name: hazelcast-storage
          mountPath: /data/hazelcast
        env:
        - name: JAVA_OPTS
          value: "-Dhazelcast.rest.enabled=true -Dhazelcast.config=/data/hazelcast/hazelcast.xml"
      volumes:
      - name: hazelcast-storage
        configMap:
          name: hazelcast-configuration

---

apiVersion: v1
kind: Service
metadata:
  name: hazelcast-service
  namespace: dev
spec:
  type: ClusterIP
  selector:
    app: hazelcast
  ports:
  - protocol: TCP
    port: 5701

Hazelcast Config File:

apiVersion: v1
kind: ConfigMap
metadata:
  name: hazelcast-configuration
  namespace: dev
data:
  hazelcast.xml: |-
    <?xml version="1.0" encoding="UTF-8"?>
    <hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.8.xsd"
    xmlns="http://www.hazelcast.com/schema/config"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <properties>
        <!-- only necessary prior Hazelcast 3.8 -->
        <property name="hazelcast.discovery.enabled">true</property>
      </properties>
      <network>
        <join>
          <!-- deactivate normal discovery -->
          <multicast enabled="false"/>
          <tcp-ip enabled="false" />

          <!-- activate the Kubernetes plugin -->
          <discovery-strategies>
            <discovery-strategy enabled="true"
                class="com.hazelcast.kubernetes.HazelcastKubernetesDiscoveryStrategy">
            <properties>
              <!-- configure discovery service API lookup -->
              <property name="service-name">hazelcast-service</property>
              <property name="namespace">dev</property>
            </properties>
          </discovery-strategy>
          </discovery-strategies>
        </join>
        </network>
    </hazelcast>

And this is rbac:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: default-cluster
  namespace: dev
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: view
subjects:
- kind: ServiceAccount
  name: default
  namespace: dev

But my microservice couldn't connect to the Hazelcast cluster and get members. This is my error:

Kubernetes API forbidden access, please check that your Service Account have the correct (Cluster) Role rules

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.