Add annotation to skip ingress rule
This commit is contained in:
parent
ba964cdcda
commit
89bbb8d4ee
3 changed files with 46 additions and 2 deletions
|
|
@ -26,6 +26,7 @@ import (
|
|||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
apierrs "k8s.io/kubernetes/pkg/api/errors"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/client/cache"
|
||||
"k8s.io/kubernetes/pkg/client/unversioned"
|
||||
"k8s.io/kubernetes/pkg/util/wait"
|
||||
|
|
@ -246,3 +247,29 @@ func waitForPodCondition(kubeClient *unversioned.Client, ns, podName string, con
|
|||
return false, nil
|
||||
})
|
||||
}
|
||||
|
||||
// ingAnnotations represents Ingress annotations.
|
||||
type ingAnnotations map[string]string
|
||||
|
||||
const (
|
||||
// ingressClassKey picks a specific "class" for the Ingress. The controller
|
||||
// only processes Ingresses with this annotation either unset, or set
|
||||
// to either nginxIngressClass or the empty string.
|
||||
ingressClassKey = "kubernetes.io/ingress.class"
|
||||
nginxIngressClass = "nginx"
|
||||
)
|
||||
|
||||
func (ing ingAnnotations) ingressClass() string {
|
||||
val, ok := ing[ingressClassKey]
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
// isNGINXIngress returns true if the given Ingress either doesn't specify the
|
||||
// ingress.class annotation, or it's set to "nginx".
|
||||
func isNGINXIngress(ing *extensions.Ingress) bool {
|
||||
class := ingAnnotations(ing.ObjectMeta.Annotations).ingressClass()
|
||||
return class == "" || class == nginxIngressClass
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue