以下示例是关于golang中包含v1.Pod用法的示例代码,想了解v1.Pod的具体用法?v1.Pod怎么用?v1.Pod使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。
1/*
2Copyright 2016 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
1/*
2Copyright 2016 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
282// getPodDaemonSets returns a list of DaemonSets that potentially match the pod.
283func (dsc *DaemonSetsController) getPodDaemonSets(pod *v1.Pod) []*extensions.DaemonSet {
284 sets, err := dsc.dsLister.GetPodDaemonSets(pod)
469// up. If the labels of the pod have changed we need to awaken both the old
470// and new set. old and cur must be *v1.Pod types.
471func (dsc *DaemonSetsController) updatePod(old, cur interface{}) {
472 curPod := cur.(*v1.Pod)
473 oldPod := old.(*v1.Pod)
523func (dsc *DaemonSetsController) deletePod(obj interface{}) {
524 pod, ok := obj.(*v1.Pod)
525 // When a delete is dropped, the relist will notice a pod in the store not
1055 }
1056 if pod.Status.Phase == v1.PodSucceeded || pod.Status.Phase == v1.PodFailed {
1057 continue
218 pod := newPod(fmt.Sprintf("%s-", nodeName), nodeName, label, ds)
219 pod.Status = v1.PodStatus{Phase: v1.PodFailed}
220 podStore.Add(pod)
396func markPodReady(pod *v1.Pod) {
397 condition := v1.PodCondition{Type: v1.PodReady, Status: v1.ConditionTrue}
398 podutil.UpdatePodCondition(&pod.Status, &condition)
610 Spec: podSpec,
611 Status: v1.PodStatus{Phase: v1.PodSucceeded},
612 })
1032 for _, pod := range daemonPods {
1033 condition := v1.PodCondition{Type: v1.PodReady, Status: v1.ConditionTrue}
1034 pod.Status.Conditions = append(pod.Status.Conditions, condition)
1574 failedPod := newPod("matching-owned-failed-pod-1-", "node-1", simpleDaemonSetLabel, ds)
1575 failedPod.Status = v1.PodStatus{Phase: v1.PodFailed}
1576 wantedPods = append(wantedPods, failedPod)
110// controllers and their scale.
111type podControllerFinder func(*v1.Pod) ([]controllerAndScale, error)
112
185// getPodReplicaSets finds replicasets which have no matching deployments.
186func (dc *DisruptionController) getPodReplicaSets(pod *v1.Pod) ([]controllerAndScale, error) {
187 var casSlice []controllerAndScale
212// getPodStatefulSet returns the statefulset managing the given pod.
213func (dc *DisruptionController) getPodStatefulSets(pod *v1.Pod) ([]controllerAndScale, error) {
214 var casSlice []controllerAndScale
235// getPodDeployments finds deployments for any replicasets which are being managed by deployments.
236func (dc *DisruptionController) getPodDeployments(pod *v1.Pod) ([]controllerAndScale, error) {
237 var casSlice []controllerAndScale
271
272func (dc *DisruptionController) getPodReplicationControllers(pod *v1.Pod) ([]controllerAndScale, error) {
273 var casSlice []controllerAndScale
120 Selector: &metav1.LabelSelector{MatchLabels: selectorMap},
121 Template: v1.PodTemplateSpec{
122 ObjectMeta: metav1.ObjectMeta{
149// create a pod with the given phase for the given rs (same selectors and namespace)
150func newPod(name string, rs *extensions.ReplicaSet, status v1.PodPhase, lastTransitionTime *metav1.Time, properlyOwned bool) *v1.Pod {
151 var conditions []v1.PodCondition
152 if status == v1.PodRunning {
153 condition := v1.PodCondition{Type: v1.PodReady, Status: v1.ConditionTrue}
154 if lastTransitionTime != nil {
163 }
164 return &v1.Pod{
165 ObjectMeta: metav1.ObjectMeta{
175// create count pods with the given phase for the given ReplicaSet (same selectors and namespace), and add them to the store.
176func newPodList(store cache.Store, count int, status v1.PodPhase, labelMap map[string]string, rs *extensions.ReplicaSet, name string) *v1.PodList {
177 pods := []v1.Pod{}
78 Selector: map[string]string{"foo": "bar"},
79 Template: &v1.PodTemplateSpec{
80 ObjectMeta: metav1.ObjectMeta{
107// create a pod with the given phase for the given rc (same selectors and namespace).
108func newPod(name string, rc *v1.ReplicationController, status v1.PodPhase, lastTransitionTime *metav1.Time, properlyOwned bool) *v1.Pod {
109 var conditions []v1.PodCondition
110 if status == v1.PodRunning {
111 condition := v1.PodCondition{Type: v1.PodReady, Status: v1.ConditionTrue}
112 if lastTransitionTime != nil {
122
123 return &v1.Pod{
124 ObjectMeta: metav1.ObjectMeta{
134// create count pods with the given phase for the given rc (same selectors and namespace), and add them to the store.
135func newPodList(store cache.Store, count int, status v1.PodPhase, rc *v1.ReplicationController, name string) *v1.PodList {
136 pods := []v1.Pod{}
264 }
265 pods[0].Status.Phase = v1.PodFailed
266 spc.podsIndexer.Update(pods[0])
690 },
691 validate: func(set *apps.StatefulSet, pods []*v1.Pod) error {
692 sort.Sort(ascendingOrdinal(pods))
1598
1599func copyPod(pod *v1.Pod) *v1.Pod {
1600 obj, err := api.Scheme.Copy(pod)
1668 pod := copyPod(pods[ordinal])
1669 condition := v1.PodCondition{Type: v1.PodReady, Status: v1.ConditionTrue}
1670 podutil.UpdatePodCondition(&pod.Status, &condition)
1704 pod.DeletionTimestamp = &deleted
1705 condition := v1.PodCondition{Type: v1.PodReady, Status: v1.ConditionTrue}
1706 fakeResourceVersion(pod)
66// to be -1.
67func getParentNameAndOrdinal(pod *v1.Pod) (string, int) {
68 parent := ""
81// getParentName gets the name of pod's parent StatefulSet. If pod has not parent, the empty string is returned.
82func getParentName(pod *v1.Pod) string {
83 parent, _ := getParentNameAndOrdinal(pod)
87// getOrdinal gets pod's ordinal. If pod has no ordinal, -1 is returned.
88func getOrdinal(pod *v1.Pod) int {
89 _, ordinal := getParentNameAndOrdinal(pod)
105// isMemberOf tests if pod is a member of set.
106func isMemberOf(set *apps.StatefulSet, pod *v1.Pod) bool {
107 return getParentName(pod) == set.Name
110// identityMatches returns true if pod has a valid identity and network identity for a member of set.
111func identityMatches(set *apps.StatefulSet, pod *v1.Pod) bool {
112 parent, ordinal := getParentNameAndOrdinal(pod)
206 }
207 pod.Status.Phase = v1.PodRunning
208 if isRunningAndReady(pod) {
210 }
211 condition := v1.PodCondition{Type: v1.PodReady, Status: v1.ConditionTrue}
212 podutil.UpdatePodCondition(&pod.Status, &condition)
231 set := newStatefulSet(10)
232 pods := make([]*v1.Pod, 10)
233 perm := rand.Perm(10)
341
342 template := v1.PodTemplateSpec{
343 Spec: v1.PodSpec{
本文地址:https://www.itbaoku.cn/snippets/415865.html