ingress on first port

This commit is contained in:
w-mj 2023-02-17 16:02:44 +08:00
parent 5f6d11b972
commit c6eb0796ea
No known key found for this signature in database
GPG Key ID: 3A2CB5BE2F835897
2 changed files with 10 additions and 8 deletions

View File

@ -24,4 +24,6 @@ kubectl get secret dev-secret -o yaml
helm repo add traefik https://traefik.github.io/charts helm repo add traefik https://traefik.github.io/charts
helm repo update helm repo update
helm install traefik traefik/traefik helm install traefik traefik/traefik
helm uninstall traefik traefik/traefik
helm install traefik traefik/traefik --set expose.dashboard=true
``` ```

View File

@ -264,13 +264,10 @@ func (c *K8sClient) IngressExists(name string) bool {
func (c *K8sClient) UpdateIngress(a *AppModel) { func (c *K8sClient) UpdateIngress(a *AppModel) {
ports := a.GetPorts() ports := a.GetPorts()
var exportPort int32 = 0 if len(ports) == 0 {
for _, p := range ports { return
if p == 80 || p == 8000 || p == 8080 || p == 8888 {
exportPort = p
break
}
} }
exportPort := ports[0]
if exportPort == 0 { if exportPort == 0 {
return return
} }
@ -282,6 +279,9 @@ func (c *K8sClient) UpdateIngress(a *AppModel) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: a.IngressName(), Name: a.IngressName(),
Labels: label, Labels: label,
Annotations: map[string]string{
//"traefik.ingress.kubernetes.io/router.middlewares": "default-strip-prefix-1@kubernetescrd",
},
}, },
Spec: netv1.IngressSpec{ Spec: netv1.IngressSpec{
Rules: []netv1.IngressRule{ Rules: []netv1.IngressRule{