diff --git a/deploy/examples/example-stan-cluster-metrics.yaml b/deploy/examples/example-stan-cluster-metrics.yaml new file mode 100644 index 0000000..27909a0 --- /dev/null +++ b/deploy/examples/example-stan-cluster-metrics.yaml @@ -0,0 +1,43 @@ +--- +apiVersion: "streaming.nats.io/v1alpha1" +kind: "NatsStreamingCluster" +metadata: + name: "example-stan" +spec: + # Number of nodes in the cluster + size: 3 + + # NATS Streaming Server image to use, by default + # the operator will use a stable version + # + image: "nats-streaming:0.12.2" + + # Service to which NATS Streaming Cluster nodes will connect. + # + natsSvc: "example-nats" + + config: + debug: true + trace: true + raftLogging: true + + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "7777" + spec: + containers: + + # Need to list the first container for the server, the operator + # will fill in the rest of the parameters. + - name: "stan" + + # Define the sidecar container and the paths that should be polled. + - name: "metrics" + image: "synadia/prometheus-nats-exporter:0.2.0" + args: ["-varz", "-channelz", "-serverz", "-DV", "http://localhost:8222"] + ports: + - name: "metrics" + containerPort: 7777 + protocol: TCP diff --git a/internal/operator/constants.go b/internal/operator/constants.go index 1aedef6..618d843 100644 --- a/internal/operator/constants.go +++ b/internal/operator/constants.go @@ -17,12 +17,12 @@ import "time" const ( // Version is the version of the NATS Streaming Operator. - Version = "0.2.0" - + Version = "0.3.0" + // DefaultNATSStreamingImage is the default image // of NATS Streaming that will be used, meant to be // the latest release available. - DefaultNATSStreamingImage = "nats-streaming:0.11.2" + DefaultNATSStreamingImage = "nats-streaming:0.12.2" // DefaultNATSStreamingClusterSize is the default size // for the cluster. Clustering is done via Raft so @@ -31,4 +31,7 @@ const ( // ResyncPeriod is how often the operator will be checking the resources. ResyncPeriod = 5 * time.Second + + // MonitoringPort is the port for the server monitoring endpoint. + MonitoringPort = 8222 ) diff --git a/internal/operator/controller.go b/internal/operator/controller.go index 96db960..1b40008 100644 --- a/internal/operator/controller.go +++ b/internal/operator/controller.go @@ -378,6 +378,7 @@ func stanContainerCmd(o *stanv1alpha1.NatsStreamingCluster, pod *k8scorev1.Pod) "/nats-streaming-server", "-cluster_id", o.Name, "-nats_server", fmt.Sprintf("nats://%s:4222", o.Spec.NatsService), + "-m", fmt.Sprintf("%d", MonitoringPort), } var storeArgs []string diff --git a/test/operator/basic_test.go b/test/operator/basic_test.go index 3650bc5..71287e1 100644 --- a/test/operator/basic_test.go +++ b/test/operator/basic_test.go @@ -151,6 +151,11 @@ func TestCreateClusterWithDebugFlags(t *testing.T) { if !strings.Contains(s, expectedFlag) { return fmt.Errorf("Does not contain %s flag", expectedFlag) } + + expectedFlag = "-m" + if !strings.Contains(s, expectedFlag) { + return fmt.Errorf("Does not contain %s flag", expectedFlag) + } } got := len(result.Items) @@ -315,7 +320,7 @@ func TestCreateWithCustomStoreDirTemplate(t *testing.T) { } for _, item := range result.Items { got := strings.Join(item.Spec.Containers[0].Command, " ") - expected := `/nats-streaming-server -cluster_id stan-cluster-custom-store-dir-test -nats_server nats://example-nats:4222 -store file --cluster_node_id="stan-cluster-custom-store-dir-test-1" -dir /my-store-dir/stan-cluster-custom-store-dir-test-1` + expected := `/nats-streaming-server -cluster_id stan-cluster-custom-store-dir-test -nats_server nats://example-nats:4222 -m 8222 -store file --cluster_node_id="stan-cluster-custom-store-dir-test-1" -dir /my-store-dir/stan-cluster-custom-store-dir-test-1` if got != expected { return fmt.Errorf("Expected %s, got: %s", expected, got) }