|
|
@@ -1,7 +1,9 @@
|
|
|
package cn.seecoder.paas.service.facade.k8s.model;
|
|
|
|
|
|
+import io.fabric8.kubernetes.api.model.networking.v1beta1.IngressTLS;
|
|
|
import io.kubernetes.client.custom.IntOrString;
|
|
|
import io.kubernetes.client.openapi.models.*;
|
|
|
+import io.kubernetes.client.proto.V1beta1Extensions;
|
|
|
import lombok.*;
|
|
|
|
|
|
import java.util.*;
|
|
|
@@ -29,23 +31,33 @@ public class Ingress extends K8sAbstractObject<ExtensionsV1beta1Ingress> {
|
|
|
//重定向的路径,默认为根路径
|
|
|
private static final String redirectPath = DEFAULT_REWRITE_PATH;
|
|
|
|
|
|
+ private List<IngressTls> tls = new ArrayList<>();
|
|
|
+
|
|
|
/*Ingress能暴露HTTP和HTTPS协议口,目前暂不支持HTTPS协议*/
|
|
|
private List<IngressRule> httpRules = new ArrayList<>();
|
|
|
|
|
|
public Ingress(ExtensionsV1beta1Ingress extensionsV1beta1Ingress) {
|
|
|
super(extensionsV1beta1Ingress);
|
|
|
List<ExtensionsV1beta1IngressRule> rules = extensionsV1beta1Ingress.getSpec().getRules();
|
|
|
+ List<ExtensionsV1beta1IngressTLS> exTls = extensionsV1beta1Ingress.getSpec().getTls();
|
|
|
if (rules != null && !rules.isEmpty()) {
|
|
|
httpRules = rules.stream()
|
|
|
.filter(Objects::nonNull)
|
|
|
.map(IngressRule::new)
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
+ if (tls != null && !tls.isEmpty()) {
|
|
|
+ tls = exTls.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(IngressTls::new)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ExtensionsV1beta1Ingress toK8sObject() {
|
|
|
ExtensionsV1beta1IngressSpec ExtensionsV1beta1IngressSpec = new ExtensionsV1beta1IngressSpecBuilder()
|
|
|
+ .withTls()
|
|
|
.withRules(toExtensionsV1beta1IngressRules())
|
|
|
.build();
|
|
|
ExtensionsV1beta1Ingress ExtensionsV1beta1Ingress = new ExtensionsV1beta1IngressBuilder()
|
|
|
@@ -148,4 +160,44 @@ public class Ingress extends K8sAbstractObject<ExtensionsV1beta1Ingress> {
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Data
|
|
|
+ @NoArgsConstructor
|
|
|
+ @AllArgsConstructor
|
|
|
+ @EqualsAndHashCode
|
|
|
+ @Builder
|
|
|
+ public static class IngressTls implements K8sObjectTransformer<ExtensionsV1beta1IngressTLS> {
|
|
|
+
|
|
|
+ private List<String> hosts;
|
|
|
+
|
|
|
+ private String secretName;
|
|
|
+
|
|
|
+ public IngressTls(List<String> hosts) {
|
|
|
+ this.hosts = hosts;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public IngressTls(ExtensionsV1beta1IngressTLS extensionsV1beta1IngressTLS) {
|
|
|
+ this.hosts = extensionsV1beta1IngressTLS.getHosts();
|
|
|
+ this.secretName = extensionsV1beta1IngressTLS.getSecretName();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ExtensionsV1beta1IngressTLS toK8sObject() {
|
|
|
+ return new ExtensionsV1beta1IngressTLSBuilder()
|
|
|
+ .withHosts(hosts)
|
|
|
+ .withNewSecretName(secretName)
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ExtensionsV1beta1IngressTLS> toExtensionsV1beta1IngressTLS() {
|
|
|
+ return tls.stream()
|
|
|
+ .map(IngressTls::toK8sObject)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|