Skip to content

Commit 0c18c1f

Browse files
committed
nginx milestone
1 parent cf89d8d commit 0c18c1f

File tree

9 files changed

+101
-70
lines changed

9 files changed

+101
-70
lines changed

electron/app/locales/en/webui.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,8 @@
608608
"ingress-design-ingress-namespace-help": "The Kubernetes namespace to use for the ingress controller.",
609609
"ingress-design-voyager-provider-label": "Kubernetes Cluster Provider for Voyager",
610610
"ingress-design-voyager-provider-help": "The Kubernetes cluster provider type to use for Voyager.",
611+
"ingress-design-nginx-allow-passthrough-label": "Allow SSL pass through to backend service",
612+
"ingress-design-nginx-allow-passthrough-help": "Enable this allows creating ssl ingress pass through to the backend service.",
611613
"ingress-design-specify-docker-registry-secret-label": "Use Docker Hub Secret",
612614
"ingress-design-specify-docker-registry-secret-help": "Whether to use a Docker Hub credential secret to pull the ingress controller image. This is helpful if you encounter a Docker Hub pull limit exceeded error.",
613615
"ingress-design-ingress-docker-reg-secret-name": "Docker Registry Secret Name",
@@ -633,8 +635,8 @@
633635
"ingress-design-ingress-route-tlsoption-plain": "Plain HTTP",
634636
"ingress-design-ingress-route-tlsoption-ssl-passthrough": "HTTPS pass through to the target service",
635637
"ingress-design-ingress-route-tlsoption-ssl-terminate-ingress": "HTTPS terminate at ingress and plain HTTP traffic from ingress to target service",
636-
"ingress-design-ingress-route-is-console-svc-label": "Check if target service is WebLogic Console Service",
637-
"ingress-design-ingress-route-yes-console-svc": "WebLogic Console Service",
638+
"ingress-design-ingress-route-is-console-svc-label": "Is target service WebLogic Console?",
639+
"ingress-design-ingress-route-is-console-svc-help": "For SSL terminating at ingress and accessing WebLogic Console, turn on this option",
638640
"ingress-design-ingress-route-name-label": "Name",
639641
"ingress-design-ingress-route-dialog-title": "Edit Ingress Route",
640642
"ingress-design-ingress-route-annotation-label": "Annotation",

webui/src/js/models/ingress-definition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ define(['knockout', 'utils/observable-properties', 'utils/validation-helper'],
5959
this.createTLSSecret = props.createProperty(false);
6060
this.ingressTLSSecretName = props.createProperty('');
6161
this.ingressTLSSecretName.addValidator(...validationHelper.getK8sNameValidators());
62-
62+
this.allowNginxSSLPassThrough = props.createProperty(false);
6363
this.generateTLSFiles = props.createProperty(false);
6464
this.ingressTLSSubject = props.createProperty('');
6565

webui/src/js/utils/ingress-controller-installer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ function(IngressActionsBase, project, wktConsole, k8sHelper, i18n, dialogHelper,
246246
helmChartData['kubernetes.namespaces'] =
247247
`{${ingressControllerNamespace},${this.project.k8sDomain.kubernetesNamespace.value}}`;
248248
}
249+
if (ingressControllerProvider === 'nginx' && this.project.ingress.allowNginxSSLPassThrough) {
250+
helmChartData['controller.extraArgs.enable-ssl-passthrough'] = true;
251+
}
249252
return helmChartData;
250253
}
251254
}

webui/src/js/utils/ingress-resource-generator.js

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,55 @@ define(['models/wkt-project', 'js-yaml'],
7575
}
7676

