跳到主要内容

51.multipleCodec

PR #1275

Create v1beta2 and allow multiple Codec encodings to exist

这里的关键变化是“latest”包有一个 Codec 定义了默认的版本


// api/latest/latest.go
package latest

import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)

// Version is the string that represents the current external default version
var Version = "v1beta1"

// Codec is the default codec for serializing output that should use
// the latest supported version. Use this Codec when writing to
// disk, a data store that is not dynamically versioned, or in tests.
// This codec can decode any object that Kubernetes is aware of.
var Codec = v1beta1.Codec

// ResourceVersioner describes a default versioner that can handle all types
// of versioning.
// TODO: when versioning changes, make this part of each API definition.
var ResourceVersioner = runtime.NewJSONBaseResourceVersioner()

PR #1386

Add authenticated TLS support to the client


var config *tls.Config
if auth != nil && len(auth.CertFile) != 0 {
cert, err := tls.LoadX509KeyPair(auth.CertFile, auth.KeyFile)
if err != nil {
return nil, err
}
data, err := ioutil.ReadFile(auth.CAFile)
if err != nil {
return nil, err
}
certPool := x509.NewCertPool()
certPool.AppendCertsFromPEM(data)
config = &tls.Config{
Certificates: []tls.Certificate{
cert,
},
RootCAs: certPool,
ClientCAs: certPool,
ClientAuth: tls.RequireAndVerifyClientCert,
}
} else {
config = &tls.Config{
InsecureSkipVerify: true,
}
}

return &RESTClient{
host: base.String(),
prefix: prefix.Path,
secure: prefix.Scheme == "https",
auth: auth,
httpClient: &http.Client{
Transport: &http.Transport{
TLSClientConfig: config,
},
},

PR #1318

Adding endpoint for log retrieval on the minion

// GetKubeletContainerLogs returns logs from the container
func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail string, follow bool, writer io.Writer) error {
dockerContainers, err := dockertools.GetKubeletDockerContainers(kl.dockerClient)
if err != nil {
return err
}
var uuid string
dockerContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uuid, containerName)
if !found {
return fmt.Errorf("container not found (%s)\n", containerName)
}
return dockertools.GetKubeletDockerContainerLogs(kl.dockerClient, dockerContainer.ID, tail , follow, writer)
}

PR #1340

Cleanup watch encoding w/ RawExtension

PR #1390

Allow STDIN to kubecfg via -c -. kubecfg 支持从标准输入读取配置

func readConfigData() []byte {
// read from STDIN
if *config == "-" {
data, err := ioutil.ReadAll(os.Stdin)
if err != nil {
glog.Fatalf("Unable to read from STDIN: %v\n", err)
}
return data
}

PR #1421

Generalize the fit scheduler

PR #1420

Initial cut of a spreading and generic scheduler.

type genericScheduler struct {
predicates []FitPredicate
prioritizer PriorityFunction
pods PodLister
random *rand.Rand
randomLock sync.Mutex
}

PR #1354

Add Event to api types

func init() {
api.Scheme.AddKnownTypes("v1beta1",
&PodList{},
&Pod{},
&ReplicationControllerList{},
&ReplicationController{},
&ServiceList{},
&Service{},
&MinionList{},
&Minion{},
&Status{},
&ServerOpList{},
&ServerOp{},
&ContainerManifestList{},
&Endpoints{},
&EndpointsList{},
&Binding{},
&Event{},
&EventList{},
)
}

// ObjectReference contains enough information to let you inspect or modify the referred object.
type ObjectReference struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
UID string `json:"uid,omitempty" yaml:"uid,omitempty"`
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
ResourceVersion uint64 `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`

// Optional. If referring to a piece of an object instead of an entire object, this string
// should contain a valid field access statement. For example,
// if the object reference is to a container within a pod, this would take on a value like:
// "desiredState.manifest.containers[2]". Such statements are valid language constructs in
// both go and JavaScript. This is syntax is chosen only to have some well-defined way of
// referencing a part of an object.
// TODO: this design is not final and this field is subject to change in the future.
FieldPath string `json:"fieldPath,omitempty" yaml:"fieldPath,omitempty"`
}

PR #1114

Proposal: Initial namespaces proposal