Skip to content

Commit

Permalink
Merge pull request #397 from serverlessworkflow/feat-kubernetes-runtime
Browse files Browse the repository at this point in the history
Add a new Kubernetes implementation of the IContainerPlatform interface
  • Loading branch information
cdavernas authored Sep 9, 2024
2 parents e511b71 + e92a8f1 commit 7193565
Show file tree
Hide file tree
Showing 47 changed files with 951 additions and 120 deletions.
14 changes: 12 additions & 2 deletions Synapse.sln
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{
deployments\helm\templates\services.yaml = deployments\helm\templates\services.yaml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Synapse.Runtime.Docker", "src\runtime\Synapse.Runtime.Docker\Synapse.Runtime.Docker.csproj", "{8FF58403-9E13-4F58-864F-E6FBC877BF37}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runtime.Docker", "src\runtime\Synapse.Runtime.Docker\Synapse.Runtime.Docker.csproj", "{8FF58403-9E13-4F58-864F-E6FBC877BF37}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Synapse.Runtime.Kubernetes", "src\runtime\Synapse.Runtime.Kubernetes\Synapse.Runtime.Kubernetes.csproj", "{9B37AA4A-A342-4A41-A2A1-C8466825A70A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runtime.Kubernetes", "src\runtime\Synapse.Runtime.Kubernetes\Synapse.Runtime.Kubernetes.csproj", "{9B37AA4A-A342-4A41-A2A1-C8466825A70A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Core.Infrastructure.Containers.Docker", "src\core\Synapse.Core.Infrastructure.Containers.Docker\Synapse.Core.Infrastructure.Containers.Docker.csproj", "{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "kubernetes", "kubernetes", "{B3F3DB1B-23E7-45FA-8934-448BFFB294E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Synapse.Core.Infrastructure.Containers.Kubernetes", "src\core\Synapse.Core.Infrastructure.Containers.Kubernetes\Synapse.Core.Infrastructure.Containers.Kubernetes.csproj", "{41C99069-BD99-4FD2-BF33-984CF03B53E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -224,6 +228,10 @@ Global
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}.Release|Any CPU.Build.0 = Release|Any CPU
{41C99069-BD99-4FD2-BF33-984CF03B53E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41C99069-BD99-4FD2-BF33-984CF03B53E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41C99069-BD99-4FD2-BF33-984CF03B53E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41C99069-BD99-4FD2-BF33-984CF03B53E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -262,6 +270,8 @@ Global
{8FF58403-9E13-4F58-864F-E6FBC877BF37} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
{9B37AA4A-A342-4A41-A2A1-C8466825A70A} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA} = {9E296C8A-4D78-4592-B046-11A3A953FD25}
{B3F3DB1B-23E7-45FA-8934-448BFFB294E8} = {562C91A3-6E91-4489-9D9D-064E7436D900}
{41C99069-BD99-4FD2-BF33-984CF03B53E8} = {9E296C8A-4D78-4592-B046-11A3A953FD25}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2A6C03D6-355A-4B39-9F2B-D0FDE429C0E2}
Expand Down
16 changes: 12 additions & 4 deletions deployments/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ spec:
- name: CONNECTIONSTRINGS__REDIS
value: {{ .Values.global.redisConnectionString }}
- name: SYNAPSE_OPERATOR_NAMESPACE
value: {{ .Values.operator.env.SYNAPSE_OPERATOR_NAMESPACE }}
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: SYNAPSE_OPERATOR_NAME
value: {{ .Values.operator.env.SYNAPSE_OPERATOR_NAME }}
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: SYNAPSE_OPERATOR_RUNNER_API
value: {{ .Values.operator.env.SYNAPSE_OPERATOR_RUNNER_API }}
- name: DOCKER_HOST
Expand Down Expand Up @@ -128,9 +132,13 @@ spec:
- name: CONNECTIONSTRINGS__REDIS
value: {{ .Values.global.redisConnectionString }}
- name: SYNAPSE_CORRELATOR_NAMESPACE
value: {{ .Values.correlator.env.SYNAPSE_CORRELATOR_NAMESPACE }}
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: SYNAPSE_CORRELATOR_NAME
value: {{ .Values.correlator.env.SYNAPSE_CORRELATOR_NAME }}
valueFrom:
fieldRef:
fieldPath: metadata.name
---
apiVersion: v1
kind: PersistentVolumeClaim
Expand Down
5 changes: 0 additions & 5 deletions deployments/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ operator:
service:
type: ClusterIP
env:
SYNAPSE_OPERATOR_NAMESPACE: default
SYNAPSE_OPERATOR_NAME: operator-1
SYNAPSE_OPERATOR_RUNNER_API: http://api:8080
DOCKER_HOST: unix:///var/run/docker.sock

Expand All @@ -45,9 +43,6 @@ correlator:
service:
type: ClusterIP
port: 8081
env:
SYNAPSE_CORRELATOR_NAMESPACE: default
SYNAPSE_CORRELATOR_NAME: correlator-1

serviceAccount:
create: true
Expand Down
53 changes: 53 additions & 0 deletions deployments/kubernetes/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-1
namespace: synapse
spec:
replicas: 1
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- name: api
image: ghcr.io/serverlessworkflow/synapse/api:1.0.0-alpha1
env:
- name: CONNECTIONSTRINGS__REDIS
value: garnet:6379
- name: SYNAPSE_DASHBOARD_SERVE
value: 'true'
- name: SYNAPSE_API_AUTH_TOKEN_FILE
value: /app/tokens.yaml
- name: SYNAPSE_API_JWT_AUTHORITY
value: http://api:8080
- name: SYNAPSE_API_CLOUD_EVENTS_ENDPOINT
value: https://webhook.site/a4aff725-0711-48b2-a9d2-5d1b806d04d0
ports:
- containerPort: 8080
volumeMounts:
- name: tokens
mountPath: /app/tokens.yaml
subPath: tokens.yaml
volumes:
- name: tokens
hostPath:
path: /run/desktop/mnt/host/c/Users/User/.synapse
---

apiVersion: v1
kind: Service
metadata:
name: api
namespace: synapse
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: api
type: ClusterIP
42 changes: 42 additions & 0 deletions deployments/kubernetes/correlator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: correlator-1
namespace: synapse
spec:
replicas: 1
selector:
matchLabels:
app: correlator
template:
metadata:
labels:
app: correlator
spec:
containers:
- name: correlator
image: ghcr.io/serverlessworkflow/synapse/correlator:1.0.0-alpha1
env:
- name: CONNECTIONSTRINGS__REDIS
value: garnet:6379
- name: SYNAPSE_CORRELATOR_NAMESPACE
value: default
- name: SYNAPSE_CORRELATOR_NAME
value: correlator-1
ports:
- containerPort: 8080

---

apiVersion: v1
kind: Service
metadata:
name: correlator
namespace: synapse
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: correlator
type: ClusterIP
35 changes: 35 additions & 0 deletions deployments/kubernetes/garnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: garnet
namespace: synapse
spec:
replicas: 1
selector:
matchLabels:
app: garnet
template:
metadata:
labels:
app: garnet
spec:
containers:
- name: garnet
image: ghcr.io/microsoft/garnet
ports:
- containerPort: 6379

---

apiVersion: v1
kind: Service
metadata:
name: garnet
namespace: synapse
spec:
ports:
- port: 6379
targetPort: 6379
selector:
app: garnet
type: ClusterIP
4 changes: 4 additions & 0 deletions deployments/kubernetes/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: synapse
86 changes: 86 additions & 0 deletions deployments/kubernetes/operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: operator
namespace: synapse

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: operator-role
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch", "create", "update", "delete"]

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: operator-role-binding
subjects:
- kind: ServiceAccount
name: operator
namespace: synapse
roleRef:
kind: ClusterRole
name: operator-role
apiGroup: rbac.authorization.k8s.io

---

apiVersion: apps/v1
kind: Deployment
metadata:
name: operator-1
namespace: synapse
spec:
replicas: 1
selector:
matchLabels:
app: operator
template:
metadata:
labels:
app: operator
spec:
serviceAccountName: operator
containers:
- name: operator
image: ghcr.io/serverlessworkflow/synapse/operator:1.0.0-alpha1
env:
- name: CONNECTIONSTRINGS__REDIS
value: garnet:6379
- name: SYNAPSE_OPERATOR_NAMESPACE
value: default
- name: SYNAPSE_OPERATOR_NAME
value: operator-1
- name: SYNAPSE_RUNNER_API
value: http://api:8080
- name: SYNAPSE_RUNNER_LIFECYCLE_EVENTS
value: "true"
- name: SYNAPSE_RUNNER_CONTAINER_PLATFORM
value: kubernetes
- name: SYNAPSE_RUNTIME_MODE
value: kubernetes
- name: SYNAPSE_RUNTIME_K8S_SERVICE_ACCOUNT
value: operator
- name: SYNAPSE_RUNTIME_K8S_NAMESPACE
value: synapse
---

apiVersion: v1
kind: Service
metadata:
name: operator
namespace: synapse
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: operator
type: ClusterIP
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<PackageIcon>transparent_logomark_256.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Description>Contains the Synapse API commands, queries and services</Description>
<AssemblyInformationalVersion>$(VersionPrefix)-$(VersionSuffix)</AssemblyInformationalVersion>
<AssemblyVersion>$(VersionPrefix).0</AssemblyVersion>
<FileVersion>$(VersionPrefix).0</FileVersion>
<DebugType>embedded</DebugType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<PackageIcon>transparent_logomark_256.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Description>Contains abstractions and interfaces used by clients of the Synapse API</Description>
<AssemblyInformationalVersion>$(VersionPrefix)-$(VersionSuffix)</AssemblyInformationalVersion>
<AssemblyVersion>$(VersionPrefix).0</AssemblyVersion>
<FileVersion>$(VersionPrefix).0</FileVersion>
<DebugType>embedded</DebugType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<PackageIcon>transparent_logomark_256.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Description>Contains the HTTP client for the Synapse API</Description>
<AssemblyInformationalVersion>$(VersionPrefix)-$(VersionSuffix)</AssemblyInformationalVersion>
<AssemblyVersion>$(VersionPrefix).0</AssemblyVersion>
<FileVersion>$(VersionPrefix).0</FileVersion>
<DebugType>embedded</DebugType>
Expand Down
1 change: 1 addition & 0 deletions src/api/Synapse.Api.Http/Synapse.Api.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<PackageIcon>transparent_logomark_256.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Description>Contains the services and controllers used by Synapse HTTP API</Description>
<AssemblyInformationalVersion>$(VersionPrefix)-$(VersionSuffix)</AssemblyInformationalVersion>
<AssemblyVersion>$(VersionPrefix).0</AssemblyVersion>
<FileVersion>$(VersionPrefix).0</FileVersion>
<DebugType>embedded</DebugType>
Expand Down
1 change: 1 addition & 0 deletions src/api/Synapse.Api.Server/Synapse.Api.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<PackageTags>synapse api server</PackageTags>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<AssemblyInformationalVersion>$(VersionPrefix)-$(VersionSuffix)</AssemblyInformationalVersion>
<AssemblyVersion>$(VersionPrefix).0</AssemblyVersion>
<FileVersion>$(VersionPrefix).0</FileVersion>
<DebugType>embedded</DebugType>
Expand Down
1 change: 1 addition & 0 deletions src/cli/Synapse.Cli/Synapse.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<AssemblyInformationalVersion>$(VersionPrefix)-$(VersionSuffix)</AssemblyInformationalVersion>
<AssemblyVersion>$(VersionPrefix).0</AssemblyVersion>
<FileVersion>$(VersionPrefix).0</FileVersion>
<DebugType>embedded</DebugType>
Expand Down
Loading

0 comments on commit 7193565

Please sign in to comment.