Skip to content

Commit 4022b7b

Browse files
committed
initial stash
1 parent 76f0a38 commit 4022b7b

File tree

7 files changed

+238
-15
lines changed

7 files changed

+238
-15
lines changed

electron/app/locales/en/webui.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,12 @@
623623
"ingress-design-ingress-route-targetservice-label": "Target Service",
624624
"ingress-design-ingress-route-targetport-label": "Target Port",
625625
"ingress-design-ingress-route-path-label": "Path Expression",
626-
"ingress-design-ingress-route-tls-label": "Enable TLS",
626+
"ingress-design-ingress-route-tls-label": "Transport Options",
627+
"ingress-design-ingress-route-tlsoption-plain": "Plain HTTP",
628+
"ingress-design-ingress-route-tlsoption-ssl-passthrough": "HTTPS pass through to the target service",
629+
"ingress-design-ingress-route-tlsoption-ssl-terminate-ingress": "HTTPS terminate at ingress and plain HTTP traffic from ingress to target service",
630+
"ingress-design-ingress-route-is-console-svc-label": "Check if target service is WebLogic Console Service",
631+
"ingress-design-ingress-route-yes-console-svc": "WebLogic Console Service",
627632
"ingress-design-ingress-route-name-label": "Name",
628633
"ingress-design-ingress-route-dialog-title": "Edit Ingress Route",
629634
"ingress-design-ingress-route-annotation-label": "Annotation",
@@ -639,6 +644,8 @@
639644
"ingress-design-ingress-route-annotation-value-help": "The value for the annotation used for this ingress route.",
640645
"ingress-design-ingress-route-annotation-add-row": "Add Annotation",
641646
"ingress-design-ingress-route-annotation-delete-row": "Delete Annotation",
647+
"ingress-design-ingress-route-traefik-mw-label": "Traefik Middleware",
648+
"ingress-design-ingress-route-traefik-mw-help": "Customize Traefik Middlewares Object",
642649

643650
"ingress-design-ingress-route-name-field-validation-error": "Route {{routeName}}",
644651
"ingress-design-ingress-route-field-validation-error": "Route: {{routeName}}, Field: {{fieldName}}",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ define(['knockout', 'utils/observable-properties', 'utils/validation-helper'],
4242

4343
this.ingressRouteKeys = [
4444
'uid', 'name', 'virtualHost', 'targetServiceNameSpace', 'targetService', 'targetPort',
45-
'path', 'tlsEnabled', 'annotations', 'accessPoint', 'markedForDeletion'
45+
'path', 'annotations', 'accessPoint', 'tlsOption', 'markedForDeletion', 'isConsoleService'
4646
];
4747
this.ingressRoutes = props.createListProperty(this.ingressRouteKeys).persistByKey('uid');
4848

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

Lines changed: 140 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ define(['models/wkt-project', 'js-yaml'],
2323
break;
2424

2525
case 'traefik':
26-
ingressRouteData = this.createTraefikRoutesAsYaml(route);
26+
let ingressTraefikMiddlewares = this.createTraefikMiddlewaresAsYaml(route);
27+
let useMiddlewares = false;
28+
if (ingressTraefikMiddlewares) {
29+
lines.push(ingressTraefikMiddlewares, '');
30+
lines.push('---');
31+
useMiddlewares = true;
32+
}
33+
ingressRouteData = this.createTraefikRoutesAsYaml(route, useMiddlewares);
2734
break;
2835

2936
case 'nginx':
@@ -67,6 +74,7 @@ define(['models/wkt-project', 'js-yaml'],
6774
]
6875
}
6976
};
77+
7078
this.addTlsSpec(result, item);
7179
this.addVirtualHost(result, item);
7280
this.addAnnotations(result, item);
@@ -77,8 +85,136 @@ define(['models/wkt-project', 'js-yaml'],
7785
return this._createStandardRoutesAsYaml(item);
7886
}
7987

