Skip to content

Commit 6a87dd4

Browse files
authored
Merge pull request #238 from kubero-dev/feature/make-letsecrypt-issuer-configurable
Feature / Make letsencrypt issuer configurable
2 parents bf79f87 + 7169aa8 commit 6a87dd4

File tree

6 files changed

+41
-10
lines changed

6 files changed

+41
-10
lines changed

.env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ KUBERO_CONTEXT=kind-kubero-001
1313
KUBERO_NAMESPACE=kubero-dev # needs to be created manually in the cluster, since the in cluster default is "kubero"
1414
KUBERO_SESSION_KEY=randomString
1515
DEBUG=*.*
16+
KUBERO_CLUSTERISSUER=letsencrypt-prod
1617

1718
##########################################
1819
# git repository configuration

client/src/components/apps/new.vue

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,8 @@ export default {
11661166
*/
11671167
11681168
],
1169+
letsecryptClusterIssuer: 'letsencrypt-prod',
1170+
// deprecated in version 1.11.0
11691171
security: {
11701172
vulnerabilityScans: false,
11711173
allowPrivilegeEscalation: false,
@@ -1176,12 +1178,7 @@ export default {
11761178
capabilities: {
11771179
add: [],
11781180
drop: [],
1179-
},
1180-
/*
1181-
seLinuxOptions: {
1182-
level: 's0:c0,c1',
1183-
},
1184-
*/
1181+
}
11851182
},
11861183
ingress: {
11871184
annotations: {
@@ -1274,6 +1271,7 @@ export default {
12741271
this.loadStorageClasses();
12751272
this.loadPodsizeList();
12761273
this.loadBuildpacks();
1274+
this.loadClusterIssuers();
12771275
if (this.app != 'new') {
12781276
this.loadApp(); // this may lead into a race condition with the buildpacks loaded in loadPipeline
12791277
}
@@ -1290,6 +1288,13 @@ export default {
12901288
breadcrumbs: () => import('../breadcrumbs.vue'),
12911289
},
12921290
methods: {
1291+
loadClusterIssuers(){
1292+
axios.get('/api/config/clusterissuers').then(response => {
1293+
for (let i = 0; i < response.data.length; i++) {
1294+
this.letsecryptClusterIssuer = response.data[i].id;
1295+
}
1296+
});
1297+
},
12931298
loadTemplate(catalogId, template) {
12941299
axios.get('/api/templates/'+catalogId+'/'+template).then(response => {
12951300
@@ -1325,7 +1330,7 @@ export default {
13251330
this.panel.push(4)
13261331
}
13271332
1328-
// Backward compability older v1.11.1
1333+
// Backward compatibility older v1.11.1
13291334
if (this.buildpack.run && this.buildpack.run.readOnlyAppStorage === undefined) {
13301335
this.buildpack.run.readOnlyAppStorage = true;
13311336
}
@@ -1368,7 +1373,7 @@ export default {
13681373
*/
13691374
}
13701375
1371-
// Backward compability older v1.11.1
1376+
// Backward compatibility older v1.11.1
13721377
if (this.buildpack.run && this.buildpack.run.readOnlyAppStorage === undefined) {
13731378
this.buildpack.run.readOnlyAppStorage = true;
13741379
}
@@ -1502,7 +1507,7 @@ export default {
15021507
this.security.vulnerabilityScans = response.data.spec.vulnerabilityscan.enabled;
15031508
this.ingress = response.data.spec.ingress || {};
15041509
1505-
// Backward compability older v1.11.1
1510+
// Backward compatibility older v1.11.1
15061511
if (this.buildpack.run && this.buildpack.run.readOnlyAppStorage === undefined) {
15071512
this.buildpack.run.readOnlyAppStorage = true;
15081513
}
@@ -1516,7 +1521,7 @@ export default {
15161521
delete this.ingress.annotations['kubernetes.io/tls-acme'];
15171522
this.ingress.tls = [];
15181523
} else {
1519-
this.ingress.annotations['cert-manager.io/cluster-issuer'] = 'letsencrypt-prod';
1524+
this.ingress.annotations['cert-manager.io/cluster-issuer'] = this.letsecryptClusterIssuer;
15201525
this.ingress.annotations['kubernetes.io/tls-acme'] = 'true';
15211526
this.ingress.tls = [
15221527
{
@@ -1615,6 +1620,9 @@ export default {
16151620
ingress: this.ingress,
16161621
}
16171622
1623+
postdata.image.run.securityContext.runAsUser = parseInt(postdata.image.run.securityContext.runAsUser);
1624+
postdata.image.run.securityContext.runAsGroup = parseInt(postdata.image.run.securityContext.runAsGroup);
1625+
16181626
axios.put(`/api/pipelines/${this.pipeline}/${this.phase}/${this.app}`, postdata
16191627
// eslint-disable-next-line no-unused-vars
16201628
).then(response => {
@@ -1702,6 +1710,10 @@ export default {
17021710
if (postdata.image.run == undefined) {
17031711
postdata.image.run = {};
17041712
}
1713+
1714+
postdata.image.run.securityContext.runAsUser = parseInt(postdata.image.run.securityContext.runAsUser);
1715+
postdata.image.run.securityContext.runAsGroup = parseInt(postdata.image.run.securityContext.runAsGroup);
1716+
17051717
/*
17061718
postdata.image.run.securityContext = {
17071719
readOnlyRootFilesystem: this.security.readOnlyRootFilesystem,

config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ kubero:
99
apps:
1010
pipelines:
1111
- janitor/ttl=5m
12+
clusterissuer: letsencrypt-prod
1213
templates:
1314
enabled: true
1415
catalogs:

src/kubero.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,9 @@ export class Kubero {
714714
try {
715715
let config = YAML.parse(fs.readFileSync(path, 'utf8')) as IKuberoConfig;
716716

717+
if (!config.clusterissuer) {
718+
config.clusterissuer = 'letsencrypt-prod';
719+
}
717720

718721
// backward compatibility. Add default if template does not exist
719722
if (!config.templates) {
@@ -1170,4 +1173,8 @@ export class Kubero {
11701173
public getTemplateEnabled() {
11711174
return this.config.templates.enabled;
11721175
}
1176+
1177+
public getClusterIssuer() {
1178+
return this.config.clusterissuer;
1179+
}
11731180
}

src/routes/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,13 @@ Router.get('/config/catalogs', authMiddleware, async function (req: Request, res
111111
// #swagger.tags = ['UI']
112112
// #swagger.summary = 'Get a list of available catalogs'
113113
res.send(await req.app.locals.kubero.getTemplateConfig());
114+
});
115+
116+
Router.get('/config/clusterissuers', authMiddleware, async function (req: Request, res: Response) {
117+
// #swagger.tags = ['UI']
118+
// #swagger.summary = 'Get a list of available clusterissuers'
119+
const ret = {
120+
id: await req.app.locals.kubero.getClusterIssuer() || 'letsencrypt-prod',
121+
}
122+
res.send(ret);
114123
});

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ export interface IBuildpack {
284284
export interface IKuberoConfig {
285285
podSizeList: IPodSize[];
286286
buildpacks: IBuildpack[];
287+
clusterissuer: string;
287288
templates: { // introduced v1.11.0
288289
enabled: boolean;
289290
catalogs: [

0 commit comments

Comments
 (0)