Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit a43fe19

Browse files
committed
Fixes for secrets and mounts
- Add new mount for `scdfmetadata` which gets creds for docker metadata fetching. - Move all mounts under /workspace as this helps avoid issues mounting under /etc if no root is available. - Also remove maven settings. - Fixes #4776 - Fixes #4775 - Fixes #4774
1 parent 5e27c6a commit a43fe19

File tree

7 files changed

+56
-11
lines changed

7 files changed

+56
-11
lines changed

src/carvel/config/dataflow-deployment.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#@ load("dataflow.star", "ctr_image")
44
#@ load("dataflow.star", "dataflow_container_env")
55
#@ load("dataflow.star", "has_image_pull_secrets")
6+
#@ load("dataflow.star", "registry_secret_ref")
67
#@ load("dataflow.star", "image_pull_secrets")
78
#@ load("dataflow.star", "dataflow_liveness_path")
89
#@ load("dataflow.star", "dataflow_readiness_path")
@@ -35,7 +36,10 @@ spec:
3536
mountPath: /workspace/config
3637
readOnly: true
3738
- name: database
38-
mountPath: /etc/secrets/database
39+
mountPath: /workspace/runtime/secrets/database
40+
readOnly: true
41+
- name: scdfmetadata
42+
mountPath: /workspace/runtime/secrets
3943
readOnly: true
4044
ports:
4145
- containerPort: 80
@@ -73,3 +77,12 @@ spec:
7377
- name: database
7478
secret:
7579
secretName: db-dataflow
80+
#@ if has_image_pull_secrets():
81+
- name: scdfmetadata
82+
secret:
83+
secretName: #@ registry_secret_ref()
84+
#@ else:
85+
- name: scdfmetadata
86+
secret:
87+
secretName: reg-creds
88+
#@ end

src/carvel/config/dataflow.star

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ def dataflow_container_env():
3232
envs.extend([{"name": "SPRING_CLOUD_DATAFLOW_TASK_COMPOSEDTASKRUNNER_URI", "value": "docker://" + ctr_image()}])
3333
envs.extend([{"name": "SPRING_CLOUD_KUBERNETES_CONFIG_ENABLE_API", "value": "false"}])
3434
envs.extend([{"name": "SPRING_CLOUD_KUBERNETES_SECRETS_ENABLE_API", "value": "false"}])
35-
envs.extend([{"name": "SPRING_CLOUD_KUBERNETES_SECRETS_PATHS", "value": "/etc/secrets"}])
35+
envs.extend([{"name": "SPRING_CLOUD_KUBERNETES_SECRETS_PATHS", "value": "/workspace/runtime/secrets"}])
3636
envs.extend([{"name": "SPRING_CLOUD_DATAFLOW_SERVER_URI", "value": "http://${SCDF_SERVER_SERVICE_HOST}:${SCDF_SERVER_SERVICE_PORT}"}])
3737
envs.extend([{"name": "SPRING_CLOUD_SKIPPER_CLIENT_SERVER_URI", "value": "http://${SKIPPER_SERVICE_HOST}:${SKIPPER_SERVICE_PORT}/api"}])
38-
envs.extend([{"name": "SPRING_APPLICATION_JSON", "value": "{ \"maven\": { \"local-repository\": null, \"remote-repositories\": { \"repo1\": { \"url\": \"https://repo.spring.io/libs-snapshot\"} } } }"}])
3938
if grafana_enabled():
4039
envs.extend([{"name": "MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED", "value": "true"}])
4140
envs.extend([{"name": "MANAGEMENT_METRICS_EXPORT_PROMETHEUS_RSOCKET_ENABLED", "value": "true"}])

src/carvel/config/skipper-deployment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ spec:
3333
mountPath: /workspace/config
3434
readOnly: true
3535
- name: database
36-
mountPath: /etc/secrets/database
36+
mountPath: /workspace/runtime/secrets/database
3737
readOnly: true
3838
#@ if rabbitmq_enabled():
3939
- name: rabbitmq
40-
mountPath: /etc/secrets/rabbitmq
40+
mountPath: /workspace/runtime/secrets/rabbitmq
4141
readOnly: true
4242
#@ end
4343
ports:

src/carvel/config/skipper.star

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def skipper_container_env():
4141
envs.extend([{"name": "SPRING_CLOUD_CONFIG_ENABLED", "value": "false"}])
4242
envs.extend([{"name": "SPRING_CLOUD_KUBERNETES_CONFIG_ENABLE_API", "value": "false"}])
4343
envs.extend([{"name": "SPRING_CLOUD_KUBERNETES_SECRETS_ENABLE_API", "value": "false"}])
44-
envs.extend([{"name": "SPRING_CLOUD_KUBERNETES_SECRETS_PATHS", "value": "/etc/secrets"}])
44+
envs.extend([{"name": "SPRING_CLOUD_KUBERNETES_SECRETS_PATHS", "value": "/workspace/runtime/secrets"}])
4545
if grafana_enabled():
4646
envs.extend([{"name": "MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED", "value": "true"}])
4747
envs.extend([{"name": "MANAGEMENT_METRICS_EXPORT_PROMETHEUS_RSOCKET_ENABLED", "value": "true"}])

