I have created Cassandra stateful/headless cluster on AWS and it's working fine inside the cluster. The only problem is I am not able to access it from outside cluster. I tried most of the things on the Kubernetes documentation or StackOverflow references, but still not able to solve it.
I have a working security group from AWS. Here are my service and statefulset yaml files.
apiVersion: v1 kind: Service metadata: name: cassandra spec: externalTrafficPolicy: Local ports: - nodePort: 30000 port: 30000 protocol: TCP targetPort: 9042 selector: app: cassandra type: NodePort
apiVersion: "apps/v1" kind: StatefulSet metadata: name: cassandra spec: serviceName: cassandra replicas: 2 selector: matchLabels: app: cassandra template: metadata: labels: role: cassandra app: cassandra spec: terminationGracePeriodSeconds: 10 containers: - env: - name: MAX_HEAP_SIZE value: 1024M - name: HEAP_NEWSIZE value: 1024M - name: CASSANDRA_SEEDS value: "cassandra-0.cassandra.default.svc.cluster.local" - name: CASSANDRA_CLUSTER_NAME value: "SetuCassandra" - name: CASSANDRA_DC value: "DC1-SetuCassandra" - name: CASSANDRA_RACK value: "Rack1-SetuCassandra" - name: CASSANDRA_SEED_PROVIDER value: io.k8s.cassandra.KubernetesSeedProvider - name: POD_IP valueFrom: fieldRef: fieldPath: status.podIP image: library/cassandra:3.11 name: cassandra volumeMounts: - mountPath: /cassandra-storage name: cassandra-storage ports: - containerPort: 9042 name: cql volumeClaimTemplates: - metadata: name: cassandra-storage spec: accessModes: - ReadWriteOnce resources: requests: storage: 320Gi
There are not enough details on the AWS security groups. But my guess is that your security group(s) in your cluster are not allowing traffic from the security groups or IP addresses from the other cluster. Something like this: