Skip to content

Commit 4239b84

Browse files
committed
Merge branch 'main' into JIRA-WKTUI-284-multiple-actions
2 parents bb9f1c3 + fa69523 commit 4239b84

File tree

13 files changed

+423
-37
lines changed

13 files changed

+423
-37
lines changed

documentation/staging/content/navigate/kubernetes/k8s-ingress-controller.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ cluster attempts to pull the image and start the container.
4949
- The `Docker Registry Secret Name` field specifies the name of the Kubernetes pull secret to use when pulling the image.
5050
To create this secret, enable `Create Docker Hub Secret` and fill in the pull secret data in the `Docker Hub Username`, `Docker Hub Password`,
5151
and `Docker Hub Email Address` fields.
52+
- For the NGINX ingress controller, if you want to have SSL pass through the ingress route, enable `Allow SSL pass through to target service`.
5253

5354
#### TLS Secret for Ingress Routes
5455
Use this pane to configure the Transport Layer Security (TLS) secret containing the certificate and private key data that will be used by the
@@ -86,11 +87,19 @@ When editing a route:
8687
- Use the `Virtual Host` and `Path Expression` fields to define the matching rules that determine which requests match this route.
8788
- All requests in the defined rules are routed to the service specified by the `Target Service` field that resides in the namespace specified by the read-only
8889
`Target Service Namespace` field and the port specified by the `Target Port` field.
89-
- To enable TLS between the client
90-
and the ingress controller, enable the `Enable TLS` option. Remember, enabling TLS means that the TLS secret
91-
information must be provided in the `TLS Secret for Ingress Routes` pane. Different ingress controllers support advanced ingress route configuration using ingress controller-specific annotations.
90+
- Specify the `Transport Option` for the ingress route:
91+
* Select `Plain HTTP` for unencrypted traffic from the client through the ingress controller to the target service.
92+
* Select `SSL terminate at ingress controller` for SSL
93+
terminating
94+
at the ingress controller and then unencrypted traffic from the ingress controller to the target service.
95+
* Enable `Is target service WebLogic Console?` if the target service is the `WebLogic Console` service.
96+
* Select `SSL pass through` for SSL traffic to pass through the ingress
97+
controller and then terminate at the target service.
98+
* If you select this option, you must also specify a valid DNS value in 'Virtual Host', and all SSL traffic from
99+
the`Virtual Host` will be routed to the target service.
100+
* Make sure that the `Target Port` supports SSL.
92101
- Use the `Ingress Route Annotations` table to
93-
add annotations to the ingress route, as needed.
102+
add annotations to the ingress route, as needed. Do not remove any pre-populated annotations.
94103

95104
### Code View
96105
The `Code View` displays shell scripts for installing an ingress controller and for updating ingress routes. It also

