Skip to content

Commit 6f57090

Browse files
committed
feat(Runner): Added secrets support
feat(Core): Updated environment variables and added new ones to fully configure runtimes feat(Docs): Updated the README.md to include a Synapse preview GIF and an architecture overview diagram Signed-off-by: Charles d'Avernas <[email protected]>
1 parent dd2e75f commit 6f57090

File tree

28 files changed

+477
-60
lines changed

28 files changed

+477
-60
lines changed

.dockerignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@
2121
**/obj
2222
**/secrets.dev.yaml
2323
**/values.dev.yaml
24-
LICENSE
25-
README.md
24+
LICENSE

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<p align="center">
2-
<img src="assets/images/transparent_logo.png" height="350px" alt="Synapse Logo"/>
1+
<p align="center">
2+
<img src="./assets/images/transparent_logo.png" height="350px" alt="Synapse Logo"/>
33
</p>
44

55
---
@@ -19,6 +19,10 @@ It enables developers and organizations to define and execute workflows effortle
1919

2020
With Synapse, you can create powerful workflows that are cloud vendor-agnostic, easily scalable, and highly customizable.
2121

22+
<p align="center">
23+
<img src="./assets/images/preview.gif" alt="Synapse Preview"/>
24+
</p>
25+
2226
### Features
2327

2428
- **Easy to Use**: The Serverless Workflow DSL is designed for universal understanding, enabling users to quickly grasp workflow concepts and create complex workflows effortlessly.
@@ -33,7 +37,7 @@ With Synapse, you can create powerful workflows that are cloud vendor-agnostic,
3337
- **Scalable**: Promotes code reusability, maintainability, and scalability across different environments.
3438
- **Cross-Platform**: Runs on various operating systems, providing flexibility and ease of integration.
3539

36-
### Microservices
40+
### Architecture
3741

3842
Synapse is composed of several specialized applications, allowing for atomic scalability, resilience, and ease of maintenance:
3943

@@ -43,6 +47,12 @@ Synapse is composed of several specialized applications, allowing for atomic sca
4347
- **Correlator**: Performs Complex Event Processing (CEP) and correlates ingested events.
4448
- **CLI**: Allows interaction with the Synapse API via the command line interface.
4549

