Skip to content

Commit

Permalink
feat: support more flexible container parameterization (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii-Klimov authored Jan 9, 2025
1 parent 9eaedec commit e358549
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 61 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/epam/aidial/service/ConfigService.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public class ConfigService {
private final RegistryService registryService;
private final AppConfiguration appconfig;

@Value("${app.template-container}")
@Value("${app.template-container.name}")
private final String pullerContainer;

@Value("${app.builder-container}")
@Value("${app.builder-container.name}")
private final String builderContainer;

@Value("${app.service-container}")
@Value("${app.service-container.name}")
private final String serviceContainer;

@Value("${app.docker-config-path}")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/epam/aidial/service/DeployService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class DeployService {
@Value("${app.deploy-namespace}")
private final String namespace;

@Value("${app.service-container}")
@Value("${app.service-container.name}")
private final String serviceContainer;

@Value("${app.service-setup-timeout-sec}")
Expand Down
97 changes: 50 additions & 47 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,53 @@ app:
heartbeat-period-sec: 30
max-error-log-lines: 20
max-error-log-chars: 1000
template-container: template
builder-container: builder
service-container: app-container
template-container: &template-container
name: template-container
image: ${app.template-image}
imagePullPolicy: Always
env:
- name: DIAL_BASE_URL
value: ${app.dial-base-url}
- name: ALLOWED_PACKAGES
value: "${app.allowed-python-packages} ${app.additional-allowed-python-packages}"
volumeMounts:
- name: volume
subPath: sources
mountPath: /sources
- name: volume
subPath: templates
mountPath: /templates
securityContext:
runAsUser: 1001
runAsNonRoot: true
allowPrivilegeEscalation: false
builder-container: &builder-container
name: builder-container
image: ${app.builder-image}
args:
- "--context=/sources"
- "--dockerfile=/templates/Dockerfile"
volumeMounts:
- name: volume
subPath: sources
mountPath: /sources
readOnly: true
- name: volume
subPath: templates
mountPath: /templates
readOnly: true
service-container: &service-container
name: app-container
imagePullPolicy: Always
resources:
requests:
cpu: "500m"
memory: "1G"
ephemeral-storage: "500M"
limits:
cpu: "1000m"
memory: "4G"
ephemeral-storage: "1G"
allowed-python-packages: |
aidial-sdk
anthropic
Expand Down Expand Up @@ -83,17 +127,7 @@ app:
containerConcurrency: 50
automountServiceAccountToken: false
containers:
- name: ${app.service-container}
imagePullPolicy: Always
resources:
requests:
cpu: "500m"
memory: "1G"
ephemeral-storage: "500M"
limits:
cpu: "1000m"
memory: "4G"
ephemeral-storage: "1G"
- <<: *service-container
job-config:
apiVersion: batch/v1
kind: Job
Expand All @@ -103,40 +137,9 @@ app:
spec:
automountServiceAccountToken: false
initContainers:
- name: ${app.template-container}
image: ${app.template-image}
imagePullPolicy: Always
env:
- name: DIAL_BASE_URL
value: ${app.dial-base-url}
- name: ALLOWED_PACKAGES
value: "${app.allowed-python-packages} ${app.additional-allowed-python-packages}"
volumeMounts:
- name: volume
subPath: sources
mountPath: /sources
- name: volume
subPath: templates
mountPath: /templates
securityContext:
runAsUser: 1001
runAsNonRoot: true
allowPrivilegeEscalation: false
- <<: *template-container
containers:
- name: ${app.builder-container}
image: ${app.builder-image}
args:
- "--context=/sources"
- "--dockerfile=/templates/Dockerfile"
volumeMounts:
- name: volume
subPath: sources
mountPath: /sources
readOnly: true
- name: volume
subPath: templates
mountPath: /templates
readOnly: true
- <<: *builder-container
restartPolicy: Never
volumes:
- name: volume
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void testAppServiceConfig() throws IOException {
// Act
V1Service actual = configService.appServiceConfig(
TEST_NAME,
Map.of("test-env-name", "test-env-value"),
Map.of(),
null,
null,
null,
Expand Down
1 change: 0 additions & 1 deletion src/test/resources/application-configtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ app:
template-image: test-template-image
builder-image: test-builder-image
dial-base-url: test-dial-base-url
service-container: test-container
docker-registry-auth: BASIC
docker-registry-user: test
docker-registry-pass: password
2 changes: 1 addition & 1 deletion src/test/resources/expected-configs/app-service-extra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
value: test-env-value
image: image-name
imagePullPolicy: Always
name: test-container
name: app-container
resources:
requests:
cpu: 500m
Expand Down
7 changes: 2 additions & 5 deletions src/test/resources/expected-configs/app-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ spec:
containerConcurrency: 50
automountServiceAccountToken: false
containers:
- env:
- name: test-env-name
value: test-env-value
image: test-docker-registry/app-test-name:latest
- image: test-docker-registry/app-test-name:latest
imagePullPolicy: Always
name: test-container
name: app-container
resources:
requests:
cpu: 500m
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/expected-configs/build-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
- --destination=test-docker-registry/app-test-name:latest
- --build-arg=BASE_IMAGE=python:3.11-slim
image: test-builder-image
name: builder
name: builder-container
volumeMounts:
- mountPath: /sources
name: volume
Expand Down Expand Up @@ -46,7 +46,7 @@ spec:
name: app-ctrl-dial-auth-test-name
image: test-template-image
imagePullPolicy: Always
name: template
name: template-container
securityContext:
allowPrivilegeEscalation: false
runAsUser: 1001
Expand Down

0 comments on commit e358549

Please sign in to comment.