electron/app/js/ipcRendererPreload.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ contextBridge.exposeInMainWorld(
229229
isMac: () => osUtils.isMac(),
230230
isLinux: () => osUtils.isLinux(),
231231
getApplicationName: () => wktApp.getApplicationName(),
232+
getVersion: () => wktApp.getApplicationVersion(),
232233
getArgv: (name) => osUtils.getArgv(name)
233234
},
234235
'i18n': {

electron/app/locales/en/webui.json

Lines changed: 13 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 target service",
612+
"ingress-design-nginx-allow-passthrough-help": "Enable this allows creating SSL pass through ingress transport to the target 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",
@@ -629,7 +631,13 @@
629631
"ingress-design-ingress-route-targetservice-label": "Target Service",
630632
"ingress-design-ingress-route-targetport-label": "Target Port",
631633
"ingress-design-ingress-route-path-label": "Path Expression",
632-
"ingress-design-ingress-route-tls-label": "Enable TLS",
634+
"ingress-design-ingress-route-tls-label": "Transport Options",
635+
"ingress-design-ingress-route-tls-help": "Select the transport option for this ingress route",
636+
"ingress-design-ingress-route-tlsoption-plain": "Plain HTTP",
637+
"ingress-design-ingress-route-tlsoption-ssl-passthrough": "SSL pass through",
638+
"ingress-design-ingress-route-tlsoption-ssl-terminate-ingress": "SSL terminate at ingress controller",
639+
"ingress-design-ingress-route-is-console-svc-label": "Is target service WebLogic Console?",
640+
"ingress-design-ingress-route-is-console-svc-help": "For SSL terminating at ingress and accessing WebLogic Console Service, turn on this option. Your domain must have 'WeblogicPluginEnabled: true' in the 'resources->WebAppContainer' section",
633641
"ingress-design-ingress-route-name-label": "Name",
634642
"ingress-design-ingress-route-dialog-title": "Edit Ingress Route",
635643
"ingress-design-ingress-route-annotation-label": "Annotation",
@@ -645,10 +653,13 @@
645653
"ingress-design-ingress-route-annotation-value-help": "The value for the annotation used for this ingress route.",
646654
"ingress-design-ingress-route-annotation-add-row": "Add Annotation",
647655
"ingress-design-ingress-route-annotation-delete-row": "Delete Annotation",
656+
"ingress-design-ingress-route-traefik-mw-label": "Traefik Middleware",
657+
"ingress-design-ingress-route-traefik-mw-help": "Customize Traefik Middlewares Object",
648658

649659
"ingress-design-ingress-route-name-field-validation-error": "Route {{routeName}}",
650660
"ingress-design-ingress-route-field-validation-error": "Route: {{routeName}}, Field: {{fieldName}}",
651-
"ingress-design-ingress-route-field-tls-config-error": "The route {{routeName}} has the {{fieldName}} field enabled but the {{specifyTlsSecretFieldName}} field is disabled.",
661+
"ingress-design-ingress-route-field-tls-config-error": "The route '{{routeName}}' has the '{{fieldName}}' set to '{{tlsOption}}' but the '{{specifyTlsSecretFieldName}}' field is disabled.",
662+
"ingress-design-ingress-route-field-tls-config-passthrough-error": "The route '{{routeName}}' has the '{{fieldName}}' set to '{{tlsOption}}' but the '{{virtualHostFieldName}}' field is not set, you must provide an valid DNS name in '{{virtualHostFieldName}}'",
652663

653664
"ingress-design-ingress-tls-secret-title": "TLS Secret for Ingress Routes",
654665
"ingress-design-specify-tls-secret-label": "Use Ingress TLS Secret",

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

Lines changed: 2 additions & 2 deletions
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

@@ -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: 180 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ define(['models/wkt-project', 'js-yaml'],
4141

4242
createVoyagerRoutesAsYaml(item) {
4343
const namespace = item['targetServiceNameSpace'] || 'default';
44-
44+
const version = window.api.process.getVersion();
4545
const result = {
4646
apiVersion: 'voyager.appscode.com/v1beta1',
4747
kind: 'Ingress',
4848
metadata: {
4949
name: item['name'],
5050
namespace: namespace,
51+
labels: { createdByWtkUIVersion: version}
5152
},
5253
spec: {
5354
rules: [
@@ -67,29 +68,28 @@ define(['models/wkt-project', 'js-yaml'],
6768
]
6869
}
6970
};
71+
7072
this.addTlsSpec(result, item);
7173
this.addVirtualHost(result, item);
7274
this.addAnnotations(result, item);
7375
return jsYaml.dump(result);
7476
}
7577

7678
createNginxRoutesAsYaml(item) {
77-
return this._createStandardRoutesAsYaml(item);
78-
}
79-
80-
createTraefikRoutesAsYaml(item) {
81-
return this._createStandardRoutesAsYaml(item);
82-
}
83-
84-
_createStandardRoutesAsYaml(item) {
8579
const namespace = item['targetServiceNameSpace'] || 'default';
80+
const version = window.api.process.getVersion();
81+
let path = item['path'];
82+
if (this.isSSLPassThrough(item)) {
83+
path = '/';
84+
}
8685

8786
const result = {
8887
apiVersion: 'networking.k8s.io/v1',
8988
kind: 'Ingress',
9089
metadata: {
9190
name: item['name'],
9291
namespace: namespace,
92+
labels: { createdByWtkUIVersion: version}
9393
},
9494
spec: {
9595
rules: [
@@ -105,7 +105,7 @@ define(['models/wkt-project', 'js-yaml'],
105105
}
106106
}
107107
},
108-
path: item['path'],
108+
path: path,
109109
pathType: 'Prefix'
110110
}
111111
]
@@ -114,22 +114,189 @@ define(['models/wkt-project', 'js-yaml'],
114114
]
115115
}
116116
};
117-
this.addTlsSpec(result, item);
117+
// No need to set TLS if passthrough
118+
if (!this.isSSLPassThrough(item)) {
119+
this.addTlsSpec(result, item);
120+
}
121+
118122
this.addVirtualHost(result, item);
123+
124+
if (this.isSSLTerminateAtIngress(item)) {
125+
if (!('annotations' in item)) {
126+
item['annotations'] = {};
127+
}
128+
// must have nl at the end
129+
item.annotations['nginx.ingress.kubernetes.io/configuration-snippet'] = 'more_clear_input_headers' +
130+
' "WL-Proxy-Client-IP" "WL-Proxy-SSL";\n'
131+
+ 'more_set_input_headers "X-Forwarded-Proto: https";\n'
132+
+ 'more_set_input_headers "WL-Proxy-SSL: true";\n';
133+
item.annotations['nginx.ingress.kubernetes.io/ingress.allow-http'] = 'false';
134+
}
135+
119136
this.addAnnotations(result, item);
120137
return jsYaml.dump(result);
121138
}
122139

