Skip to content

Commit 4fbd7ab

Browse files
App erudika-scoold on branch main
1 parent 0028ed5 commit 4fbd7ab

File tree

12 files changed

+435
-0
lines changed

12 files changed

+435
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
spec:
2+
name: deploystack
3+
region: nyc
4+
services:
5+
- name: default
6+
image:
7+
registry_type: DOCKER_HUB
8+
registry: erudikaltd
9+
repository: scoold
10+
tag: latest_stable
11+
instance_count: 1
12+
instance_size_slug: basic-xxs
13+
run_command: ""
14+
envs:
15+
- key: JAVA_OPTS
16+
value: -Dconfig.file=/scoold/application.conf
17+
scope: RUN_TIME
18+
http_port: 8000
19+
routes:
20+
- path: /
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
AWSTemplateFormatVersion: 2010-09-09
2+
Description: Generated from container configuration by docker-to-iac
3+
Parameters:
4+
VPC:
5+
Type: AWS::EC2::VPC::Id
6+
SubnetA:
7+
Type: AWS::EC2::Subnet::Id
8+
SubnetB:
9+
Type: AWS::EC2::Subnet::Id
10+
ServiceName:
11+
Type: String
12+
Default: DeployStackService
13+
Resources:
14+
Cluster:
15+
Type: AWS::ECS::Cluster
16+
Properties:
17+
ClusterName: !Join ['', [!Ref ServiceName, Cluster]]
18+
ExecutionRole:
19+
Type: AWS::IAM::Role
20+
Properties:
21+
RoleName: !Join ['', [!Ref ServiceName, ExecutionRole]]
22+
AssumeRolePolicyDocument:
23+
Statement:
24+
- Effect: Allow
25+
Principal:
26+
Service: ecs-tasks.amazonaws.com
27+
Action: sts:AssumeRole
28+
ManagedPolicyArns:
29+
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
30+
LogGroupdefault:
31+
Type: AWS::Logs::LogGroup
32+
Properties:
33+
LogGroupName: !Join ['', [/ecs/, !Ref ServiceName, TaskDefinitiondefault]]
34+
TaskDefinitiondefault:
35+
Type: AWS::ECS::TaskDefinition
36+
DependsOn:
37+
- LogGroupdefault
38+
Properties:
39+
Family: !Join ['', [!Ref ServiceName, TaskDefinitiondefault]]
40+
NetworkMode: awsvpc
41+
RequiresCompatibilities:
42+
- FARGATE
43+
Cpu: 512
44+
Memory: 1GB
45+
ExecutionRoleArn: !Ref ExecutionRole
46+
ContainerDefinitions:
47+
- Name: default
48+
Image: docker.io/erudikaltd/scoold:latest_stable
49+
ReadonlyRootFilesystem: false
50+
PortMappings:
51+
- ContainerPort: 8000
52+
Environment:
53+
- name: JAVA_OPTS
54+
value: -Dconfig.file=/scoold/application.conf
55+
LogConfiguration:
56+
LogDriver: awslogs
57+
Options:
58+
awslogs-region: !Ref AWS::Region
59+
awslogs-group: !Ref LogGroupdefault
60+
awslogs-stream-prefix: ecs
61+
ContainerSecurityGroupdefault:
62+
Type: AWS::EC2::SecurityGroup
63+
Properties:
64+
GroupDescription: !Join ['', [default, ContainerSecurityGroup]]
65+
VpcId: !Ref VPC
66+
SecurityGroupIngress:
67+
IpProtocol: tcp
68+
FromPort: 0
69+
ToPort: 65535
70+
CidrIp: 0.0.0.0/0
71+
Servicedefault:
72+
Type: AWS::ECS::Service
73+
Properties:
74+
ServiceName: default
75+
Cluster: !Ref Cluster
76+
TaskDefinition: !Ref TaskDefinitiondefault
77+
DesiredCount: 1
78+
LaunchType: FARGATE
79+
NetworkConfiguration:
80+
AwsvpcConfiguration:
81+
AssignPublicIp: ENABLED
82+
Subnets:
83+
- !Ref SubnetA
84+
- !Ref SubnetB
85+
SecurityGroups:
86+
- !Ref ContainerSecurityGroupdefault

erudika-scoold/docker-run.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker run -ti -p 8000:8000 -v ./scoold-application.conf:/scoold/application.conf -e JAVA_OPTS="-Dconfig.file=/scoold/application.conf" erudikaltd/scoold:latest_stable

