Commit 752951a6 authored by 黎博's avatar 黎博

修复创建Ingress

parent 0e059e79
...@@ -2046,11 +2046,12 @@ public class K8sService { ...@@ -2046,11 +2046,12 @@ public class K8sService {
Ingress ingress = new Ingress(); Ingress ingress = new Ingress();
ObjectMeta objectMeta = new ObjectMeta(); ObjectMeta objectMeta = new ObjectMeta();
objectMeta.setName(serviceName);
objectMeta.setNamespace(namespace);
Map<String, String> annotationMap = new HashMap<>(); Map<String, String> annotationMap = new HashMap<>();
annotationMap.put("kubernetes.io/ingress.class", "traefik"); annotationMap.put("kubernetes.io/ingress.class", "traefik");
objectMeta.setName(serviceName);
objectMeta.setNamespace(namespace);
objectMeta.setAnnotations(annotationMap); objectMeta.setAnnotations(annotationMap);
objectMeta.setGeneration(1L);
IngressSpec ingressSpec = new IngressSpec(); IngressSpec ingressSpec = new IngressSpec();
List<IngressRule> ingressRuleList = new ArrayList<>(); List<IngressRule> ingressRuleList = new ArrayList<>();
...@@ -2072,12 +2073,12 @@ public class K8sService { ...@@ -2072,12 +2073,12 @@ public class K8sService {
paths.add(ingressPath); paths.add(ingressPath);
httpIngressRuleValue.setPaths(paths); httpIngressRuleValue.setPaths(paths);
ingressRule.setHttp(httpIngressRuleValue); ingressRule.setHttp(httpIngressRuleValue);
ingressRuleList.add(ingressRule);
ingressRule.setHost(domain + "-" + namespace + ".liangkebang.net"); ingressRule.setHost(domain + "-" + namespace + ".liangkebang.net");
ingressRule.setHttp(httpIngressRuleValue); ingressRule.setHttp(httpIngressRuleValue);
ingressRuleList.add(ingressRule); ingressRuleList.add(ingressRule);
ingressSpec.setRules(ingressRuleList); ingressSpec.setRules(ingressRuleList);
System.out.println(JSON.toJSONString(ingressSpec));
ingress.setApiVersion("extensions/v1beta1"); ingress.setApiVersion("extensions/v1beta1");
ingress.setKind("Ingress"); ingress.setKind("Ingress");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment