k8s/io/kubernetes/pkg/api.Container 示例代码

2022-03-03

以下示例是关于golang中包含api.Container用法的示例代码,想了解api.Container的具体用法?api.Container怎么用?api.Container使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。

示例1:
validation_test.go开发语言: Go项目名称: kubernetes代码行数: 2544
335	type T struct {
336		Container      api.Container
337		ExpectedPolicy api.PullPolicy
340		"NotPresent1": {
341			api.Container{Name: "abc", Image: "image:latest", ImagePullPolicy: "IfNotPresent"},
342			api.PullIfNotPresent,
344		"NotPresent2": {
345			api.Container{Name: "abc1", Image: "image", ImagePullPolicy: "IfNotPresent"},
346			api.PullIfNotPresent,
348		"Always1": {
349			api.Container{Name: "123", Image: "image:latest", ImagePullPolicy: "Always"},
350			api.PullAlways,
352		"Always2": {
353			api.Container{Name: "1234", Image: "image", ImagePullPolicy: "Always"},
354			api.PullAlways,
示例2:
kubelet.go开发语言: Go项目名称: kubernetes代码行数: 1747
485
486func makeBinds(pod *api.BoundPod, container *api.Container, podVolumes volumeMap) []string {
487	binds := []string{}
500}
501func makePortsAndBindings(container *api.Container) (map[docker.Port]struct{}, map[docker.Port][]docker.PortBinding) {
502	exposedPorts := map[docker.Port]struct{}{}
563type actionHandler interface {
564	Run(podFullName string, uid types.UID, container *api.Container, handler *api.Handler) error
565}
578
579func (kl *Kubelet) runHandler(podFullName string, uid types.UID, container *api.Container, handler *api.Handler) error {
580	actionHandler := kl.newActionHandler(handler)
588// Returns an error if the container isn't part of the pod.
589func fieldPath(pod *api.BoundPod, container *api.Container) (string, error) {
590	for i := range pod.Spec.Containers {
示例3:
kubelet_test.go开发语言: Go项目名称: kubernetes代码行数: 3084
378	kubelet, fakeDocker := newTestKubelet(t)
379	container := api.Container{Name: "bar"}
380	fakeDocker.ContainerList = []docker.APIContainers{
400			Spec: api.PodSpec{
401				Containers: []api.Container{
402					container,
416	kubelet, fakeDocker := newTestKubelet(t)
417	container := api.Container{
418		Name: "bar",
430			Spec: api.PodSpec{
431				Containers: []api.Container{
432					container,
489			Spec: api.PodSpec{
490				Containers: []api.Container{
491					{Name: "bar"},
示例4:
kubelet_test.go开发语言: Go项目名称: kubernetes代码行数: 1165
772	successCaseAll := []Pod{
773		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 80}}}}}},
774		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}}},
777	successCaseNew := Pod{
778		Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 83}}}}},
779	}
785	failureCaseAll := []Pod{
786		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 80}}}}}},
787		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}}},
788		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 82}}}}}},
789	}
790	failureCaseNew := Pod{
791		Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}},
792	}
示例5:
kubelet_test.go开发语言: Go项目名称: kubernetes代码行数: 1129
785		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}}},
786		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 82}}}}}},
787	}
788	successCaseNew := Pod{
789		Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 83}}}}},
790	}
796	failureCaseAll := []Pod{
797		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 80}}}}}},
798		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}}},
799		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 82}}}}}},
800	}
801	failureCaseNew := Pod{
802		Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}},
803	}
示例6:
kubelet_test.go开发语言: Go项目名称: kubernetes代码行数: 860
596		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}}},
597		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 82}}}}}},
598	}
599	successCaseNew := Pod{
600		Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 83}}}}},
601	}
607	failureCaseAll := []Pod{
608		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 80}}}}}},
609		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}}},
610		{Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 82}}}}}},
611	}
612	failureCaseNew := Pod{
613		Manifest: api.ContainerManifest{Containers: []api.Container{{Ports: []api.Port{{HostPort: 81}}}}},
614	}
示例7:
kubelet.go开发语言: Go项目名称: kubernetes代码行数: 599
73func (kl *Kubelet) RunKubelet(file, manifest_url, etcd_servers, address string, port uint) {
74	fileChannel := make(chan api.ContainerManifest)
75	etcdChannel := make(chan []api.ContainerManifest)
137// Returns an error if one occurs.
138func (kl *Kubelet) ContainerExists(manifest *api.ContainerManifest, container *api.Container) (exists bool, foundName string, err error) {
139	containers, err := kl.ListContainers()
215// Creates a name which can be reversed to identify both manifest id and container name.
216func manifestAndContainerToDockerName(manifest *api.ContainerManifest, container *api.Container) string {
217	// Note, manifest.Id could be blank.
238
239func (kl *Kubelet) RunContainer(manifest *api.ContainerManifest, container *api.Container) (name string, err error) {
240	err = kl.pullImage(container.Image)
560// Never returns.
561func (kl *Kubelet) RunSyncLoop(etcdChannel <-chan []api.ContainerManifest, fileChannel, serverChannel, httpChannel <-chan api.ContainerManifest, handler SyncHandler) {
562	var lastFile, lastEtcd, lastHttp, lastServer []api.ContainerManifest
示例8:
kubelet_test.go开发语言: Go项目名称: kubernetes代码行数: 563
143	name := manifestAndContainerToDockerName(
144		&api.ContainerManifest{Id: manifestId},
145		&api.Container{Name: containerName},
167	}
168	manifest := api.ContainerManifest{
169		Id: "qux",
170	}
171	container := api.Container{
172		Name: "foo",
325func TestSyncHTTP(t *testing.T) {
326	containers := api.ContainerManifest{
327		Containers: []api.Container{
328			api.Container{
329				Name:  "foo",
示例9:
kubelet.go开发语言: Go项目名称: kubernetes代码行数: 595
74func (kl *Kubelet) RunKubelet(file, manifest_url, etcd_servers, address string, port uint) {
75	fileChannel := make(chan api.ContainerManifest)
76	etcdChannel := make(chan []api.ContainerManifest)
138// Returns an error if one occurs.
139func (kl *Kubelet) ContainerExists(manifest *api.ContainerManifest, container *api.Container) (exists bool, foundName string, err error) {
140	containers, err := kl.ListContainers()
216// Creates a name which can be reversed to identify both manifest id and container name.
217func manifestAndContainerToDockerName(manifest *api.ContainerManifest, container *api.Container) string {
218	// Note, manifest.Id could be blank.
239
240func (kl *Kubelet) RunContainer(manifest *api.ContainerManifest, container *api.Container) (name string, err error) {
241	err = kl.pullImage(container.Image)
556// Never returns.
557func (kl *Kubelet) RunSyncLoop(etcdChannel <-chan []api.ContainerManifest, fileChannel, serverChannel, httpChannel <-chan api.ContainerManifest, handler SyncHandler) {
558	var lastFile, lastEtcd, lastHttp, lastServer []api.ContainerManifest
示例10:
kubelet.go开发语言: Go项目名称: kubernetes代码行数: 620
76func (kl *Kubelet) RunKubelet(file, manifest_url, etcd_servers, address string, port uint) {
77	fileChannel := make(chan api.ContainerManifest)
78	etcdChannel := make(chan []api.ContainerManifest)
140// Returns an error if one occurs.
141func (kl *Kubelet) ContainerExists(manifest *api.ContainerManifest, container *api.Container) (exists bool, foundName string, err error) {
142	containers, err := kl.ListContainers()
218// Creates a name which can be reversed to identify both manifest id and container name.
219func manifestAndContainerToDockerName(manifest *api.ContainerManifest, container *api.Container) string {
220	// Note, manifest.Id could be blank.
290
291func (kl *Kubelet) RunContainer(manifest *api.ContainerManifest, container *api.Container) (name string, err error) {
292	name = manifestAndContainerToDockerName(manifest, container)
581// Never returns.
582func (kl *Kubelet) RunSyncLoop(etcdChannel <-chan []api.ContainerManifest, fileChannel, serverChannel, httpChannel <-chan api.ContainerManifest, handler SyncHandler) {
583	var lastFile, lastEtcd, lastHttp, lastServer []api.ContainerManifest

本文地址:https://www.itbaoku.cn/snippets/415641.html