I installed the nats-streaming-operator to my minikube cluster. It installed without any issue. Since nats service created by nats-operator is a ClusterIP one I unable to send data into that service externally. So I tried two approaches to send data.
Approach 1
Create a service like below of type LoadBalancer and try to send data.
apiVersion: v1
kind: Service
metadata:
name: nats-streaming
namespace: default
labels:
app: nats-streaming
stan_cluster: siddhi-stan
spec:
externalTrafficPolicy: Cluster
ports:
- name: natsservice
port: 4222
protocol: TCP
targetPort: 4222
- name: natsservice-proxy
port: 8222
protocol: TCP
targetPort: 8222
selector:
app: nats-streaming
stan_cluster: siddhi-stan
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer: {}
Approach 2
Create a different kubernetes deployment of https://github.com/nats-io/go-nats-streaming/tree/master/examples and use that deployment to send data.
I used the following command to send requests.
go run $GOPATH/src/github.com/nats-io/go-nats-streaming/examples/stan-pub/main.go --server nats://nats-streaming.default.svc.cluster.local:4222 <SUBJECT> "{\"name\":\"data\"}"
But from both approaches, I got an error as
Can't connect: stan: connect request timeout.
Make sure a NATS Streaming Server is running at: nats://nats-streaming:4222
exit status 1
So I want to know that how can I external send data to nats-streaming-server in the kubernetes cluster?
Specifications
- minikube version: v0.33.1
- kubernetes version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.2", GitCommit:"cff46ab41ff0bb44d8584413b598ad8360ec1def", GitTreeState:"clean", BuildDate:"2019-01-10T23:28:14Z", GoVersion:"go1.11.4", Compiler:"gc", Platform:"linux/amd64"}
I installed the
nats-streaming-operatorto my minikube cluster. It installed without any issue. Sincenatsservice created bynats-operatoris aClusterIPone I unable to send data into that service externally. So I tried two approaches to send data.Approach 1
Create a service like below of type
LoadBalancerand try to send data.Approach 2
Create a different kubernetes deployment of https://github.com/nats-io/go-nats-streaming/tree/master/examples and use that deployment to send data.
I used the following command to send requests.
But from both approaches, I got an error as
So I want to know that how can I external send data to
nats-streaming-serverin the kubernetes cluster?Specifications