...

Source file src/k8s.io/kubernetes/pkg/proxy/types.go

Documentation: k8s.io/kubernetes/pkg/proxy

     1  /*
     2  Copyright 2015 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package proxy
    18  
    19  import (
    20  	"fmt"
    21  
    22  	v1 "k8s.io/api/core/v1"
    23  	"k8s.io/apimachinery/pkg/types"
    24  	"k8s.io/kubernetes/pkg/proxy/config"
    25  )
    26  
    27  // Provider is the interface provided by proxier implementations.
    28  type Provider interface {
    29  	config.EndpointSliceHandler
    30  	config.ServiceHandler
    31  	config.NodeHandler
    32  	config.ServiceCIDRHandler
    33  
    34  	// Sync immediately synchronizes the Provider's current state to proxy rules.
    35  	Sync()
    36  	// SyncLoop runs periodic work.
    37  	// This is expected to run as a goroutine or as the main loop of the app.
    38  	// It does not return.
    39  	SyncLoop()
    40  }
    41  
    42  // ServicePortName carries a namespace + name + portname.  This is the unique
    43  // identifier for a load-balanced service.
    44  type ServicePortName struct {
    45  	types.NamespacedName
    46  	Port     string
    47  	Protocol v1.Protocol
    48  }
    49  
    50  func (spn ServicePortName) String() string {
    51  	return fmt.Sprintf("%s%s", spn.NamespacedName.String(), fmtPortName(spn.Port))
    52  }
    53  
    54  func fmtPortName(in string) string {
    55  	if in == "" {
    56  		return ""
    57  	}
    58  	return fmt.Sprintf(":%s", in)
    59  }
    60  
    61  // ServiceEndpoint is used to identify a service and one of its endpoint pair.
    62  type ServiceEndpoint struct {
    63  	Endpoint        string
    64  	ServicePortName ServicePortName
    65  }
    66  

View as plain text