Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) Listen to NATS/JetStream for CloudEvents #338

Merged
merged 1 commit into from
Jan 30, 2025
Merged

(feat) Listen to NATS/JetStream for CloudEvents #338

merged 1 commit into from
Jan 30, 2025

Conversation

gianlucam76
Copy link
Member

Sveltos-agent gets NATS/JetStream configuration from a Secret in the projectsveltos namespace. The Secret name is sveltos-nats. The key in the Secret with configuration is named ``sveltos-nats`.

This is a configuration example

  "nats":
   {
     "configuration":
        {
            "url": "nats://nats.nats.svc.cluster.local:4222",
            "subjects": [
                "test",
                "foo"
            ],
            "authorization": {
                "user": {
                    "user": "admin",
                    "password": "password"
                }
            }
        }
   }
}

JetStream can also be configured. Create a section jetstream with same fields as NATS.

Authorization also allows specifying:

  • token
  • clientCert _ root CA

Here is the golang structures

type messagingUser struct {
	User     string `json:"user"`
	Password string `json:"password"`
}

type clientCert struct {
	CertPem []byte `json:"certPem"`
	KeyPem  []byte `json:"keyPem"`
}

type messagingAuthorization struct {
	User       *messagingUser `json:"user,omitempty"`
	Token      *string        `json:"token,omitempty"`
	ClientCert *clientCert    `json:"clientCert,omitempty"`
	RootCA     []byte         `json:"rootCA,omitempty"`
}

type configuration struct {
	URL           string                 `json:"url"`
	Subjects      []string               `json:"subjects"`
	Authorization messagingAuthorization `json:"authorization,omitempty"`
}

type natsConfiguration struct {
	Configuration configuration `json:"configuration"`
}

type jetstreamConfiguration struct {
	Configuration configuration `json:"configuration"`
}

type messagingConfig struct {
	Nats      *natsConfiguration      `json:"nats,omitempty"`
	Jetstream *jetstreamConfiguration `json:"jetstream,omitempty"`
}

Sveltos-agent gets NATS/JetStream configuration from a Secret
in the projectsveltos namespace. The Secret name is `sveltos-nats`.
The key in the Secret with configuration is named ``sveltos-nats`.

This is a configuration example

```
  "nats":
   {
     "configuration":
        {
            "url": "nats://nats.nats.svc.cluster.local:4222",
            "subjects": [
                "test",
                "foo"
            ],
            "authorization": {
                "user": {
                    "user": "admin",
                    "password": "password"
                }
            }
        }
   }
}
```

JetStream can also be configured. Create a section `jetstream` with same fields as NATS.

Authorization also allows specifying:

- token
- clientCert
_ root CA

Here is the golang structures

```go
type messagingUser struct {
	User     string `json:"user"`
	Password string `json:"password"`
}

type clientCert struct {
	CertPem []byte `json:"certPem"`
	KeyPem  []byte `json:"keyPem"`
}

type messagingAuthorization struct {
	User       *messagingUser `json:"user,omitempty"`
	Token      *string        `json:"token,omitempty"`
	ClientCert *clientCert    `json:"clientCert,omitempty"`
	RootCA     []byte         `json:"rootCA,omitempty"`
}

type configuration struct {
	URL           string                 `json:"url"`
	Subjects      []string               `json:"subjects"`
	Authorization messagingAuthorization `json:"authorization,omitempty"`
}

type natsConfiguration struct {
	Configuration configuration `json:"configuration"`
}

type jetstreamConfiguration struct {
	Configuration configuration `json:"configuration"`
}

type messagingConfig struct {
	Nats      *natsConfiguration      `json:"nats,omitempty"`
	Jetstream *jetstreamConfiguration `json:"jetstream,omitempty"`
}

```
@gianlucam76 gianlucam76 merged commit 63c8e21 into main Jan 30, 2025
3 checks passed
@gianlucam76 gianlucam76 deleted the nats branch January 30, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant