Merge pull request #25826 from freehan/svcsourcerange
Automatic merge from submit-queue promote sourceRange into service spec @thockin one more for your pile I will add docs at `http://releases.k8s.io/HEAD/docs/user-guide/services-firewalls.md` cc: @justinsb Fixes: #20392
This commit is contained in:
@@ -3472,6 +3472,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "valid LoadBalancer source range annotation",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.Type = api.ServiceTypeLoadBalancer
|
||||
s.Annotations[service.AnnotationLoadBalancerSourceRangesKey] = "1.2.3.4/8, 5.6.7.8/16"
|
||||
},
|
||||
numErrs: 0,
|
||||
@@ -3479,6 +3480,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "empty LoadBalancer source range annotation",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.Type = api.ServiceTypeLoadBalancer
|
||||
s.Annotations[service.AnnotationLoadBalancerSourceRangesKey] = ""
|
||||
},
|
||||
numErrs: 0,
|
||||
@@ -3488,15 +3490,47 @@ func TestValidateService(t *testing.T) {
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Annotations[service.AnnotationLoadBalancerSourceRangesKey] = "foo.bar"
|
||||
},
|
||||
numErrs: 1,
|
||||
numErrs: 2,
|
||||
},
|
||||
{
|
||||
name: "invalid LoadBalancer source range annotation (invalid CIDR)",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.Type = api.ServiceTypeLoadBalancer
|
||||
s.Annotations[service.AnnotationLoadBalancerSourceRangesKey] = "1.2.3.4/33"
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
{
|
||||
name: "invalid source range for non LoadBalancer type service",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.LoadBalancerSourceRanges = []string{"1.2.3.4/8", "5.6.7.8/16"}
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
{
|
||||
name: "valid LoadBalancer source range",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.Type = api.ServiceTypeLoadBalancer
|
||||
s.Spec.LoadBalancerSourceRanges = []string{"1.2.3.4/8", "5.6.7.8/16"}
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "empty LoadBalancer source range",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.Type = api.ServiceTypeLoadBalancer
|
||||
s.Spec.LoadBalancerSourceRanges = []string{" "}
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
{
|
||||
name: "invalid LoadBalancer source range",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.Type = api.ServiceTypeLoadBalancer
|
||||
s.Spec.LoadBalancerSourceRanges = []string{"foo.bar"}
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
Reference in New Issue
Block a user