50+
<p align="center">
51+
<img src="./assets/images/architecture-c4-l2.png" alt="Synapse Architecture C4 Diagram - Container Layer"/>
52+
</p>
53+
54+
*For more information about the Synapse architecture, please refer to the [wiki](https://github.com/serverlessworkflow/synapse/wiki/Architecture).* 📖
55+
4656
## Getting Started
4757

4858
### Prerequisites
@@ -79,6 +89,8 @@ The simplest way to get started is by using the provided Docker Compose setup.
7989

8090
This will pull the necessary Docker images and start the Synapse services as defined in the `docker-compose.yml` file. You can then access the Synapse API and dashboard as configured.
8191

92+
*For more information about installing Synapse, please refer to the [wiki](https://github.com/serverlessworkflow/synapse/wiki/Installation)*. 📖
93+
8294
### Run using `synctl` Command-line Interface
8395

8496
First, set up the Synapse API server to use with `synctl`:
@@ -120,15 +132,15 @@ The command above will provide the fully qualified name of the created workflow
120132
synctl workflow-instance get-output greeter-uk58h3dssqp620a --namespace default --output yaml
121133
```
122134

123-
For more information about `synctl`, please refer to the [documentation](#synctl).
135+
*For more information about `synctl`, please refer to the [wiki](https://github.com/serverlessworkflow/synapse/wiki/CLI-Usage).* 📖
124136

125137
## Community
126138

127139
The Synapse project has a vibrant and growing community dedicated to building a community-driven and vendor-neutral workflow runtime ecosystem. Contributions from the community are encouraged and essential to the continued growth and success of the project.
128140

129-
A list of community members who have contributed to Synapse can be found [here](./community/README.md).
141+
A list of community members who have contributed to Synapse can be found [here](./community/README.md). 👥
130142

131-
To learn how to contribute to Synapse, please refer to the [contribution guidelines](CONTRIBUTING.md).
143+
To learn how to contribute to Synapse, please refer to the [contribution guidelines](CONTRIBUTING.md). 📝
132144

133145
For any copyright-related questions when contributing to a CNCF project like Synapse, please refer to the [Ownership of Copyrights in CNCF Project Contributions](https://github.com/cncf/foundation/blob/master/copyright-notices.md) document.
134146

@@ -138,5 +150,5 @@ As contributors and maintainers of Synapse, and in the interest of fostering an
138150

139151
The project is committed to making participation in Synapse a harassment-free experience for everyone, regardless of experience level, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
140152

141-
For more detailed information, please see the full project Code of Conduct [here](code-of-conduct.md).
153+
For more detailed information, please see the full project Code of Conduct [here](code-of-conduct.md). 🛡️
142154

assets/images/architecture-c4-l2.png

337 KB
Loading

assets/images/preview.gif

1.68 MB
Loading

deployments/docker-compose/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ services:
2929
SYNAPSE_RUNNER_API: http://api:8080
3030
SYNAPSE_RUNNER_LIFECYCLE_EVENTS: true
3131
SYNAPSE_RUNNER_CONTAINER_PLATFORM: docker
32+
SYNAPSE_RUNTIME_DOCKER_SECRETS_DIRECTORY: C:\Users\User\.synapse\secrets
3233
DOCKER_HOST: unix:///var/run/docker.sock
3334
extra_hosts:
3435
- "host.docker.internal:host-gateway"

src/api/Synapse.Api.Server/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ EXPOSE 8080
66
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
77
ARG BUILD_CONFIGURATION=Release
88
WORKDIR /src
9+
COPY ["README.md", "README.md"]
10+
COPY ["assets/images/transparent_logomark_256.png", "assets/images/transparent_logomark_256.png"]
911
COPY ["src/api/Synapse.Api.Server/Synapse.Api.Server.csproj", "src/api/Synapse.Api.Server/"]
1012
RUN dotnet restore "./src/api/Synapse.Api.Server/Synapse.Api.Server.csproj"
1113
COPY . .

src/core/Synapse.Core.Infrastructure/Services/OAuth2TokenManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public virtual async Task<OAuth2Token> GetTokenAsync(OAuth2AuthenticationSchemeD
6666
{
6767
var discoveryRequest = new DiscoveryDocumentRequest()
6868
{
69-
Address = configuration.Authority.OriginalString,
69+
Address = configuration.Authority!.OriginalString,
7070
Policy = new()
7171
{
7272
RequireHttps = false
@@ -80,7 +80,7 @@ public virtual async Task<OAuth2Token> GetTokenAsync(OAuth2AuthenticationSchemeD
8080
else throw new NotSupportedException($"The specified scheme type '{configuration.GetType().FullName}' is not supported in this context");
8181
var properties = new Dictionary<string, string>()
8282
{
83-
{ "grant_type", configuration.Grant }
83+
{ "grant_type", configuration.Grant! }
8484
};
8585
switch (configuration.Client?.Authentication)
8686
{
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright © 2024-Present The Synapse Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace Synapse;
15+
16+
/// <summary>
17+
/// Defines extensions for <see cref="AuthenticationPolicyDefinition"/>s
18+
/// </summary>
19+
public static class AuthenticationPolicyDefinitionExtensions
20+
{
21+
22+
/// <summary>
23+
/// Attempts to get the name of the secret, if any, on which the <see cref="AuthenticationPolicyDefinition"/> is based
24+
/// </summary>
25+
/// <param name="authentication">The extended <see cref="AuthenticationPolicyDefinition"/></param>
26+
/// <param name="secretName">The name of the secret, if any, on which the <see cref="AuthenticationPolicyDefinition"/> is based</param>
27+
/// <returns>A boolean indicating whether or not the <see cref="AuthenticationPolicyDefinition"/> is secret based</returns>
28+
public static bool TryGetBaseSecret(this AuthenticationPolicyDefinition authentication, out string? secretName)
29+
{
30+
secretName = authentication.Scheme switch
31+
{
32+
AuthenticationScheme.Basic => authentication.Basic?.Use,
33+
AuthenticationScheme.Bearer => authentication.Bearer?.Use,
34+
AuthenticationScheme.Certificate => authentication.Certificate?.Use,
35+
AuthenticationScheme.Digest => authentication.Digest?.Use,
36+
AuthenticationScheme.OAuth2 => authentication.OAuth2?.Use,
37+
AuthenticationScheme.OpenIDConnect => authentication.Oidc?.Use,
38+
_ => throw new NotSupportedException($"The specified authentication schema '{authentication.Scheme}' is not supported")
39+
};
40+
return !string.IsNullOrWhiteSpace(secretName);
41+
}
42+
43+
}

src/core/Synapse.Core/Resources/DockerRuntimeConfiguration.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,38 @@ public record DockerRuntimeConfiguration
3535
Image = SynapseDefaults.Containers.Images.Runner
3636
};
3737

38+
/// <summary>
39+
/// Initializes a new <see cref="DockerRuntimeConfiguration"/>
40+
/// </summary>
41+
public DockerRuntimeConfiguration()
42+
{
43+
var env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Docker.Api.Endpoint);
44+
if (!string.IsNullOrWhiteSpace(env) && Uri.TryCreate(env, UriKind.RelativeOrAbsolute, out var uri)) this.Api.Endpoint = uri;
45+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Docker.Api.Version);
46+
if (!string.IsNullOrWhiteSpace(env)) this.Api.Version = env;
47+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Docker.Image.Registry);
48+
if (!string.IsNullOrWhiteSpace(env)) this.ImageRegistry = env;
49+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Docker.Image.PullPolicy);
50+
if (!string.IsNullOrWhiteSpace(env)) this.ImagePullPolicy = env;
51+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Docker.Secrets.Directory);
52+
if (!string.IsNullOrWhiteSpace(env)) this.Secrets.Directory = env;
53+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Docker.Secrets.MountPath);
54+
if (!string.IsNullOrWhiteSpace(env)) this.Secrets.MountPath = env;
55+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Docker.Network);
56+
if (!string.IsNullOrWhiteSpace(env)) this.Network = env;
57+
}
58+
3859
/// <summary>
3960
/// Gets/sets the Docker API to use
4061
/// </summary>
4162
[DataMember(Order = 1, Name = "api"), JsonPropertyOrder(1), JsonPropertyName("api"), YamlMember(Order = 1, Alias = "api")]
4263
public virtual DockerApiConfiguration Api { get; set; } = new();
4364

4465
/// <summary>
45-
/// Gets/sets the name of the image repository to use when pulling the runtime's container image
66+
/// Gets/sets the name of the image registry to use when pulling the runtime's container image
4667
/// </summary>
47-
[DataMember(Order = 2, Name = "imageRepository"), JsonPropertyOrder(2), JsonPropertyName("imageRepository"), YamlMember(Order = 2, Alias = "imageRepository")]
48-
public virtual string? ImageRepository { get; set; }
68+
[DataMember(Order = 2, Name = "imageRegistry"), JsonPropertyOrder(2), JsonPropertyName("imageRegistry"), YamlMember(Order = 2, Alias = "imageRegistry")]
69+
public virtual string? ImageRegistry { get; set; }
4970

5071
/// <summary>
5172
/// Gets/sets the Docker image pull policy. Supported values are 'Always', 'IfNotPresent' and 'Never'. Defaults to 'Always'.

src/core/Synapse.Core/Resources/KubernetesRuntimeConfiguration.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ public record KubernetesRuntimeConfiguration
5252
}
5353
};
5454

55+
/// <summary>
56+
/// Initializes a new <see cref="KubernetesRuntimeConfiguration"/>
57+
/// </summary>
58+
public KubernetesRuntimeConfiguration()
59+
{
60+
var env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Kubernetes.Kubeconfig);
61+
if (!string.IsNullOrWhiteSpace(env)) this.Kubeconfig = env;
62+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Kubernetes.Secrets.VolumeName);
63+
if (!string.IsNullOrWhiteSpace(env)) this.Secrets.VolumeName = env;
64+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Kubernetes.Secrets.MountPath);
65+
if (!string.IsNullOrWhiteSpace(env)) this.Secrets.MountPath = env;
66+
}
67+
5568
/// <summary>
5669
/// Gets/sets the path to the Kubeconfig file to use, if any. If not set, defaults to 'InCluster' configuration
5770
/// </summary>
@@ -76,7 +89,7 @@ public record KubernetesRuntimeConfiguration
7689
/// <returns>The runner container template</returns>
7790
public static V1Pod LoadPodTemplate()
7891
{
79-
var templateFilePath = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Docker.Container);
92+
var templateFilePath = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Kubernetes.Pod);
8093
if (string.IsNullOrWhiteSpace(templateFilePath) || !File.Exists(templateFilePath)) return DefaultPodTemplate;
8194
var yaml = File.ReadAllText(templateFilePath);
8295
return YamlSerializer.Default.Deserialize<V1Pod>(yaml)!;

0 commit comments

Comments
 (0)