140+
isSSLTerminateAtIngress(item) {
141+
if (item && item['tlsOption'] === 'ssl_terminate_ingress') {
142+
return true;
143+
} else {
144+
return false;
145+
}
146+
}
147+
148+
isSSLPassThrough(item) {
149+
if (item && item['tlsOption'] === 'ssl_passthrough') {
150+
return true;
151+
} else {
152+
return false;
153+
}
154+
}
155+
156+
isPlainHTTP(item) {
157+
if (item && item['tlsOption'] === 'plain') {
158+
return true;
159+
} else {
160+
return false;
161+
}
162+
}
163+
164+
createTraefikMiddlewaresAsYaml(item) {
165+
166+
const namespace = item['targetServiceNameSpace'] || 'default';
167+
const version = window.api.process.getVersion();
168+
169+
const result = {
170+
apiVersion: 'traefik.containo.us/v1alpha1',
171+
kind: 'Middleware',
172+
metadata: {
173+
name: item['name'] + '-middleware',
174+
namespace: namespace,
175+
labels: { createdByWtkUIVersion: version}
176+
}
177+
};
178+
179+
if (this.isSSLTerminateAtIngress(item)) {
180+
if (item['isConsoleService']) {
181+
result.spec = {
182+
headers: {
183+
sslRedirect: true,
184+
customRequestHeaders: {
185+
'X-Custom-Request-Header': '',
186+
'X-Forwarded-For': '',
187+
'WL-Proxy-Client-IP': '',
188+
'WL-Proxy-SSL': 'true'
189+
}
190+
}
191+
};
192+
193+
return jsYaml.dump(result);
194+
}
195+
196+
if (item['path'].indexOf('.') < 0) {
197+
result.spec = { replacePathRegex: { regex: '^' + item['path'] + '(.*)', replacement: item['path'] + '/$1'}};
198+
return jsYaml.dump(result);
199+
}
200+
201+
}
202+
203+
}
204+
205+
createTraefikRoutesAsYaml(item) {
206+
207+
let ingressTraefikMiddlewares = this.createTraefikMiddlewaresAsYaml(item);
208+
let useMiddlewares = false;
209+
if (ingressTraefikMiddlewares) {
210+
useMiddlewares = true;
211+
}
212+
213+
const namespace = item['targetServiceNameSpace'] || 'default';
214+
215+
const result = {
216+
apiVersion: 'traefik.containo.us/v1alpha1',
217+
kind: 'IngressRoute',
218+
metadata: {
219+
name: item['name'],
220+
namespace: namespace,
221+
},
222+
spec: {
223+
routes: [
224+
{
225+
kind: 'Rule',
226+
match: {},
227+
services: [{
228+
kind: 'Service',
229+
name: item['targetService'],
230+
port: Number(item['targetPort'])
231+
}]
232+
}
233+
]
234+
}
235+
};
236+
237+
let matchExpression = '';
238+
239+
if (item && item['path']) {
240+
matchExpression += 'PathPrefix(`' + item['path'] + '`)';
241+
}
242+
243+
if (item['virtualHost']) {
244+
if (matchExpression !== '') {
245+
matchExpression += ' && ';
246+
}
247+
matchExpression += 'Host(`' + item['virtualHost'] + '`)';
248+
}
249+
250+
result.spec.routes[0].match = matchExpression;
251+
252+
// if SSL terminate at ingress
253+
if (this.project.ingress.specifyIngressTLSSecret.value && this.isSSLTerminateAtIngress(item)) {
254+
if (!item['tlsSecretName']) {
255+
item['tlsSecretName'] = this.project.ingress.ingressTLSSecretName.value;
256+
}
257+
result.spec.tls = { secretName: item['tlsSecretName'] };
258+
}
259+
// SSL passthrough
260+
if (this.project.ingress.specifyIngressTLSSecret.value && this.isSSLPassThrough(item)) {
261+
const obj = { passthrough: true };
262+
result.spec.tls = obj;
263+
264+
// passthrough is a different kind!
265+
result.kind = 'IngressRouteTCP';
266+
delete result.spec.routes[0].kind;
267+
delete result.spec.routes[0].services[0].kind;
268+
269+
// Set HostSNI
270+
if (item && item['virtualHost']) {
271+
result.spec.routes[0].match = 'HostSNI(`' + item['virtualHost'] + '`)';
272+
}
273+
}
274+
275+
if (useMiddlewares) {
276+
result.spec.routes[0].middlewares = [ {name: item['name'] + '-middleware'} ];
277+
}
278+
279+
this.addAnnotations(result, item);
280+
281+
let yaml = '';
282+
if (ingressTraefikMiddlewares) {
283+
yaml = ingressTraefikMiddlewares;
284+
yaml += '\n---\n';
285+
}
286+
yaml += jsYaml.dump(result);
287+
return yaml;
288+
}
289+
123290
addTlsSpec(result, item) {
124291
// 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) {
292+
if (this.project.ingress.specifyIngressTLSSecret.value && !this.isPlainHTTP(item)) {
126293
if (!item['tlsSecretName']) {
127294
item['tlsSecretName'] = this.project.ingress.ingressTLSSecretName.value;
128295
}
129296

130297
const obj = { secretName: item['tlsSecretName'] };
131298
if (item['virtualHost']) {
132-
obj['hosts'] = item['virtualHost'];
299+
obj['hosts'] = [ item['virtualHost'] ];
133300
}
134301
result.spec.tls = [ obj ];
135302
}

0 commit comments

Comments
 (0)