1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 23:09:41 +02:00

fix(EE-4782): add portainer internal label to created ingress rules (#8196)

This commit is contained in:
Dakota Walsh 2022-12-20 16:46:51 +13:00 committed by GitHub
parent e1b474d04f
commit 95558ed4ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 4 deletions

View file

@ -5,6 +5,7 @@ import (
"strings"
models "github.com/portainer/portainer/api/http/models/kubernetes"
"github.com/portainer/portainer/api/stacks/stackutils"
"github.com/rs/zerolog/log"
netv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -150,7 +151,7 @@ func (kcl *KubeClient) GetIngresses(namespace string) ([]models.K8sIngressInfo,
}
// CreateIngress creates a new ingress in a given namespace in a k8s endpoint.
func (kcl *KubeClient) CreateIngress(namespace string, info models.K8sIngressInfo) error {
func (kcl *KubeClient) CreateIngress(namespace string, info models.K8sIngressInfo, owner string) error {
ingressClient := kcl.cli.NetworkingV1().Ingresses(namespace)
var ingress netv1.Ingress
@ -160,6 +161,10 @@ func (kcl *KubeClient) CreateIngress(namespace string, info models.K8sIngressInf
ingress.Spec.IngressClassName = &info.ClassName
}
ingress.Annotations = info.Annotations
if ingress.Labels == nil {
ingress.Labels = make(map[string]string)
}
ingress.Labels["io.portainer.kubernetes.application.owner"] = stackutils.SanitizeLabel(owner)
// Store TLS information.
var tls []netv1.IngressTLS