Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ExternalIPs #690

Merged
merged 1 commit into from Nov 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions apis/voyager/ingress.go
Expand Up @@ -82,23 +82,31 @@ type IngressSpec struct {

// If specified, the pod's scheduling constraints
// +optional
Affinity *core.Affinity `json:"affinity,omitempty" protobuf:"bytes,18,opt,name=affinity"`
Affinity *core.Affinity `json:"affinity,omitempty"`

// If specified, the pod will be dispatched by specified scheduler.
// If not specified, the pod will be dispatched by default scheduler.
// +optional
SchedulerName string `json:"schedulerName,omitempty" protobuf:"bytes,19,opt,name=schedulerName"`
SchedulerName string `json:"schedulerName,omitempty"`

// If specified, the pod's tolerations.
// +optional
Tolerations []core.Toleration `json:"tolerations,omitempty" protobuf:"bytes,22,opt,name=tolerations"`
Tolerations []core.Toleration `json:"tolerations,omitempty"`

// ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec.
// If specified, these secrets will be passed to individual puller implementations for them to use. For example,
// in the case of docker, only DockerConfig type secrets are honored.
// More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod
// +optional
ImagePullSecrets []core.LocalObjectReference `json:"imagePullSecrets,omitempty"`

// externalIPs is a list of IP addresses for which nodes in the cluster
// will also accept traffic for this service. These IPs are not managed by
// Kubernetes. The user is responsible for ensuring that traffic arrives
// at a node with this IP. A common example is external load-balancers
// that are not part of the Kubernetes system.
// +optional
ExternalIPs []string `json:"externalIPs,omitempty"`
}

// IngressTLS describes the transport layer security associated with an Ingress.
Expand Down
14 changes: 11 additions & 3 deletions apis/voyager/v1beta1/ingress.go
Expand Up @@ -83,23 +83,31 @@ type IngressSpec struct {

// If specified, the pod's scheduling constraints
// +optional
Affinity *core.Affinity `json:"affinity,omitempty" protobuf:"bytes,18,opt,name=affinity"`
Affinity *core.Affinity `json:"affinity,omitempty"`

// If specified, the pod will be dispatched by specified scheduler.
// If not specified, the pod will be dispatched by default scheduler.
// +optional
SchedulerName string `json:"schedulerName,omitempty" protobuf:"bytes,19,opt,name=schedulerName"`
SchedulerName string `json:"schedulerName,omitempty"`

// If specified, the pod's tolerations.
// +optional
Tolerations []core.Toleration `json:"tolerations,omitempty" protobuf:"bytes,22,opt,name=tolerations"`
Tolerations []core.Toleration `json:"tolerations,omitempty"`

// ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec.
// If specified, these secrets will be passed to individual puller implementations for them to use. For example,
// in the case of docker, only DockerConfig type secrets are honored.
// More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod
// +optional
ImagePullSecrets []core.LocalObjectReference `json:"imagePullSecrets,omitempty"`

// externalIPs is a list of IP addresses for which nodes in the cluster
// will also accept traffic for this service. These IPs are not managed by
// Kubernetes. The user is responsible for ensuring that traffic arrives
// at a node with this IP. A common example is external load-balancers
// that are not part of the Kubernetes system.
// +optional
ExternalIPs []string `json:"externalIPs,omitempty"`
}

// IngressTLS describes the transport layer security associated with an Ingress.
Expand Down
14 changes: 14 additions & 0 deletions apis/voyager/v1beta1/openapi_generated.go
Expand Up @@ -1054,6 +1054,20 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
},
},
},
"externalIPs": {
SchemaProps: spec.SchemaProps{
Description: "externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service. These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
},
},
},
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions apis/voyager/v1beta1/zz_generated.conversion.go
Expand Up @@ -718,6 +718,7 @@ func autoConvert_v1beta1_IngressSpec_To_voyager_IngressSpec(in *IngressSpec, out
out.SchedulerName = in.SchedulerName
out.Tolerations = *(*[]core_v1.Toleration)(unsafe.Pointer(&in.Tolerations))
out.ImagePullSecrets = *(*[]core_v1.LocalObjectReference)(unsafe.Pointer(&in.ImagePullSecrets))
out.ExternalIPs = *(*[]string)(unsafe.Pointer(&in.ExternalIPs))
return nil
}