src/carvel/test/binders.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('binders rabbit', () => {
5353
expect(rabbitVolume?.secret?.secretName).toBe('rabbitmq');
5454

5555
const rabbitVolumeMount = containerVolumeMount(skipperContainer, 'rabbitmq');
56-
expect(rabbitVolumeMount?.mountPath).toBe('/etc/secrets/rabbitmq');
56+
expect(rabbitVolumeMount?.mountPath).toBe('/workspace/runtime/secrets/rabbitmq');
5757
});
5858

5959
it('should skip deploy if external settings', async () => {

src/carvel/test/secrets.test.ts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'jest-extended';
2-
import { DEFAULT_REQUIRED_DATA_VALUES } from '../src/constants';
3-
import { findPodSpecsWithImagePullSecrets, findSecret } from '../src/k8s-helper';
2+
import { SCDF_SERVER_NAME, DEFAULT_REQUIRED_DATA_VALUES } from '../src/constants';
3+
import { findDeployment, deploymentContainer, findPodSpecsWithImagePullSecrets, findSecret } from '../src/k8s-helper';
4+
45
import { execYtt } from '../src/ytt';
56

67
describe('secrets', () => {
@@ -84,6 +85,22 @@ describe('secrets', () => {
8485
expect(secret).toBeTruthy();
8586
});
8687

88+
it('should add carvel secretgen on default 4', async () => {
89+
const result = await execYtt({
90+
files: ['config'],
91+
dataValueYamls: [...DEFAULT_REQUIRED_DATA_VALUES]
92+
});
93+
expect(result.success, result.stderr).toBeTruthy();
94+
const yaml = result.stdout;
95+
96+
const dataflowDeployment = findDeployment(yaml, SCDF_SERVER_NAME);
97+
const dataflowContainer = deploymentContainer(dataflowDeployment, SCDF_SERVER_NAME);
98+
const volumeMount = dataflowContainer?.volumeMounts?.find(x => x.name === 'scdfmetadata');
99+
expect(volumeMount?.mountPath).toBe('/workspace/runtime/secrets');
100+
const volume = dataflowDeployment?.spec?.template.spec?.volumes?.find(x => x.name === 'scdfmetadata');
101+
expect(volume?.secret?.secretName).toBe('reg-creds');
102+
});
103+
87104
it('should add manual image pull secret if defined 1', async () => {
88105
const result = await execYtt({
89106
files: ['config'],
@@ -155,4 +172,20 @@ describe('secrets', () => {
155172
const secret = findSecret(yaml, 'reg-creds');
156173
expect(secret).toBeFalsy();
157174
});
175+
176+
it('should add manual image pull secret if defined 4', async () => {
177+
const result = await execYtt({
178+
files: ['config'],
179+
dataValueYamls: [...DEFAULT_REQUIRED_DATA_VALUES, 'scdf.registry.secret.ref=fakeref']
180+
});
181+
expect(result.success, result.stderr).toBeTruthy();
182+
const yaml = result.stdout;
183+
184+
const dataflowDeployment = findDeployment(yaml, SCDF_SERVER_NAME);
185+
const dataflowContainer = deploymentContainer(dataflowDeployment, SCDF_SERVER_NAME);
186+
const volumeMount = dataflowContainer?.volumeMounts?.find(x => x.name === 'scdfmetadata');
187+
expect(volumeMount?.mountPath).toBe('/workspace/runtime/secrets');
188+
const volume = dataflowDeployment?.spec?.template.spec?.volumes?.find(x => x.name === 'scdfmetadata');
189+
expect(volume?.secret?.secretName).toBe('fakeref');
190+
});
158191
});

src/carvel/test/servers.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ describe('servers', () => {
268268
}),
269269
expect.objectContaining({
270270
name: 'SPRING_CLOUD_KUBERNETES_SECRETS_PATHS',
271-
value: '/etc/secrets'
271+
value: '/workspace/runtime/secrets'
272272
})
273273
])
274274
);
@@ -374,7 +374,7 @@ describe('servers', () => {
374374
}),
375375
expect.objectContaining({
376376
name: 'SPRING_CLOUD_KUBERNETES_SECRETS_PATHS',
377-
value: '/etc/secrets'
377+
value: '/workspace/runtime/secrets'
378378
}),
379379
expect.objectContaining({
380380
name: 'SPRING_CLOUD_DATAFLOW_SERVER_URI'

0 commit comments

Comments
 (0)