erudika-scoold/helm/Chart.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v2
2+
name: erudika-scoold
3+
description: A Helm chart for DeployStack application generated from Docker configuration
4+
type: application
5+
version: 0.1.0
6+
appVersion: 1.0.0
7+
maintainers:
8+
- name: DeployStack
9+
10+
dependencies: []
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
Thank you for installing {{ .Chart.Name }}.
3+
4+
Your application has been deployed successfully!
5+
6+
{{- range $key, $service := .Values.services }}
7+
{{- if and $service.enabled $service.service.ports }}
8+
9+
Service {{ $key }}:
10+
{{- if contains "NodePort" $service.service.type }}
11+
Access on: http://NODE_IP:NODE_PORT
12+
Get the NodePort by running: kubectl get svc {{ include "deploystack.fullname" $ }}-{{ $key }}
13+
{{- else if contains "LoadBalancer" $service.service.type }}
14+
Access on: http://EXTERNAL_IP:PORT
15+
Get the LoadBalancer IP by running: kubectl get svc {{ include "deploystack.fullname" $ }}-{{ $key }}
16+
{{- else if contains "ClusterIP" $service.service.type }}
17+
Access within the cluster only
18+
Forward ports by running: kubectl port-forward svc/{{ include "deploystack.fullname" $ }}-{{ $key }} LOCAL_PORT:SERVICE_PORT
19+
{{- end }}
20+
{{- end }}
21+
{{- end }}
22+
23+
For more information on managing your application, see the Helm documentation:
24+
https://helm.sh/docs/
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "deploystack.name" -}}
6+
{{- default .Chart.Name .Values.global.nameOverride | trunc 63 | trimSuffix "-" }}
7+
{{- end }}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
*/}}
12+
{{- define "deploystack.fullname" -}}
13+
{{- if .Values.global.fullnameOverride }}
14+
{{- .Values.global.fullnameOverride | trunc 63 | trimSuffix "-" }}
15+
{{- else }}
16+
{{- $name := default .Chart.Name .Values.global.nameOverride }}
17+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
18+
{{- end }}
19+
{{- end }}
20+
21+
{{/*
22+
Create chart name and version as used by the chart label.
23+
*/}}
24+
{{- define "deploystack.chart" -}}
25+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
26+
{{- end }}
27+
28+
{{/*
29+
Common labels
30+
*/}}
31+
{{- define "deploystack.labels" -}}
32+
helm.sh/chart: {{ include "deploystack.chart" . }}
33+
{{ include "deploystack.selectorLabels" . }}
34+
{{- if .Chart.AppVersion }}
35+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
36+
{{- end }}
37+
app.kubernetes.io/managed-by: {{ .Release.Service }}
38+
{{- end }}
39+
40+
{{/*
41+
Selector labels
42+
*/}}
43+
{{- define "deploystack.selectorLabels" -}}
44+
app.kubernetes.io/name: {{ include "deploystack.name" . }}
45+
app.kubernetes.io/instance: {{ .Release.Name }}
46+
{{- end }}
47+
48+
{{/*
49+
Service reference helper
50+
*/}}
51+
{{- define "deploystack.serviceReference" -}}
52+
{{- if .service }}
53+
{{- if .service.service.ports }}
54+
{{- with index .service.service.ports 0 }}
55+
{{ $.serviceKey }}.{{ $.serviceName }}.svc.cluster.local:{{ .port }}
56+
{{- end }}
57+
{{- else }}
58+
{{ $.serviceKey }}.{{ $.serviceName }}.svc.cluster.local
59+
{{- end }}
60+
{{- else }}
61+
unknown-service-reference
62+
{{- end }}
63+
{{- end }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
{{- range $key, $service := .Values.services }}
3+
{{- if $service.enabled }}
4+
{{- if $service.environment.regular }}
5+
apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: {{ include "deploystack.fullname" $ }}-{{ $key }}-config
9+
labels:
10+
{{- include "deploystack.labels" $ | nindent 4 }}
11+
app.kubernetes.io/component: {{ $key }}
12+
data:
13+
{{- toYaml $service.environment.regular | nindent 2 }}
14+
{{- end }}
15+
16+
{{- if $service.dependencies }}
17+
---
18+
apiVersion: v1
19+
kind: ConfigMap
20+
metadata:
21+
name: {{ include "deploystack.fullname" $ }}-{{ $key }}-dependencies
22+
labels:
23+
{{- include "deploystack.labels" $ | nindent 4 }}
24+
app.kubernetes.io/component: {{ $key }}
25+
data:
26+
{{- range $service.dependencies }}
27+
{{- $serviceName := .service }}
28+
{{- range $envKey, $envValue := .variables }}
29+
{{ $envKey }}: {{ include "deploystack.serviceReference" (dict "service" (index $.Values.services $serviceName) "serviceKey" $serviceName) }}
30+
{{- end }}
31+
{{- end }}
32+
{{- end }}
33+
{{- end }}
34+
{{- end }}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
{{- range $key, $service := .Values.services }}
3+
{{- if $service.enabled }}
4+
apiVersion: apps/v1
5+
kind: Deployment
6+
metadata:
7+
name: {{ include "deploystack.fullname" $ }}-{{ $key }}
8+
labels:
9+
{{- include "deploystack.labels" $ | nindent 4 }}
10+
app.kubernetes.io/component: {{ $key }}
11+
spec:
12+
{{- if not $service.autoscaling.enabled }}
13+
replicas: {{ $service.replicaCount }}
14+
{{- end }}
15+
selector:
16+
matchLabels:
17+
{{- include "deploystack.selectorLabels" $ | nindent 6 }}
18+
app.kubernetes.io/component: {{ $key }}
19+
template:
20+
metadata:
21+
{{- with $.Values.global.podAnnotations }}
22+
annotations:
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
labels:
26+
{{- include "deploystack.selectorLabels" $ | nindent 8 }}
27+
app.kubernetes.io/component: {{ $key }}
28+
spec:
29+
{{- with $.Values.global.imagePullSecrets }}
30+
imagePullSecrets:
31+
{{- toYaml . | nindent 8 }}
32+
{{- end }}
33+
securityContext:
34+
{{- toYaml $.Values.global.podSecurityContext | nindent 8 }}
35+
containers:
36+
- name: {{ $key }}
37+
securityContext:
38+
{{- toYaml $.Values.global.securityContext | nindent 12 }}
39+
image: "{{ $service.image.repository }}:{{ $service.image.tag | default "latest" }}"
40+
imagePullPolicy: {{ $service.image.pullPolicy }}
41+
{{- if $service.command }}
42+
command:
43+
{{- toYaml $service.command | nindent 12 }}
44+
{{- end }}
45+
ports:
46+
{{- range $service.service.ports }}
47+
- name: http-{{ .port }}
48+
containerPort: {{ .targetPort }}
49+
protocol: {{ .protocol }}
50+
{{- end }}
51+
{{- if or $service.environment.regular $service.environment.sensitive }}
52+
env:
53+
{{- range $envKey, $envValue := $service.environment.regular }}
54+
- name: {{ $envKey }}
55+
valueFrom:
56+
configMapKeyRef:
57+
name: {{ include "deploystack.fullname" $ }}-{{ $key }}-config
58+
key: {{ $envKey }}
59+
{{- end }}
60+
{{- range $envKey, $envValue := $service.environment.sensitive }}
61+
- name: {{ $envKey }}
62+
valueFrom:
63+
secretKeyRef:
64+
name: {{ include "deploystack.fullname" $ }}-{{ $key }}-secret
65+
key: {{ $envKey }}
66+
{{- end }}
67+
{{- if $service.dependencies }}
68+
{{- range $service.dependencies }}
69+
{{- range $envKey, $envValue := .variables }}
70+
- name: {{ $envKey }}
71+
valueFrom:
72+
configMapKeyRef:
73+
name: {{ include "deploystack.fullname" $ }}-{{ $key }}-dependencies
74+
key: {{ $envKey }}
75+
{{- end }}
76+
{{- end }}
77+
{{- end }}
78+
{{- end }}
79+
{{- with $service.volumes }}
80+
volumeMounts:
81+
{{- toYaml . | nindent 12 }}
82+
{{- end }}
83+
resources:
84+
{{- toYaml $service.resources | nindent 12 }}
85+
{{- with $service.volumes }}
86+
volumes:
87+
{{- range . }}
88+
- name: {{ .name }}
89+
hostPath:
90+
path: {{ .hostPath }}
91+
{{- end }}
92+
{{- end }}
93+
{{- end }}
94+
{{- end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
{{- range $key, $service := .Values.services }}
3+
{{- if $service.enabled }}
4+
{{- if $service.environment.sensitive }}
5+
apiVersion: v1
6+
kind: Secret
7+
metadata:
8+
name: {{ include "deploystack.fullname" $ }}-{{ $key }}-secret
9+
labels:
10+
{{- include "deploystack.labels" $ | nindent 4 }}
11+
app.kubernetes.io/component: {{ $key }}
12+
type: Opaque
13+
data:
14+
{{- range $envKey, $envValue := $service.environment.sensitive }}
15+
{{ $envKey }}: {{ $envValue | b64enc | quote }}
16+
{{- end }}
17+
{{- end }}
18+
{{- end }}
19+
{{- end }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
{{- range $key, $service := .Values.services }}
3+
{{- if $service.enabled }}
4+
apiVersion: v1
5+
kind: Service
6+
metadata:
7+
name: {{ include "deploystack.fullname" $ }}-{{ $key }}
8+
labels:
9+
{{- include "deploystack.labels" $ | nindent 4 }}
10+
app.kubernetes.io/component: {{ $key }}
11+
spec:
12+
type: {{ $service.service.type }}
13+
ports:
14+
{{- range $service.service.ports }}
15+
- port: {{ .port }}
16+
targetPort: {{ .targetPort }}
17+
protocol: {{ .protocol }}
18+
name: http-{{ .port }}
19+
{{- end }}
20+
selector:
21+
{{- include "deploystack.selectorLabels" $ | nindent 4 }}
22+
app.kubernetes.io/component: {{ $key }}
23+
{{- end }}
24+
{{- end }}

0 commit comments

Comments
 (0)