remove ro service

This commit is contained in:
Daniel Smith
2015-05-06 14:54:54 -07:00
parent f8bf996000
commit 1690617ee6
8 changed files with 32 additions and 155 deletions

View File

@@ -60,10 +60,6 @@ type Controller struct {
ServicePort int
PublicServicePort int
ReadOnlyServiceIP net.IP
ReadOnlyServicePort int
PublicReadOnlyServicePort int
runner *util.Runner
}
@@ -87,11 +83,8 @@ func (c *Controller) Start() {
if err := c.UpdateKubernetesService(); err != nil {
glog.Errorf("Unable to perform initial Kubernetes service initialization: %v", err)
}
if err := c.UpdateKubernetesROService(); err != nil {
glog.Errorf("Unable to perform initial Kubernetes RO service initialization: %v", err)
}
c.runner = util.NewRunner(c.RunKubernetesService, c.RunKubernetesROService, repairClusterIPs.RunUntil, repairNodePorts.RunUntil)
c.runner = util.NewRunner(c.RunKubernetesService, repairClusterIPs.RunUntil, repairNodePorts.RunUntil)
c.runner.Start()
}
@@ -124,34 +117,6 @@ func (c *Controller) UpdateKubernetesService() error {
return nil
}
// RunKubernetesROService periodically updates the kubernetes RO service
func (c *Controller) RunKubernetesROService(ch chan struct{}) {
util.Until(func() {
if err := c.UpdateKubernetesROService(); err != nil {
util.HandleError(fmt.Errorf("unable to sync kubernetes RO service: %v", err))
}
}, c.EndpointInterval, ch)
}
// UpdateKubernetesROService attempts to update the default Kube read-only service.
func (c *Controller) UpdateKubernetesROService() error {
// Update service & endpoint records.
// TODO: when it becomes possible to change this stuff,
// stop polling and start watching.
if err := c.CreateNamespaceIfNeeded(api.NamespaceDefault); err != nil {
return err
}
if c.ReadOnlyServiceIP != nil {
if err := c.CreateMasterServiceIfNeeded("kubernetes-ro", c.ReadOnlyServiceIP, c.ReadOnlyServicePort); err != nil {
return err
}
if err := c.SetEndpoints("kubernetes-ro", c.PublicIP, c.PublicReadOnlyServicePort); err != nil {
return err
}
}
return nil
}
// CreateNamespaceIfNeeded will create the namespace that contains the master services if it doesn't already exist
func (c *Controller) CreateNamespaceIfNeeded(ns string) error {
ctx := api.NewContext()

View File

@@ -119,9 +119,6 @@ type Config struct {
// same value for this field. (Numbers > 1 currently untested.)
MasterCount int
// The port on PublicAddress where a read-only server will be installed.
// Defaults to 7080 if not set.
ReadOnlyPort int
// The port on PublicAddress where a read-write server will be installed.
// Defaults to 6443 if not set.
ReadWritePort int
@@ -178,10 +175,7 @@ type Master struct {
externalHost string
// clusterIP is the IP address of the master within the cluster.
clusterIP net.IP
publicReadOnlyPort int
publicReadWritePort int
serviceReadOnlyIP net.IP
serviceReadOnlyPort int
serviceReadWriteIP net.IP
serviceReadWritePort int
masterServices *util.Runner
@@ -244,9 +238,6 @@ func setDefaults(c *Config) {
// Clearly, there will be at least one master.
c.MasterCount = 1
}
if c.ReadOnlyPort == 0 {
c.ReadOnlyPort = 7080
}
if c.ReadWritePort == 0 {
c.ReadWritePort = 6443
}
@@ -276,7 +267,6 @@ func setDefaults(c *Config) {
// ServiceClusterIPRange
// ServiceNodePortRange
// MasterCount
// ReadOnlyPort
// ReadWritePort
// PublicAddress
// Certain config fields must be specified, including:
@@ -301,16 +291,12 @@ func New(c *Config) *Master {
glog.Fatalf("master.New() called with config.KubeletClient == nil")
}
// Select the first two valid IPs from serviceClusterIPRange to use as the master service IPs
serviceReadOnlyIP, err := ipallocator.GetIndexedIP(c.ServiceClusterIPRange, 1)
if err != nil {
glog.Fatalf("Failed to generate service read-only IP for master service: %v", err)
}
serviceReadWriteIP, err := ipallocator.GetIndexedIP(c.ServiceClusterIPRange, 2)
// Select the first valid IP from serviceClusterIPRange to use as the master service IP.
serviceReadWriteIP, err := ipallocator.GetIndexedIP(c.ServiceClusterIPRange, 1)
if err != nil {
glog.Fatalf("Failed to generate service read-write IP for master service: %v", err)
}
glog.V(4).Infof("Setting master service IPs based to %q (read-only) and %q (read-write).", serviceReadOnlyIP, serviceReadWriteIP)
glog.V(4).Infof("Setting master service IP to %q (read-write).", serviceReadWriteIP)
m := &Master{
serviceClusterIPRange: c.ServiceClusterIPRange,
@@ -335,11 +321,7 @@ func New(c *Config) *Master {
masterCount: c.MasterCount,
externalHost: c.ExternalHost,
clusterIP: c.PublicAddress,
publicReadOnlyPort: c.ReadOnlyPort,
publicReadWritePort: c.ReadWritePort,
serviceReadOnlyIP: serviceReadOnlyIP,
// TODO: serviceReadOnlyPort should be passed in as an argument, it may not always be 80
serviceReadOnlyPort: 80,
serviceReadWriteIP: serviceReadWriteIP,
// TODO: serviceReadWritePort should be passed in as an argument, it may not always be 443
serviceReadWritePort: 443,
@@ -360,6 +342,7 @@ func New(c *Config) *Master {
m.muxHelper = &apiserver.MuxHelper{m.mux, []string{}}
m.init(c)
return m
}
@@ -618,10 +601,6 @@ func (m *Master) NewBootstrapController() *Controller {
ServiceIP: m.serviceReadWriteIP,
ServicePort: m.serviceReadWritePort,
PublicServicePort: m.publicReadWritePort,
ReadOnlyServiceIP: m.serviceReadOnlyIP,
ReadOnlyServicePort: m.serviceReadOnlyPort,
PublicReadOnlyServicePort: m.publicReadOnlyPort,
}
}
@@ -639,10 +618,6 @@ func (m *Master) InstallSwaggerAPI() {
host := m.clusterIP.String()
if m.publicReadWritePort != 0 {
hostAndPort = net.JoinHostPort(host, strconv.Itoa(m.publicReadWritePort))
} else {
// Use the read only port.
hostAndPort = net.JoinHostPort(host, strconv.Itoa(m.publicReadOnlyPort))
protocol = "http://"
}
}
webServicesUrl := protocol + hostAndPort