7777
createNginxRoutesAsYaml(item) {
78-
return this._createStandardRoutesAsYaml(item);
78+
const namespace = item['targetServiceNameSpace'] || 'default';
79+
80+
const result = {
81+
apiVersion: 'networking.k8s.io/v1',
82+
kind: 'Ingress',
83+
metadata: {
84+
name: item['name'],
85+
namespace: namespace,
86+
},
87+
spec: {
88+
rules: [
89+
{
90+
http: {
91+
paths: [
92+
{
93+
backend: {
94+
service : {
95+
name: item['targetService'],
96+
port: {
97+
number: Number(item['targetPort'])
98+
}
99+
}
100+
},
101+
path: item['path'],
102+
pathType: 'Prefix'
103+
}
104+
]
105+
}
106+
}
107+
]
108+
}
109+
};
110+
this.addTlsSpec(result, item);
111+
this.addVirtualHost(result, item);
112+
this.addAnnotations(result, item);
113+
114+
if (this.isSSLTerminateAtIngress(item)) {
115+
if (item['isConsoleService']) {
116+
const snippet = 'more_clear_input_headers "WL-Proxy-Client-IP" "WL-Proxy-SSL";\n'
117+
+ 'more_set_input_headers "X-Forwarded-Proto: https";\n'
118+
+ 'more_set_input_headers "WL-Proxy-SSL: true";\n'; // must have nl at the end
119+
result.metadata.annotations['nginx.ingress.kubernetes.io/configuration-snippet'] = snippet;
120+
result.metadata.annotations['nginx.ingress.kubernetes.io/ingress.allow-http'] = 'false';
121+
}
122+
}
123+
return jsYaml.dump(result);
79124
}
80125

