mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Address comments.
This commit is contained in:
parent
2aa52d043b
commit
4a8a2b5a9f
@ -40,7 +40,8 @@ type serviceInfo struct {
|
|||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
mu sync.Mutex // protects active
|
mu sync.Mutex // protects active
|
||||||
active bool
|
active bool
|
||||||
publicIP []string
|
// TODO: make this an net.IP address
|
||||||
|
publicIP []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (si *serviceInfo) isActive() bool {
|
func (si *serviceInfo) isActive() bool {
|
||||||
@ -506,7 +507,6 @@ func (proxier *Proxier) openPortal(service string, info *serviceInfo) error {
|
|||||||
|
|
||||||
func (proxier *Proxier) openExternalPortal(service string, info *serviceInfo) error {
|
func (proxier *Proxier) openExternalPortal(service string, info *serviceInfo) error {
|
||||||
for _, publicIP := range info.publicIP {
|
for _, publicIP := range info.publicIP {
|
||||||
proxier.iptables.EnsureRule(iptables.TableNAT, iptables.ChainPostrouting, iptablesRoutingArgs(publicIP)...)
|
|
||||||
args := iptablesPortalArgs(net.ParseIP(publicIP), info.portalPort, info.protocol, proxier.listenAddress, info.proxyPort, service)
|
args := iptablesPortalArgs(net.ParseIP(publicIP), info.portalPort, info.protocol, proxier.listenAddress, info.proxyPort, service)
|
||||||
existed, err := proxier.iptables.EnsureRule(iptables.TableNAT, iptablesProxyChain, args...)
|
existed, err := proxier.iptables.EnsureRule(iptables.TableNAT, iptablesProxyChain, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -535,7 +535,6 @@ func (proxier *Proxier) closePortal(service string, info *serviceInfo) error {
|
|||||||
|
|
||||||
func (proxier *Proxier) closeExternalPortal(service string, info *serviceInfo) error {
|
func (proxier *Proxier) closeExternalPortal(service string, info *serviceInfo) error {
|
||||||
for _, publicIP := range info.publicIP {
|
for _, publicIP := range info.publicIP {
|
||||||
proxier.iptables.DeleteRule(iptables.TableNAT, iptables.ChainPostrouting, iptablesRoutingArgs(publicIP)...)
|
|
||||||
args := iptablesPortalArgs(net.ParseIP(publicIP), info.portalPort, info.protocol, proxier.listenAddress, info.proxyPort, service)
|
args := iptablesPortalArgs(net.ParseIP(publicIP), info.portalPort, info.protocol, proxier.listenAddress, info.proxyPort, service)
|
||||||
if err := proxier.iptables.DeleteRule(iptables.TableNAT, iptablesProxyChain, args...); err != nil {
|
if err := proxier.iptables.DeleteRule(iptables.TableNAT, iptablesProxyChain, args...); err != nil {
|
||||||
glog.Errorf("Failed to delete external iptables %s rule for service %q", iptablesProxyChain, service)
|
glog.Errorf("Failed to delete external iptables %s rule for service %q", iptablesProxyChain, service)
|
||||||
@ -577,16 +576,6 @@ var localhostIPv4 = net.ParseIP("127.0.0.1")
|
|||||||
var zeroIPv6 = net.ParseIP("::0")
|
var zeroIPv6 = net.ParseIP("::0")
|
||||||
var localhostIPv6 = net.ParseIP("::1")
|
var localhostIPv6 = net.ParseIP("::1")
|
||||||
|
|
||||||
// Build an iptables args to route in a specific external ip
|
|
||||||
func iptablesRoutingArgs(destIP string) []string {
|
|
||||||
return []string{
|
|
||||||
"!",
|
|
||||||
"-d", destIP + "/32",
|
|
||||||
"-o", "eth0",
|
|
||||||
"-j", "MASQUERADE",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build a slice of iptables args for a portal rule.
|
// Build a slice of iptables args for a portal rule.
|
||||||
func iptablesPortalArgs(destIP net.IP, destPort int, protocol api.Protocol, proxyIP net.IP, proxyPort int, service string) []string {
|
func iptablesPortalArgs(destIP net.IP, destPort int, protocol api.Protocol, proxyIP net.IP, proxyPort int, service string) []string {
|
||||||
args := []string{
|
args := []string{
|
||||||
|
@ -112,6 +112,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
|
|||||||
return apiserver.MakeAsync(func() (runtime.Object, error) {
|
return apiserver.MakeAsync(func() (runtime.Object, error) {
|
||||||
// TODO: Consider moving this to a rectification loop, so that we make/remove external load balancers
|
// TODO: Consider moving this to a rectification loop, so that we make/remove external load balancers
|
||||||
// correctly no matter what http operations happen.
|
// correctly no matter what http operations happen.
|
||||||
|
// TODO: Get rid of ProxyPort.
|
||||||
service.Spec.ProxyPort = 0
|
service.Spec.ProxyPort = 0
|
||||||
if service.Spec.CreateExternalLoadBalancer {
|
if service.Spec.CreateExternalLoadBalancer {
|
||||||
if rs.cloud == nil {
|
if rs.cloud == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user