80-
createTraefikRoutesAsYaml(item) {
81-
return this._createStandardRoutesAsYaml(item);
88+
isTraefikSSLTerminateAtIngress(item) {
89+
if (item && item['tlsOption'] === 'ssl_terminate_ingress') {
90+
return true;
91+
} else {
92+
return false;
93+
}
94+
}
95+
96+
isTraefikSSLPassThrough(item) {
97+
if (item && item['tlsOption'] === 'ssl_passthrough') {
98+
return true;
99+
} else {
100+
return false;
101+
}
102+
}
103+
104+
isTraefikPlain(item) {
105+
if (item && item['tlsOption'] === 'plain') {
106+
return true;
107+
} else {
108+
return false;
109+
}
110+
}
111+
112+
createTraefikMiddlewaresAsYaml(item) {
113+
114+
const namespace = item['targetServiceNameSpace'] || 'default';
115+
116+
const result = {
117+
apiVersion: 'traefik.containo.us/v1alpha1',
118+
kind: 'Middleware',
119+
metadata: {
120+
name: item['name'] + '-middleware',
121+
namespace: namespace,
122+
}
123+
};
124+
125+
if (this.isTraefikSSLTerminateAtIngress(item)) {
126+
if (item['isConsoleService'].includes('yes')) {
127+
console.log('at tthere');
128+
result.spec = {
129+
sslRedirct: true,
130+
headers: {
131+
customRequestHeaders: {
132+
'X-Custom-Request-Header': '',
133+
'X-Forwarded-For': '',
134+
'WL-Proxy-Client-IP': '',
135+
'WL-Proxy-SSL': 'true'
136+
}
137+
}
138+
};
139+
140+
return jsYaml.dump(result);
141+
}
142+
143+
if (item['path'].indexOf('.') < 0) {
144+
console.log('at here');
145+
result.spec = { replacePathRegex: { regex: '^' + item['path'] + '(.*)'}, replacement: item['path'] + '/$1'};
146+
return jsYaml.dump(result);
147+
}
148+
149+
}
150+
151+
}
152+
153+
createTraefikRoutesAsYaml(item, useMiddlewares) {
154+
const namespace = item['targetServiceNameSpace'] || 'default';
155+
156+
const result = {
157+
apiVersion: 'traefik.containo.us/v1alpha1',
158+
kind: 'IngressRoute',
159+
metadata: {
160+
name: item['name'],
161+
namespace: namespace,
162+
},
163+
spec: {
164+
routes: [
165+
{
166+
kind: 'Rule',
167+
match: {},
168+
services: [{
169+
kind: 'Service',
170+
name: item['targetService'],
171+
port: Number(item['targetPort'])
172+
}]
173+
}
174+
]
175+
}
176+
};
177+
178+
let matchExpression = '';
179+
180+
if (item && item['path']) {
181+
matchExpression += 'PathPrefix(`' + item['path'] + '`)';
182+
}
183+
184+
if (item['virtualHost']) {
185+
if (matchExpression !== '') {
186+
matchExpression += ' && ';
187+
}
188+
matchExpression += 'Host(`' + item['virtualHost'] + '`)';
189+
}
190+
191+
result.spec.routes[0].match = matchExpression;
192+
193+
// if SSL terminate at ingress
194+
if (this.project.ingress.specifyIngressTLSSecret.value && this.isTraefikSSLTerminateAtIngress(item)) {
195+
if (!item['tlsSecretName']) {
196+
item['tlsSecretName'] = this.project.ingress.ingressTLSSecretName.value;
197+
}
198+
result.spec.tls = { secretName: item['tlsSecretName'] };
199+
}
200+
// SSL passthrough
201+
console.log(item);
202+
if (this.project.ingress.specifyIngressTLSSecret.value && this.isTraefikSSLPassThrough(item)) {
203+
const obj = { passthrough: true };
204+
result.spec.tls = [ obj ];
205+
206+
// Set HostSNI
207+
if (item && item['virtualHost']) {
208+
result.spec.routes[0].match = 'HostSNI(`' + item['virtualHost'] + '`)';
209+
}
210+
}
211+
212+
if (useMiddlewares) {
213+
result.spec.routes[0].middleware = item['name'] + '-middleware';
214+
}
215+
216+
this.addAnnotations(result, item);
217+
return jsYaml.dump(result);
82218
}
83219

84220
_createStandardRoutesAsYaml(item) {
@@ -122,7 +258,7 @@ define(['models/wkt-project', 'js-yaml'],
122258

123259
addTlsSpec(result, item) {
124260
// If the Ingress TLS secret is not enabled, do not add the ingress TLS secret name even if it exists.
125-
if (this.project.ingress.specifyIngressTLSSecret.value && item && item['tlsEnabled'] === true) {
261+
if (this.project.ingress.specifyIngressTLSSecret.value && !this.isTraefikPlain(item)) {
126262
if (!item['tlsSecretName']) {
127263
item['tlsSecretName'] = this.project.ingress.ingressTLSSecretName.value;
128264
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ function(IngressActionsBase, project, wktConsole, k8sHelper, i18n, projectIo, di
191191
// Currently UI for tls secret is created/assumed in the same namespace of the domain to avoid too many
192192
// inputs and handling another table. Once we moved to dialog format, then this can be accomplished.
193193
//
194-
if (route['tlsEnabled'] === true) {
194+
if (route['tlsOption'] === 'ssl_terminate_ingress') {
195195
route['tlsSecretName'] = this.project.ingress.ingressTLSSecretName.value;
196196
}
197197
let ingressRouteData = {};
@@ -491,15 +491,15 @@ function(IngressActionsBase, project, wktConsole, k8sHelper, i18n, projectIo, di
491491
});
492492
}
493493
}
494-
494+
console.log(ingressDefinition);
495495
if (useNodePort) {
496-
if (ingressDefinition['tLSEnabled'] === true) {
496+
if (ingressDefinition['tlsOption'] !== 'plain') {
497497
results['accessPoint'] = 'https:' + externalLoadBalancerHost + ':' + ingressSSLPort + ingressDefinition.path;
498498
} else {
499499
results['accessPoint'] = 'http:' + externalLoadBalancerHost + ':' + ingressPlainPort + ingressDefinition.path;
500500
}
501501
} else {
502-
if (ingressDefinition['tLSEnabled'] === true) {
502+
if (ingressDefinition['tlsOption'] !== 'plain') {
503503
results['accessPoint'] = 'https:' + externalLoadBalancerHost + ingressDefinition.path;
504504
} else {
505505
results['accessPoint'] = 'http:' + externalLoadBalancerHost + ingressDefinition.path;
@@ -619,7 +619,7 @@ function(IngressActionsBase, project, wktConsole, k8sHelper, i18n, projectIo, di
619619
validationHelper.validateField(validators, data[attribute], isRequired), routeConfig);
620620
});
621621

622-
if (data['tlsEnabled'] && !tlsSecretSpecified) {
622+
if (data['tlsOption'] === 'ssl_terminate_ingress' && !tlsSecretSpecified) {
623623
errFieldMessage = i18n.t('ingress-design-ingress-route-field-validation-error', {
624624
routeName: data['name'],
625625
fieldName: i18n.t('ingress-design-ingress-route-tls-label')

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ function(i18n, accUtils, ko, ArrayDataProvider, BufferingDataProvider, project,
176176
uid: getAnnotationUid(nextIndex),
177177
name: `new-route-${nextIndex}`,
178178
targetServiceNameSpace: this.project.k8sDomain.kubernetesNamespace.value,
179-
accessPoint: ''
179+
accessPoint: '',
180+
tlsOption: 'plain',
181+
isConsoleService: []
180182
};
181183

182184
// if controller is Voyager and provider is baremetal only nodeport is supported, set the default in the UI
@@ -188,6 +190,9 @@ function(i18n, accUtils, ko, ArrayDataProvider, BufferingDataProvider, project,
188190
if (project.ingress.ingressControllerProvider.value === 'nginx') {
189191
newRoute.annotations = {'kubernetes.io/ingress.class': 'nginx'};
190192
}
193+
if (project.ingress.ingressControllerProvider.value === 'traefik') {
194+
newRoute.annotations = {'kubernetes.io/ingress.class': 'traefik'};
195+
}
191196

192197
project.ingress.ingressRoutes.addNewItem(newRoute);
193198
};
@@ -213,6 +218,8 @@ function(i18n, accUtils, ko, ArrayDataProvider, BufferingDataProvider, project,
213218
// no result indicates operation was cancelled
214219
if (result) {
215220
let changed = false;
221+
console.log('after calls');
222+
console.log(result);
216223
project.ingress.ingressRouteKeys.forEach(key => {
217224
if ((key !== 'uid') && result.hasOwnProperty(key)) {
218225
route[key] = result[key];

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,20 @@ function(accUtils, ko, i18n, project, viewHelper, ArrayDataProvider, BufferingDa
3838

3939
this.project = project;
4040
this.route = args.route;
41+
this.route.isConsoleService = [];
4142

4243
this.savedAnnotations = args.route.annotations || {};
4344

45+
this.tlsOptions = [
46+
{ id: 'plain', value: 'plain', text: this.labelMapper('route-tlsoption-plain') },
47+
{ id: 'ssl_terminate_ingress', value: 'ssl_terminate_ingress', text: this.labelMapper('route-tlsoption-ssl-terminate-ingress') },
48+
{ id: 'ssl_passthrough', value: 'ssl_passthrough', text: this.labelMapper('route-tlsoption-ssl-passthrough') },
49+
];
50+
51+
this.isConsoleOptions = [
52+
{ id: 'isConsole', value: 'yes', text: this.labelMapper('route-yes-console-svc') }
53+
];
54+
4455
// this is dynamic to allow i18n fields to load correctly
4556
this.annotationColumns = [
4657
{
@@ -124,6 +135,19 @@ function(accUtils, ko, i18n, project, viewHelper, ArrayDataProvider, BufferingDa
124135
return Object.entries(one).sort().toString() !== Object.entries(two).sort().toString();
125136
}
126137

138+
function addOrDeleteAnnotation(annotations, addAction, key, value, deleteKey) {
139+
if (addAction) {
140+
annotations[key] = value;
141+
} else {
142+
if (key in annotations) {
143+
delete annotations[key];
144+
}
145+
}
146+
if (deleteKey in annotations) {
147+
delete annotations[deleteKey];
148+
}
149+
}
150+
127151
this.okInput = () => {
128152
let tracker = document.getElementById('ingressTracker');
129153
if (tracker.valid !== 'valid') {
@@ -144,12 +168,36 @@ function(accUtils, ko, i18n, project, viewHelper, ArrayDataProvider, BufferingDa
144168
result[propertyName] = property.value;
145169
}
146170
});
171+
console.log(result);
147172

148173
// add annotations if any value has changed
149174
const changedAnnotations = {};
150175
this.annotations.observable().forEach(annotation => {
151176
changedAnnotations[annotation.key] = annotation.value ? annotation.value : '';
152177
});
178+
179+
if (this.project.ingress.ingressControllerProvider.value === 'traefik') {
180+
const sslKey = 'traefik.ingress.kubernetes.io/router.tls';
181+
const tlsOption = result['tlsOption'];
182+
addOrDeleteAnnotation(changedAnnotations, (tlsOption !== 'plain'),
183+
sslKey, 'true', '');
184+
// if user switched to plain
185+
if (tlsOption === 'plain') {
186+
if (sslKey in changedAnnotations) {
187+
delete changedAnnotations[sslKey];
188+
}
189+
}
190+
}
191+
192+
if (this.project.ingress.ingressControllerProvider.value === 'nginx') {
193+
const sslKey = 'nginx.ingress.kubernetes.io/backend-protocol';
194+
const sslPassThroughKey = 'nginx.ingress.kubernetes.io/ssl-passthrough';
195+
const tlsOption = result['tlsOption'];
196+
addOrDeleteAnnotation(changedAnnotations, (tlsOption === 'ssl_terminate_ingress'),
197+
sslKey, 'HTTPS', sslPassThroughKey);
198+
addOrDeleteAnnotation(changedAnnotations, (tlsOption === 'ssl_passthrough'), 'true', sslKey);
199+
}
200+
153201
if(compareObjects(changedAnnotations, this.savedAnnotations)) {
154202
result['annotations'] = changedAnnotations;
155203
}
@@ -161,6 +209,7 @@ function(accUtils, ko, i18n, project, viewHelper, ArrayDataProvider, BufferingDa
161209
$(DIALOG_SELECTOR)[0].close();
162210
args.setValue();
163211
};
212+
164213
}
165214

166215
/*

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,33 @@
4444
help.instruction="[[labelMapper('route-targetport-help')]]"
4545
validators="[[project.ingress.validators.targetPortValidator]]">
4646
</oj-input-number>
47-
<oj-switch label-hint="[[labelMapper('route-tls-label')]]"
48-
value="{{tlsEnabled.observable}}">
49-
</oj-switch>
47+
48+
<oj-radioset id="tlsOptionId"
49+
label-hint="[[labelMapper('route-tls-label')]]"
50+
label-edge="inside"
51+
value="{{tlsOption.observable}}">
52+
<oj-bind-for-each data="[[tlsOptions]]">
53+
<template>
54+
<oj-option value="[[$current.data.value]]">
55+
<oj-bind-text value="[[$current.data.text]]"></oj-bind-text>
56+
</oj-option>
57+
</template>
58+
</oj-bind-for-each>
59+
</oj-radioset>
60+
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>
73+
5074
</oj-form-layout>
5175

5276
<h6 class="wkt-subheading">

0 commit comments

Comments
 (0)