github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.30.2/go/kubernetes/core/v1/pod.go (about)

     1  // Code generated by pulumigen DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package v1
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts.
    15  //
    16  // This resource waits until its status is ready before registering success
    17  // for create/update, and populating output properties from the current state of the resource.
    18  // The following conditions are used to determine whether the resource creation has
    19  // succeeded or failed:
    20  //
    21  //  1. The Pod is scheduled ("PodScheduled"" '.status.condition' is true).
    22  //  2. The Pod is initialized ("Initialized" '.status.condition' is true).
    23  //  3. The Pod is ready ("Ready" '.status.condition' is true) and the '.status.phase' is
    24  //     set to "Running".
    25  //     Or (for Jobs): The Pod succeeded ('.status.phase' set to "Succeeded").
    26  //
    27  // If the Pod has not reached a Ready state after 10 minutes, it will
    28  // time out and mark the resource update as Failed. You can override the default timeout value
    29  // by setting the 'customTimeouts' option on the resource.
    30  //
    31  // ## Example Usage
    32  // ### Create a Pod with auto-naming
    33  // ```go
    34  // package main
    35  //
    36  // import (
    37  //
    38  //	corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1"
    39  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    40  //
    41  // )
    42  //
    43  //	func main() {
    44  //		pulumi.Run(func(ctx *pulumi.Context) error {
    45  //			_, err := corev1.NewPod(ctx, "pod", &corev1.PodArgs{
    46  //				Spec: &corev1.PodSpecArgs{
    47  //					Containers: corev1.ContainerArray{
    48  //						&corev1.ContainerArgs{
    49  //							Image: pulumi.String("nginx:1.14.2"),
    50  //							Name:  pulumi.String("nginx"),
    51  //							Ports: corev1.ContainerPortArray{
    52  //								&corev1.ContainerPortArgs{
    53  //									ContainerPort: pulumi.Int(80),
    54  //								},
    55  //							},
    56  //						},
    57  //					},
    58  //				},
    59  //			})
    60  //			if err != nil {
    61  //				return err
    62  //			}
    63  //			return nil
    64  //		})
    65  //	}
    66  //
    67  // ```
    68  // ### Create a Pod with a user-specified name
    69  // ```go
    70  // package main
    71  //
    72  // import (
    73  //
    74  //	corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1"
    75  //	metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1"
    76  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    77  //
    78  // )
    79  //
    80  //	func main() {
    81  //		pulumi.Run(func(ctx *pulumi.Context) error {
    82  //			_, err := corev1.NewPod(ctx, "pod", &corev1.PodArgs{
    83  //				Metadata: &metav1.ObjectMetaArgs{
    84  //					Name: pulumi.String("nginx"),
    85  //				},
    86  //				Spec: &corev1.PodSpecArgs{
    87  //					Containers: corev1.ContainerArray{
    88  //						&corev1.ContainerArgs{
    89  //							Image: pulumi.String("nginx:1.14.2"),
    90  //							Name:  pulumi.String("nginx"),
    91  //							Ports: corev1.ContainerPortArray{
    92  //								&corev1.ContainerPortArgs{
    93  //									ContainerPort: pulumi.Int(80),
    94  //								},
    95  //							},
    96  //						},
    97  //					},
    98  //				},
    99  //			})
   100  //			if err != nil {
   101  //				return err
   102  //			}
   103  //			return nil
   104  //		})
   105  //	}
   106  //
   107  // ```
   108  type Pod struct {
   109  	pulumi.CustomResourceState
   110  
   111  	// APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
   112  	ApiVersion pulumi.StringPtrOutput `pulumi:"apiVersion"`
   113  	// Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
   114  	Kind pulumi.StringPtrOutput `pulumi:"kind"`
   115  	// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   116  	Metadata metav1.ObjectMetaPtrOutput `pulumi:"metadata"`
   117  	// Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   118  	Spec PodSpecPtrOutput `pulumi:"spec"`
   119  	// Most recently observed status of the pod. This data may not be up to date. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   120  	Status PodStatusPtrOutput `pulumi:"status"`
   121  }
   122  
   123  // NewPod registers a new resource with the given unique name, arguments, and options.
   124  func NewPod(ctx *pulumi.Context,
   125  	name string, args *PodArgs, opts ...pulumi.ResourceOption) (*Pod, error) {
   126  	if args == nil {
   127  		args = &PodArgs{}
   128  	}
   129  
   130  	args.ApiVersion = pulumi.StringPtr("v1")
   131  	args.Kind = pulumi.StringPtr("Pod")
   132  	var resource Pod
   133  	err := ctx.RegisterResource("kubernetes:core/v1:Pod", name, args, &resource, opts...)
   134  	if err != nil {
   135  		return nil, err
   136  	}
   137  	return &resource, nil
   138  }
   139  
   140  // GetPod gets an existing Pod resource's state with the given name, ID, and optional
   141  // state properties that are used to uniquely qualify the lookup (nil if not required).
   142  func GetPod(ctx *pulumi.Context,
   143  	name string, id pulumi.IDInput, state *PodState, opts ...pulumi.ResourceOption) (*Pod, error) {
   144  	var resource Pod
   145  	err := ctx.ReadResource("kubernetes:core/v1:Pod", name, id, state, &resource, opts...)
   146  	if err != nil {
   147  		return nil, err
   148  	}
   149  	return &resource, nil
   150  }
   151  
   152  // Input properties used for looking up and filtering Pod resources.
   153  type podState struct {
   154  }
   155  
   156  type PodState struct {
   157  }
   158  
   159  func (PodState) ElementType() reflect.Type {
   160  	return reflect.TypeOf((*podState)(nil)).Elem()
   161  }
   162  
   163  type podArgs struct {
   164  	// APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
   165  	ApiVersion *string `pulumi:"apiVersion"`
   166  	// Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
   167  	Kind *string `pulumi:"kind"`
   168  	// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   169  	Metadata *metav1.ObjectMeta `pulumi:"metadata"`
   170  	// Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   171  	Spec *PodSpec `pulumi:"spec"`
   172  }
   173  
   174  // The set of arguments for constructing a Pod resource.
   175  type PodArgs struct {
   176  	// APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
   177  	ApiVersion pulumi.StringPtrInput
   178  	// Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
   179  	Kind pulumi.StringPtrInput
   180  	// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   181  	Metadata metav1.ObjectMetaPtrInput
   182  	// Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   183  	Spec PodSpecPtrInput
   184  }
   185  
   186  func (PodArgs) ElementType() reflect.Type {
   187  	return reflect.TypeOf((*podArgs)(nil)).Elem()
   188  }
   189  
   190  type PodInput interface {
   191  	pulumi.Input
   192  
   193  	ToPodOutput() PodOutput
   194  	ToPodOutputWithContext(ctx context.Context) PodOutput
   195  }
   196  
   197  func (*Pod) ElementType() reflect.Type {
   198  	return reflect.TypeOf((**Pod)(nil)).Elem()
   199  }
   200  
   201  func (i *Pod) ToPodOutput() PodOutput {
   202  	return i.ToPodOutputWithContext(context.Background())
   203  }
   204  
   205  func (i *Pod) ToPodOutputWithContext(ctx context.Context) PodOutput {
   206  	return pulumi.ToOutputWithContext(ctx, i).(PodOutput)
   207  }
   208  
   209  // PodArrayInput is an input type that accepts PodArray and PodArrayOutput values.
   210  // You can construct a concrete instance of `PodArrayInput` via:
   211  //
   212  //	PodArray{ PodArgs{...} }
   213  type PodArrayInput interface {
   214  	pulumi.Input
   215  
   216  	ToPodArrayOutput() PodArrayOutput
   217  	ToPodArrayOutputWithContext(context.Context) PodArrayOutput
   218  }
   219  
   220  type PodArray []PodInput
   221  
   222  func (PodArray) ElementType() reflect.Type {
   223  	return reflect.TypeOf((*[]*Pod)(nil)).Elem()
   224  }
   225  
   226  func (i PodArray) ToPodArrayOutput() PodArrayOutput {
   227  	return i.ToPodArrayOutputWithContext(context.Background())
   228  }
   229  
   230  func (i PodArray) ToPodArrayOutputWithContext(ctx context.Context) PodArrayOutput {
   231  	return pulumi.ToOutputWithContext(ctx, i).(PodArrayOutput)
   232  }
   233  
   234  // PodMapInput is an input type that accepts PodMap and PodMapOutput values.
   235  // You can construct a concrete instance of `PodMapInput` via:
   236  //
   237  //	PodMap{ "key": PodArgs{...} }
   238  type PodMapInput interface {
   239  	pulumi.Input
   240  
   241  	ToPodMapOutput() PodMapOutput
   242  	ToPodMapOutputWithContext(context.Context) PodMapOutput
   243  }
   244  
   245  type PodMap map[string]PodInput
   246  
   247  func (PodMap) ElementType() reflect.Type {
   248  	return reflect.TypeOf((*map[string]*Pod)(nil)).Elem()
   249  }
   250  
   251  func (i PodMap) ToPodMapOutput() PodMapOutput {
   252  	return i.ToPodMapOutputWithContext(context.Background())
   253  }
   254  
   255  func (i PodMap) ToPodMapOutputWithContext(ctx context.Context) PodMapOutput {
   256  	return pulumi.ToOutputWithContext(ctx, i).(PodMapOutput)
   257  }
   258  
   259  type PodOutput struct{ *pulumi.OutputState }
   260  
   261  func (PodOutput) ElementType() reflect.Type {
   262  	return reflect.TypeOf((**Pod)(nil)).Elem()
   263  }
   264  
   265  func (o PodOutput) ToPodOutput() PodOutput {
   266  	return o
   267  }
   268  
   269  func (o PodOutput) ToPodOutputWithContext(ctx context.Context) PodOutput {
   270  	return o
   271  }
   272  
   273  // APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
   274  func (o PodOutput) ApiVersion() pulumi.StringPtrOutput {
   275  	return o.ApplyT(func(v *Pod) pulumi.StringPtrOutput { return v.ApiVersion }).(pulumi.StringPtrOutput)
   276  }
   277  
   278  // Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
   279  func (o PodOutput) Kind() pulumi.StringPtrOutput {
   280  	return o.ApplyT(func(v *Pod) pulumi.StringPtrOutput { return v.Kind }).(pulumi.StringPtrOutput)
   281  }
   282  
   283  // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   284  func (o PodOutput) Metadata() metav1.ObjectMetaPtrOutput {
   285  	return o.ApplyT(func(v *Pod) metav1.ObjectMetaPtrOutput { return v.Metadata }).(metav1.ObjectMetaPtrOutput)
   286  }
   287  
   288  // Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   289  func (o PodOutput) Spec() PodSpecPtrOutput {
   290  	return o.ApplyT(func(v *Pod) PodSpecPtrOutput { return v.Spec }).(PodSpecPtrOutput)
   291  }
   292  
   293  // Most recently observed status of the pod. This data may not be up to date. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   294  func (o PodOutput) Status() PodStatusPtrOutput {
   295  	return o.ApplyT(func(v *Pod) PodStatusPtrOutput { return v.Status }).(PodStatusPtrOutput)
   296  }
   297  
   298  type PodArrayOutput struct{ *pulumi.OutputState }
   299  
   300  func (PodArrayOutput) ElementType() reflect.Type {
   301  	return reflect.TypeOf((*[]*Pod)(nil)).Elem()
   302  }
   303  
   304  func (o PodArrayOutput) ToPodArrayOutput() PodArrayOutput {
   305  	return o
   306  }
   307  
   308  func (o PodArrayOutput) ToPodArrayOutputWithContext(ctx context.Context) PodArrayOutput {
   309  	return o
   310  }
   311  
   312  func (o PodArrayOutput) Index(i pulumi.IntInput) PodOutput {
   313  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Pod {
   314  		return vs[0].([]*Pod)[vs[1].(int)]
   315  	}).(PodOutput)
   316  }
   317  
   318  type PodMapOutput struct{ *pulumi.OutputState }
   319  
   320  func (PodMapOutput) ElementType() reflect.Type {
   321  	return reflect.TypeOf((*map[string]*Pod)(nil)).Elem()
   322  }
   323  
   324  func (o PodMapOutput) ToPodMapOutput() PodMapOutput {
   325  	return o
   326  }
   327  
   328  func (o PodMapOutput) ToPodMapOutputWithContext(ctx context.Context) PodMapOutput {
   329  	return o
   330  }
   331  
   332  func (o PodMapOutput) MapIndex(k pulumi.StringInput) PodOutput {
   333  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Pod {
   334  		return vs[0].(map[string]*Pod)[vs[1].(string)]
   335  	}).(PodOutput)
   336  }
   337  
   338  func init() {
   339  	pulumi.RegisterInputType(reflect.TypeOf((*PodInput)(nil)).Elem(), &Pod{})
   340  	pulumi.RegisterInputType(reflect.TypeOf((*PodArrayInput)(nil)).Elem(), PodArray{})
   341  	pulumi.RegisterInputType(reflect.TypeOf((*PodMapInput)(nil)).Elem(), PodMap{})
   342  	pulumi.RegisterOutputType(PodOutput{})
   343  	pulumi.RegisterOutputType(PodArrayOutput{})
   344  	pulumi.RegisterOutputType(PodMapOutput{})
   345  }