wanghongkai 5 anni fa
parent
commit
6ed3d3ca32

+ 2 - 2
src/main/java/cn/seecoder/paas/service/facade/k8s/model/Ingress.java

@@ -22,9 +22,9 @@ public class Ingress extends K8sAbstractObject<ExtensionsV1beta1Ingress> {
 
     private static final String KIND = "Ingress";
 
-    private static final String REWRITE_ANNOTATION = "nginx.ingress.kubernetes.io/rewrite-target";
+    public static final String REWRITE_ANNOTATION = "nginx.ingress.kubernetes.io/rewrite-target";
 
-    private static final String DEFAULT_REWRITE_PATH = "/";
+    public static final String DEFAULT_REWRITE_PATH = "/";
 
     //重定向的路径,默认为根路径
     private static final String redirectPath = DEFAULT_REWRITE_PATH;

+ 4 - 0
src/main/java/cn/seecoder/paas/service/impl/EnvironmentServiceImpl.java

@@ -309,6 +309,10 @@ public class EnvironmentServiceImpl implements EnvironmentService {
                     ingress.setNamespace(deploymentNamespace);
                     ingress.setName(labelValue + "-" + port);
                     ingress.setLabels(labelsMap);
+                    if (configContent.getIngressAnnotations() != null && configContent.getIngressAnnotations().get(port) != null) {
+                        ingress.setAnnotations(configContent.getIngressAnnotations().get(port));
+                    }
+                    ingress.setAnnotation(Ingress.REWRITE_ANNOTATION, Ingress.DEFAULT_REWRITE_PATH);
                     ingress.setHttpRules(Collections.singletonList(
                             Ingress.IngressRule.builder().host(configContent.getHostPrefix() + "-" + port + "." + deploymentHost).ruleValues(
                                     Collections.singleton(Ingress.IngressPath.builder()

+ 4 - 1
src/main/java/cn/seecoder/paas/service/model/vo/ConfigVO.java

@@ -27,7 +27,7 @@ public class ConfigVO {
     private static final ConfigContent EMPTY_CONFIG_CONTENT;
 
     static {
-        EMPTY_CONFIG_CONTENT = new ConfigContent(null, Collections.emptyMap(), null, null, Collections.emptyMap(), Collections.emptyMap(), null, null);
+        EMPTY_CONFIG_CONTENT = new ConfigContent(null, Collections.emptyMap(), null, null, Collections.emptyMap(), Collections.emptyMap(), null, null, Collections.emptyMap());
     }
 
     public static ConfigVO getEmptyConfigVO(ConfigBelongsToType configBelongs, Integer entityId) {
@@ -89,6 +89,9 @@ public class ConfigVO {
         @JsonProperty("replicas")
         private Integer replicas;
 
+        @JsonProperty("ingressAnnotations")
+        private Map<String, Map<String, String>> ingressAnnotations;
+
         @JsonIgnore()
         public boolean isValid() {
             return servicePort != null && hostPrefix != null;

+ 0 - 1
src/main/java/cn/seecoder/paas/util/socket/WebSocketConfig.java

@@ -1,6 +1,5 @@
 package cn.seecoder.paas.util.socket;
 
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.stereotype.Controller;

+ 1 - 1
src/test/java/cn/seecoder/paas/SeecoderPaasApplicationTests.java

@@ -3,7 +3,7 @@ package cn.seecoder.paas;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
 
-@SpringBootTest
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 class SeecoderPaasApplicationTests {
 
     @Test