81-
isTraefikSSLTerminateAtIngress(item) {
126+
isSSLTerminateAtIngress(item) {
82127
if (item && item['tlsOption'] === 'ssl_terminate_ingress') {
83128
return true;
84129
} else {
@@ -115,8 +160,8 @@ define(['models/wkt-project', 'js-yaml'],
115160
}
116161
};
117162

118-
if (this.isTraefikSSLTerminateAtIngress(item)) {
119-
if (item['isConsoleService'].includes('yes')) {
163+
if (this.isSSLTerminateAtIngress(item)) {
164+
if (item['isConsoleService']) {
120165
result.spec = {
121166
headers: {
122167
sslRedirect: true,
@@ -133,7 +178,6 @@ define(['models/wkt-project', 'js-yaml'],
133178
}
134179

135180
if (item['path'].indexOf('.') < 0) {
136-
console.log('at here');
137181
result.spec = { replacePathRegex: { regex: '^' + item['path'] + '(.*)'}, replacement: item['path'] + '/$1'};
138182
return jsYaml.dump(result);
139183
}
@@ -190,7 +234,7 @@ define(['models/wkt-project', 'js-yaml'],
190234
result.spec.routes[0].match = matchExpression;
191235

192236
// if SSL terminate at ingress
193-
if (this.project.ingress.specifyIngressTLSSecret.value && this.isTraefikSSLTerminateAtIngress(item)) {
237+
if (this.project.ingress.specifyIngressTLSSecret.value && this.isSSLTerminateAtIngress(item)) {
194238
if (!item['tlsSecretName']) {
195239
item['tlsSecretName'] = this.project.ingress.ingressTLSSecretName.value;
196240
}
@@ -222,45 +266,6 @@ define(['models/wkt-project', 'js-yaml'],
222266
return yaml;
223267
}
224268

225-
_createStandardRoutesAsYaml(item) {
226-
const namespace = item['targetServiceNameSpace'] || 'default';
227-
228-
const result = {
229-
apiVersion: 'networking.k8s.io/v1',
230-
kind: 'Ingress',
231-
metadata: {
232-
name: item['name'],
233-
namespace: namespace,
234-
},
235-
spec: {
236-
rules: [
237-
{
238-
http: {
239-
paths: [
240-
{
241-
backend: {
242-
service : {
243-
name: item['targetService'],
244-
port: {
245-
number: Number(item['targetPort'])
246-
}
247-
}
248-
},
249-
path: item['path'],
250-
pathType: 'Prefix'
251-
}
252-
]
253-
}
254-
}
255-
]
256-
}
257-
};
258-
this.addTlsSpec(result, item);
259-
this.addVirtualHost(result, item);
260-
this.addAnnotations(result, item);
261-
return jsYaml.dump(result);
262-
}
263-
264269
addTlsSpec(result, item) {
265270
// If the Ingress TLS secret is not enabled, do not add the ingress TLS secret name even if it exists.
266271
if (this.project.ingress.specifyIngressTLSSecret.value && !this.isTraefikPlain(item)) {

webui/src/js/utils/ingress-routes-updater.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ function(IngressActionsBase, project, wktConsole, k8sHelper, i18n, projectIo, di
491491
});
492492
}
493493
}
494-
console.log(ingressDefinition);
495494
if (useNodePort) {
496495
if (ingressDefinition['tlsOption'] !== 'plain') {
497496
results['accessPoint'] = 'https:' + externalLoadBalancerHost + ':' + ingressSSLPort + ingressDefinition.path;

webui/src/js/viewModels/ingress-design-view-impl.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ function(i18n, accUtils, ko, ArrayDataProvider, BufferingDataProvider, project,
5252
return this.project.ingress.ingressControllerProvider.value === 'voyager';
5353
};
5454

55+
this.isNginx = () => {
56+
return this.project.ingress.ingressControllerProvider.value === 'nginx';
57+
};
58+
5559
this.imageOnDockerHub = () => {
5660
return (this.project.ingress.ingressControllerProvider.value === 'voyager') ||
5761
(this.project.ingress.ingressControllerProvider.value === 'traefik');
@@ -178,7 +182,7 @@ function(i18n, accUtils, ko, ArrayDataProvider, BufferingDataProvider, project,
178182
targetServiceNameSpace: this.project.k8sDomain.kubernetesNamespace.value,
179183
accessPoint: '',
180184
tlsOption: 'plain',
181-
isConsoleService: []
185+
isConsoleService: false
182186
};
183187

184188
// if controller is Voyager and provider is baremetal only nodeport is supported, set the default in the UI

webui/src/js/viewModels/route-edit-dialog.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function(accUtils, ko, i18n, project, viewHelper, ArrayDataProvider, BufferingDa
3838

3939
this.project = project;
4040
this.route = args.route;
41-
this.route.isConsoleService = [];
41+
this.askIfConsoleSvc = ko.observable(this.route.isConsoleService);
4242

4343
this.savedAnnotations = args.route.annotations || {};
4444

@@ -48,10 +48,6 @@ function(accUtils, ko, i18n, project, viewHelper, ArrayDataProvider, BufferingDa
4848
{ id: 'ssl_passthrough', value: 'ssl_passthrough', text: this.labelMapper('route-tlsoption-ssl-passthrough') },
4949
];
5050

51-
this.isConsoleOptions = [
52-
{ id: 'isConsole', value: 'yes', text: this.labelMapper('route-yes-console-svc') }
53-
];
54-
5551
// this is dynamic to allow i18n fields to load correctly
5652
this.annotationColumns = [
5753
{
@@ -148,6 +144,18 @@ function(accUtils, ko, i18n, project, viewHelper, ArrayDataProvider, BufferingDa
148144
}
149145
}
150146

147+
this.askIfConsoleService = () => {
148+
return this.askIfConsoleSvc();
149+
};
150+
151+
this.transportValueChanged = (event) => {
152+
if (event.detail.value === 'ssl_terminate_ingress') {
153+
this.askIfConsoleSvc(true);
154+
} else {
155+
this.askIfConsoleSvc(false);
156+
}
157+
};
158+
151159
this.okInput = () => {
152160
let tracker = document.getElementById('ingressTracker');
153161
if (tracker.valid !== 'valid') {
@@ -175,9 +183,16 @@ function(accUtils, ko, i18n, project, viewHelper, ArrayDataProvider, BufferingDa
175183
changedAnnotations[annotation.key] = annotation.value ? annotation.value : '';
176184
});
177185

186+
const ingressClassKey = 'kubernetes.io/ingress.class';
187+
let tlsOption = result['tlsOption'];
188+
189+
if (typeof tlsOption === 'undefined') {
190+
tlsOption = this.route.tlsOption;
191+
}
192+
178193
if (this.project.ingress.ingressControllerProvider.value === 'traefik') {
179194
const sslKey = 'traefik.ingress.kubernetes.io/router.tls';
180-
const tlsOption = result['tlsOption'];
195+
changedAnnotations[ingressClassKey] = 'traefik';
181196
addOrDeleteAnnotation(changedAnnotations, (tlsOption !== 'plain'),
182197
sslKey, 'true', '');
183198
// if user switched to plain
@@ -191,10 +206,12 @@ function(accUtils, ko, i18n, project, viewHelper, ArrayDataProvider, BufferingDa
191206
if (this.project.ingress.ingressControllerProvider.value === 'nginx') {
192207
const sslKey = 'nginx.ingress.kubernetes.io/backend-protocol';
193208
const sslPassThroughKey = 'nginx.ingress.kubernetes.io/ssl-passthrough';
194-
const tlsOption = result['tlsOption'];
209+
changedAnnotations[ingressClassKey] = 'nginx';
195210
addOrDeleteAnnotation(changedAnnotations, (tlsOption === 'ssl_terminate_ingress'),
196211
sslKey, 'HTTPS', sslPassThroughKey);
197-
addOrDeleteAnnotation(changedAnnotations, (tlsOption === 'ssl_passthrough'), 'true', sslKey);
212+
// passthrough require both
213+
addOrDeleteAnnotation(changedAnnotations, (tlsOption === 'ssl_passthrough'), sslPassThroughKey, 'true', '');
214+
addOrDeleteAnnotation(changedAnnotations, (tlsOption === 'ssl_passthrough'), sslKey, 'HTTPS', '');
198215
}
199216

200217
if(compareObjects(changedAnnotations, this.savedAnnotations)) {

webui/src/js/views/ingress-design-view.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ <h6 class="wkt-subheading">
3939
help.instruction="[[labelMapper('voyager-provider-help')]]">
4040
</oj-select-single>
4141
</oj-bind-if>
42+
<oj-bind-if test="[[isNginx() === true]]">
43+
<oj-switch label-hint="[[labelMapper('nginx-allow-passthrough-label')]]"
44+
value="{{project.ingress.allowNginxSSLPassThrough.observable}}"
45+
help.instruction="[[labelMapper('nginx-allow-passthrough-help')]]">
46+
</oj-switch>
47+
</oj-bind-if>
4248
</oj-form-layout>
4349

4450

webui/src/js/views/route-edit-dialog.html

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<oj-radioset id="tlsOptionId"
4949
label-hint="[[labelMapper('route-tls-label')]]"
5050
label-edge="inside"
51+
on-value-changed = "[[transportValueChanged]]"
5152
value="{{tlsOption.observable}}">
5253
<oj-bind-for-each data="[[tlsOptions]]">
5354
<template>
@@ -58,18 +59,12 @@
5859
</oj-bind-for-each>
5960
</oj-radioset>
6061

61-
<oj-checkboxset id="isConsoleSetId"
62-
label-hint="[[labelMapper('route-is-console-svc-label')]]"
63-
label-edge="inside"
64-
value="{{isConsoleService.observable}}">
65-
<oj-bind-for-each data="[[isConsoleOptions]]">
66-
<template>
67-
<oj-option value="[[$current.data.value]]">
68-
<oj-bind-text value="[[$current.data.text]]"></oj-bind-text>
69-
</oj-option>
70-
</template>
71-
</oj-bind-for-each>
72-
</oj-checkboxset>
62+
<oj-bind-if test="[[askIfConsoleService() === true]]">
63+
<oj-switch label-hint="[[labelMapper('route-is-console-svc-label')]]"
64+
value="{{isConsoleService.observable}}"
65+
help.instruction="[[labelMapper('route-is-console-svc-help')]]">
66+
</oj-switch>
67+
</oj-bind-if>
7368

7469
</oj-form-layout>
7570

0 commit comments

Comments
 (0)