Expand All @@ -737,6 +738,7 @@ func autoConvert_voyager_IngressSpec_To_v1beta1_IngressSpec(in *voyager.IngressS
out.SchedulerName = in.SchedulerName
out.Tolerations = *(*[]core_v1.Toleration)(unsafe.Pointer(&in.Tolerations))
out.ImagePullSecrets = *(*[]core_v1.LocalObjectReference)(unsafe.Pointer(&in.ImagePullSecrets))
out.ExternalIPs = *(*[]string)(unsafe.Pointer(&in.ExternalIPs))
return nil
}

Expand Down
5 changes: 5 additions & 0 deletions apis/voyager/v1beta1/zz_generated.deepcopy.go
Expand Up @@ -869,6 +869,11 @@ func (in *IngressSpec) DeepCopyInto(out *IngressSpec) {
*out = make([]core_v1.LocalObjectReference, len(*in))
copy(*out, *in)
}
if in.ExternalIPs != nil {
in, out := &in.ExternalIPs, &out.ExternalIPs
*out = make([]string, len(*in))
copy(*out, *in)
}
return
}

Expand Down
5 changes: 5 additions & 0 deletions apis/voyager/zz_generated.deepcopy.go
Expand Up @@ -822,6 +822,11 @@ func (in *IngressSpec) DeepCopyInto(out *IngressSpec) {
*out = make([]core_v1.LocalObjectReference, len(*in))
copy(*out, *in)
}
if in.ExternalIPs != nil {
in, out := &in.ExternalIPs, &out.ExternalIPs
*out = make([]string, len(*in))
copy(*out, *in)
}
return
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/ingress/hostport.go
Expand Up @@ -486,9 +486,10 @@ func (c *hostPortController) newService() *core.Service {
},

Spec: core.ServiceSpec{
Type: core.ServiceTypeClusterIP,
ClusterIP: "None",
Ports: []core.ServicePort{},
Type: core.ServiceTypeClusterIP,
ClusterIP: "None",
Ports: []core.ServicePort{},
ExternalIPs: c.Ingress.Spec.ExternalIPs,
},
}
svc.ObjectMeta = c.ensureOwnerReference(svc.ObjectMeta)
Expand Down
7 changes: 4 additions & 3 deletions pkg/ingress/internal.go
Expand Up @@ -391,9 +391,10 @@ func (c *internalController) newService() *core.Service {
},
},
Spec: core.ServiceSpec{
Type: core.ServiceTypeClusterIP,
Ports: []core.ServicePort{},
Selector: c.Ingress.OffshootLabels(),
Type: core.ServiceTypeClusterIP,
Ports: []core.ServicePort{},
Selector: c.Ingress.OffshootLabels(),
ExternalIPs: c.Ingress.Spec.ExternalIPs,
},
}
svc.ObjectMeta = c.ensureOwnerReference(svc.ObjectMeta)
Expand Down
1 change: 1 addition & 0 deletions pkg/ingress/loadbalancer.go
Expand Up @@ -405,6 +405,7 @@ func (c *loadBalancerController) newService() *core.Service {
Ports: []core.ServicePort{},
Selector: c.Ingress.OffshootLabels(),
LoadBalancerSourceRanges: c.Ingress.Spec.LoadBalancerSourceRanges,
ExternalIPs: c.Ingress.Spec.ExternalIPs,
},
}
svc.ObjectMeta = c.ensureOwnerReference(svc.ObjectMeta)
Expand Down
7 changes: 4 additions & 3 deletions pkg/ingress/nodeport.go
Expand Up @@ -517,9 +517,10 @@ func (c *nodePortController) newService() *core.Service {
},
},
Spec: core.ServiceSpec{
Type: core.ServiceTypeNodePort,
Ports: []core.ServicePort{},
Selector: c.Ingress.OffshootLabels(),
Type: core.ServiceTypeNodePort,
Ports: []core.ServicePort{},
Selector: c.Ingress.OffshootLabels(),
ExternalIPs: c.Ingress.Spec.ExternalIPs,
// https://github.com/kubernetes/kubernetes/issues/33586
// LoadBalancerSourceRanges: lbc.Config.Spec.LoadBalancerSourceRanges,
},
Expand Down
4 changes: 4 additions & 0 deletions pkg/ingress/update.go
Expand Up @@ -129,6 +129,10 @@ func (c *controller) serviceRequiresUpdate(current, desired *core.Service, old *
current.Spec.ExternalTrafficPolicy = desired.Spec.ExternalTrafficPolicy
}

if !sets.NewString(current.Spec.ExternalIPs...).Equal(sets.NewString(desired.Spec.ExternalIPs...)) {
needsUpdate = true
current.Spec.ExternalIPs = desired.Spec.ExternalIPs
}
return current, needsUpdate
}

Expand Down