// newDockerPuller creates a new instance of the default implementation of DockerPuller. func newDockerPuller(client DockerInterface, qps float32, burst int) DockerPuller { dp := dockerPuller{ client: client, keyring: credentialprovider.NewDockerKeyring(), } if qps == 0.0 { return dp } return &throttledDockerPuller{ puller: dp, limiter: util.NewTokenBucketRateLimiter(qps, burst), } }
// New creates the rkt container runtime which implements the container runtime interface. // It will test if the rkt binary is in the $PATH, and whether we can get the // version of it. If so, creates the rkt container runtime, otherwise returns an error. func New(config *Config, generator kubecontainer.RunContainerOptionsGenerator, recorder record.EventRecorder, containerRefManager *kubecontainer.RefManager, readinessManager *kubecontainer.ReadinessManager, volumeGetter volumeGetter, serializeImagePulls bool, ) (kubecontainer.Runtime, error) { systemdVersion, err := getSystemdVersion() if err != nil { return nil, err } result, err := systemdVersion.Compare(systemdMinimumVersion) if err != nil { return nil, err } if result < 0 { return nil, fmt.Errorf("rkt: systemd version is too old, requires at least %v", systemdMinimumVersion) } systemd, err := dbus.New() if err != nil { return nil, fmt.Errorf("cannot connect to dbus: %v", err) } rktBinAbsPath := config.Path if rktBinAbsPath == "" { // No default rkt path was set, so try to find one in $PATH. var err error rktBinAbsPath, err = exec.LookPath("rkt") if err != nil { return nil, fmt.Errorf("cannot find rkt binary: %v", err) } } rkt := &runtime{ systemd: systemd, rktBinAbsPath: rktBinAbsPath, config: config, dockerKeyring: credentialprovider.NewDockerKeyring(), containerRefManager: containerRefManager, generator: generator, recorder: recorder, readinessManager: readinessManager, volumeGetter: volumeGetter, } rkt.prober = prober.New(rkt, readinessManager, containerRefManager, recorder) if serializeImagePulls { rkt.imagePuller = kubecontainer.NewSerializedImagePuller(recorder, rkt) } else { rkt.imagePuller = kubecontainer.NewImagePuller(recorder, rkt) } // Test the rkt version. version, err := rkt.Version() if err != nil { return nil, err } result, err = version.Compare(rktMinimumVersion) if err != nil { return nil, err } if result < 0 { return nil, fmt.Errorf("rkt: Version is too old, requires at least %v", rktMinimumVersion) } return rkt, nil }