Kubernetes notes (1)--hyperkube

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

k8sA module is used in the hyperkube following functions:

Package Hyperkube are a framework for Kubernetes servers components. It
Allows us to combine all of the Kubernetes servers components into a single
Binary where the user selects which components to run with any individual
Process.
//
Currently, only one server component can is run at once. As such there is
No need to harmonize flags or identify logs across the various servers. Inch
The future we'll support launching and running many Servers-either by
Managing processes or running In-proc.
//
This are inspired by Https://github.com/spf13/cobra. However, as
The eventual goal is-to-run multiple servers from one call, a new package
was needed.

In layman's words, the hyperkube module is the integration of various functions into an executable file, and then specify the module at runtime. For example, km the program is used hyperkube :

$ km --helpThis is an all-in-one binary that can run any of the various Kubernetes-Mesosservers.Usage  km <server> [flags]Servers  apiserver    The main API entrypoint and interface to the storage system. The API server    is also the focal point for all authorization decisions.......

hyperkubeStructure definition:

type HyperKube struct {    Name string // The executable name, used for help and soft-link invocation    Long string // A long description of the binary.  It will be world wrapped before output.    servers     []Server    baseFlags   *pflag.FlagSet    out         io.Writer    helpFlagVal bool}

The definition of the Server structure used:

// Server describes a server that this binary can morph into.type Server struct {    SimpleUsage string        // One line description of the server.    Long        string        // Longer free form description of the server    Run         serverRunFunc // Run the server.  This is not expected to return.    flags *pflag.FlagSet // Flags for the command (and all dependents)    name  string    hk    *HyperKube}

See km the function of the program main :

func main() {    hk := HyperKube{        Name: "km",        Long: "This is an all-in-one binary that can run any of the various Kubernetes-Mesos servers.",    }    hk.AddServer(NewKubeAPIServer())    hk.AddServer(NewControllerManager())    hk.AddServer(NewScheduler())    hk.AddServer(NewKubeletExecutor())    hk.AddServer(NewKubeProxy())    hk.AddServer(NewMinion())    hk.RunToExit(os.Args)}

mainhyperkubean important way to use the function AddServer :

// AddServer adds a server to the HyperKube object.func (hk *HyperKube) AddServer(s *Server) {    hk.servers = append(hk.servers, *s)    hk.servers[len(hk.servers)-1].hk = hk}

As you can see, in this method, hk.servers[len(hk.servers)-1].hk = hk you can have the fields of the Server struct hk point to the same one binary , so that the functions are hyperkube integrated together. the next hyperkube call RunToExit runs the corresponding function.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.