Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Adds support for enableTLSAcme #127

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deploy/kubelessDeploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class KubelessDeploy {
{
namespace: this.serverless.service.provider.namespace,
hostname: this.serverless.service.provider.hostname,
enableTLSAcme: this.serverless.service.provider.enableTLSAcme || false,
defaultDNSResolution: this.serverless.service.provider.defaultDNSResolution,
memorySize: this.serverless.service.provider.memorySize,
force: this.options.force,
Expand Down
3 changes: 3 additions & 0 deletions lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ function deploy(functions, runtime, service, options) {
verbose: false,
log: console.log,
contentType: 'text',
enableTLSAcme: false,
});
const errors = [];
let counter = 0;
Expand All @@ -483,6 +484,7 @@ function deploy(functions, runtime, service, options) {
hostname: options.hostname,
defaultDNSResolution: options.defaultDNSResolution,
namespace: ns,
enableTLSAcme: options.enableTLSAcme,
}),
});
});
Expand All @@ -501,6 +503,7 @@ function deploy(functions, runtime, service, options) {
hostname: options.hostname,
defaultDNSResolution: options.defaultDNSResolution,
namespace: ns,
enableTLSAcme: options.enableTLSAcme,
}),
});
});
Expand Down
14 changes: 10 additions & 4 deletions lib/ingress.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function addIngressRuleIfNecessary(ruleName, functions, options) {
namespace: 'default',
hostname: null,
defaultDNSResolution: 'nip.io',
enableTLSAcme: false,
});
const config = helpers.loadKubeConfig();
const extensions = new Api.Extensions(helpers.getConnectionOptions(
Expand Down Expand Up @@ -70,14 +71,19 @@ function addIngressRuleIfNecessary(ruleName, functions, options) {
return new BbPromise((resolve, reject) => {
if (!_.isEmpty(rules)) {
// Found a path to deploy the function
const annotations = {
'kubernetes.io/ingress.class': 'nginx',
'nginx.ingress.kubernetes.io/rewrite-target': '/',
};
if (opts.enableTLSAcme) {
annotations['kubernetes.io/tls-acme'] = "true";
annotations['nginx.ingress.kubernetes.io/ssl-redirect'] = "true";
}
const ingressDef = {
kind: 'Ingress',
metadata: {
name: ruleName,
annotations: {
'kubernetes.io/ingress.class': 'nginx',
'nginx.ingress.kubernetes.io/rewrite-target': '/',
},
annotations,
},
spec: { rules },
};
Expand Down