github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.30.2/go/kubernetes/networking/v1/ingress.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  // Ingress is a collection of rules that allow inbound connections to reach the endpoints defined by a backend. An Ingress can be configured to give services externally-reachable urls, load balance traffic, terminate SSL, offer name based virtual hosting etc.
    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. Ingress object exists.
    22  //  2. Endpoint objects exist with matching names for each Ingress path (except when Service
    23  //     type is ExternalName).
    24  //  3. Ingress entry exists for '.status.loadBalancer.ingress'.
    25  //
    26  // If the Ingress has not reached a Ready state after 10 minutes, it will
    27  // time out and mark the resource update as Failed. You can override the default timeout value
    28  // by setting the 'customTimeouts' option on the resource.
    29  //
    30  // ## Example Usage
    31  // ### Create an Ingress with auto-naming
    32  // ```go
    33  // package main
    34  //
    35  // import (
    36  //
    37  //	metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1"
    38  //	networkingv1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/networking/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 := networkingv1.NewIngress(ctx, "ingress", &networkingv1.IngressArgs{
    46  //				Metadata: &metav1.ObjectMetaArgs{
    47  //					Annotations: pulumi.StringMap{
    48  //						"nginx.ingress.kubernetes.io/rewrite-target": pulumi.String("/"),
    49  //					},
    50  //				},
    51  //				Spec: &networkingv1.IngressSpecArgs{
    52  //					Rules: networkingv1.IngressRuleArray{
    53  //						&networkingv1.IngressRuleArgs{
    54  //							Http: &networkingv1.HTTPIngressRuleValueArgs{
    55  //								Paths: networkingv1.HTTPIngressPathArray{
    56  //									&networkingv1.HTTPIngressPathArgs{
    57  //										Backend: &networkingv1.IngressBackendArgs{
    58  //											Service: &networkingv1.IngressServiceBackendArgs{
    59  //												Name: pulumi.String("test"),
    60  //												Port: &networkingv1.ServiceBackendPortArgs{
    61  //													Number: pulumi.Int(80),
    62  //												},
    63  //											},
    64  //										},
    65  //										Path:     pulumi.String("/testpath"),
    66  //										PathType: pulumi.String("Prefix"),
    67  //									},
    68  //								},
    69  //							},
    70  //						},
    71  //					},
    72  //				},
    73  //			})
    74  //			if err != nil {
    75  //				return err
    76  //			}
    77  //			return nil
    78  //		})
    79  //	}
    80  //
    81  // ```
    82  // ### Create an Ingress with a user-specified name
    83  // ```go
    84  // package main
    85  //
    86  // import (
    87  //
    88  //	metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1"
    89  //	networkingv1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/networking/v1"
    90  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    91  //
    92  // )
    93  //
    94  //	func main() {
    95  //		pulumi.Run(func(ctx *pulumi.Context) error {
    96  //			_, err := networkingv1.NewIngress(ctx, "ingress", &networkingv1.IngressArgs{
    97  //				Metadata: &metav1.ObjectMetaArgs{
    98  //					Annotations: pulumi.StringMap{
    99  //						"nginx.ingress.kubernetes.io/rewrite-target": pulumi.String("/"),
   100  //					},
   101  //					Name: pulumi.String("minimal-ingress"),
   102  //				},
   103  //				Spec: &networkingv1.IngressSpecArgs{
   104  //					Rules: networkingv1.IngressRuleArray{
   105  //						&networkingv1.IngressRuleArgs{
   106  //							Http: &networkingv1.HTTPIngressRuleValueArgs{
   107  //								Paths: networkingv1.HTTPIngressPathArray{
   108  //									&networkingv1.HTTPIngressPathArgs{
   109  //										Backend: &networkingv1.IngressBackendArgs{
   110  //											Service: &networkingv1.IngressServiceBackendArgs{
   111  //												Name: pulumi.String("test"),
   112  //												Port: &networkingv1.ServiceBackendPortArgs{
   113  //													Number: pulumi.Int(80),
   114  //												},
   115  //											},
   116  //										},
   117  //										Path:     pulumi.String("/testpath"),
   118  //										PathType: pulumi.String("Prefix"),
   119  //									},
   120  //								},
   121  //							},
   122  //						},
   123  //					},
   124  //				},
   125  //			})
   126  //			if err != nil {
   127  //				return err
   128  //			}
   129  //			return nil
   130  //		})
   131  //	}
   132  //
   133  // ```
   134  type Ingress struct {
   135  	pulumi.CustomResourceState
   136  
   137  	// 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
   138  	ApiVersion pulumi.StringPtrOutput `pulumi:"apiVersion"`
   139  	// 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
   140  	Kind pulumi.StringPtrOutput `pulumi:"kind"`
   141  	// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   142  	Metadata metav1.ObjectMetaPtrOutput `pulumi:"metadata"`
   143  	// spec is the desired state of the Ingress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   144  	Spec IngressSpecPtrOutput `pulumi:"spec"`
   145  	// status is the current state of the Ingress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   146  	Status IngressStatusPtrOutput `pulumi:"status"`
   147  }
   148  
   149  // NewIngress registers a new resource with the given unique name, arguments, and options.
   150  func NewIngress(ctx *pulumi.Context,
   151  	name string, args *IngressArgs, opts ...pulumi.ResourceOption) (*Ingress, error) {
   152  	if args == nil {
   153  		args = &IngressArgs{}
   154  	}
   155  
   156  	args.ApiVersion = pulumi.StringPtr("networking.k8s.io/v1")
   157  	args.Kind = pulumi.StringPtr("Ingress")
   158  	aliases := pulumi.Aliases([]pulumi.Alias{
   159  		{
   160  			Type: pulumi.String("kubernetes:extensions/v1beta1:Ingress"),
   161  		},
   162  		{
   163  			Type: pulumi.String("kubernetes:networking.k8s.io/v1beta1:Ingress"),
   164  		},
   165  	})
   166  	opts = append(opts, aliases)
   167  	var resource Ingress
   168  	err := ctx.RegisterResource("kubernetes:networking.k8s.io/v1:Ingress", name, args, &resource, opts...)
   169  	if err != nil {
   170  		return nil, err
   171  	}
   172  	return &resource, nil
   173  }
   174  
   175  // GetIngress gets an existing Ingress resource's state with the given name, ID, and optional
   176  // state properties that are used to uniquely qualify the lookup (nil if not required).
   177  func GetIngress(ctx *pulumi.Context,
   178  	name string, id pulumi.IDInput, state *IngressState, opts ...pulumi.ResourceOption) (*Ingress, error) {
   179  	var resource Ingress
   180  	err := ctx.ReadResource("kubernetes:networking.k8s.io/v1:Ingress", name, id, state, &resource, opts...)
   181  	if err != nil {
   182  		return nil, err
   183  	}
   184  	return &resource, nil
   185  }
   186  
   187  // Input properties used for looking up and filtering Ingress resources.
   188  type ingressState struct {
   189  }
   190  
   191  type IngressState struct {
   192  }
   193  
   194  func (IngressState) ElementType() reflect.Type {
   195  	return reflect.TypeOf((*ingressState)(nil)).Elem()
   196  }
   197  
   198  type ingressArgs struct {
   199  	// 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
   200  	ApiVersion *string `pulumi:"apiVersion"`
   201  	// 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
   202  	Kind *string `pulumi:"kind"`
   203  	// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   204  	Metadata *metav1.ObjectMeta `pulumi:"metadata"`
   205  	// spec is the desired state of the Ingress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   206  	Spec *IngressSpec `pulumi:"spec"`
   207  }
   208  
   209  // The set of arguments for constructing a Ingress resource.
   210  type IngressArgs struct {
   211  	// 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
   212  	ApiVersion pulumi.StringPtrInput
   213  	// 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
   214  	Kind pulumi.StringPtrInput
   215  	// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   216  	Metadata metav1.ObjectMetaPtrInput
   217  	// spec is the desired state of the Ingress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   218  	Spec IngressSpecPtrInput
   219  }
   220  
   221  func (IngressArgs) ElementType() reflect.Type {
   222  	return reflect.TypeOf((*ingressArgs)(nil)).Elem()
   223  }
   224  
   225  type IngressInput interface {
   226  	pulumi.Input
   227  
   228  	ToIngressOutput() IngressOutput
   229  	ToIngressOutputWithContext(ctx context.Context) IngressOutput
   230  }
   231  
   232  func (*Ingress) ElementType() reflect.Type {
   233  	return reflect.TypeOf((**Ingress)(nil)).Elem()
   234  }
   235  
   236  func (i *Ingress) ToIngressOutput() IngressOutput {
   237  	return i.ToIngressOutputWithContext(context.Background())
   238  }
   239  
   240  func (i *Ingress) ToIngressOutputWithContext(ctx context.Context) IngressOutput {
   241  	return pulumi.ToOutputWithContext(ctx, i).(IngressOutput)
   242  }
   243  
   244  // IngressArrayInput is an input type that accepts IngressArray and IngressArrayOutput values.
   245  // You can construct a concrete instance of `IngressArrayInput` via:
   246  //
   247  //	IngressArray{ IngressArgs{...} }
   248  type IngressArrayInput interface {
   249  	pulumi.Input
   250  
   251  	ToIngressArrayOutput() IngressArrayOutput
   252  	ToIngressArrayOutputWithContext(context.Context) IngressArrayOutput
   253  }
   254  
   255  type IngressArray []IngressInput
   256  
   257  func (IngressArray) ElementType() reflect.Type {
   258  	return reflect.TypeOf((*[]*Ingress)(nil)).Elem()
   259  }
   260  
   261  func (i IngressArray) ToIngressArrayOutput() IngressArrayOutput {
   262  	return i.ToIngressArrayOutputWithContext(context.Background())
   263  }
   264  
   265  func (i IngressArray) ToIngressArrayOutputWithContext(ctx context.Context) IngressArrayOutput {
   266  	return pulumi.ToOutputWithContext(ctx, i).(IngressArrayOutput)
   267  }
   268  
   269  // IngressMapInput is an input type that accepts IngressMap and IngressMapOutput values.
   270  // You can construct a concrete instance of `IngressMapInput` via:
   271  //
   272  //	IngressMap{ "key": IngressArgs{...} }
   273  type IngressMapInput interface {
   274  	pulumi.Input
   275  
   276  	ToIngressMapOutput() IngressMapOutput
   277  	ToIngressMapOutputWithContext(context.Context) IngressMapOutput
   278  }
   279  
   280  type IngressMap map[string]IngressInput
   281  
   282  func (IngressMap) ElementType() reflect.Type {
   283  	return reflect.TypeOf((*map[string]*Ingress)(nil)).Elem()
   284  }
   285  
   286  func (i IngressMap) ToIngressMapOutput() IngressMapOutput {
   287  	return i.ToIngressMapOutputWithContext(context.Background())
   288  }
   289  
   290  func (i IngressMap) ToIngressMapOutputWithContext(ctx context.Context) IngressMapOutput {
   291  	return pulumi.ToOutputWithContext(ctx, i).(IngressMapOutput)
   292  }
   293  
   294  type IngressOutput struct{ *pulumi.OutputState }
   295  
   296  func (IngressOutput) ElementType() reflect.Type {
   297  	return reflect.TypeOf((**Ingress)(nil)).Elem()
   298  }
   299  
   300  func (o IngressOutput) ToIngressOutput() IngressOutput {
   301  	return o
   302  }
   303  
   304  func (o IngressOutput) ToIngressOutputWithContext(ctx context.Context) IngressOutput {
   305  	return o
   306  }
   307  
   308  // 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
   309  func (o IngressOutput) ApiVersion() pulumi.StringPtrOutput {
   310  	return o.ApplyT(func(v *Ingress) pulumi.StringPtrOutput { return v.ApiVersion }).(pulumi.StringPtrOutput)
   311  }
   312  
   313  // 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
   314  func (o IngressOutput) Kind() pulumi.StringPtrOutput {
   315  	return o.ApplyT(func(v *Ingress) pulumi.StringPtrOutput { return v.Kind }).(pulumi.StringPtrOutput)
   316  }
   317  
   318  // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   319  func (o IngressOutput) Metadata() metav1.ObjectMetaPtrOutput {
   320  	return o.ApplyT(func(v *Ingress) metav1.ObjectMetaPtrOutput { return v.Metadata }).(metav1.ObjectMetaPtrOutput)
   321  }
   322  
   323  // spec is the desired state of the Ingress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   324  func (o IngressOutput) Spec() IngressSpecPtrOutput {
   325  	return o.ApplyT(func(v *Ingress) IngressSpecPtrOutput { return v.Spec }).(IngressSpecPtrOutput)
   326  }
   327  
   328  // status is the current state of the Ingress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
   329  func (o IngressOutput) Status() IngressStatusPtrOutput {
   330  	return o.ApplyT(func(v *Ingress) IngressStatusPtrOutput { return v.Status }).(IngressStatusPtrOutput)
   331  }
   332  
   333  type IngressArrayOutput struct{ *pulumi.OutputState }
   334  
   335  func (IngressArrayOutput) ElementType() reflect.Type {
   336  	return reflect.TypeOf((*[]*Ingress)(nil)).Elem()
   337  }
   338  
   339  func (o IngressArrayOutput) ToIngressArrayOutput() IngressArrayOutput {
   340  	return o
   341  }
   342  
   343  func (o IngressArrayOutput) ToIngressArrayOutputWithContext(ctx context.Context) IngressArrayOutput {
   344  	return o
   345  }
   346  
   347  func (o IngressArrayOutput) Index(i pulumi.IntInput) IngressOutput {
   348  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Ingress {
   349  		return vs[0].([]*Ingress)[vs[1].(int)]
   350  	}).(IngressOutput)
   351  }
   352  
   353  type IngressMapOutput struct{ *pulumi.OutputState }
   354  
   355  func (IngressMapOutput) ElementType() reflect.Type {
   356  	return reflect.TypeOf((*map[string]*Ingress)(nil)).Elem()
   357  }
   358  
   359  func (o IngressMapOutput) ToIngressMapOutput() IngressMapOutput {
   360  	return o
   361  }
   362  
   363  func (o IngressMapOutput) ToIngressMapOutputWithContext(ctx context.Context) IngressMapOutput {
   364  	return o
   365  }
   366  
   367  func (o IngressMapOutput) MapIndex(k pulumi.StringInput) IngressOutput {
   368  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Ingress {
   369  		return vs[0].(map[string]*Ingress)[vs[1].(string)]
   370  	}).(IngressOutput)
   371  }
   372  
   373  func init() {
   374  	pulumi.RegisterInputType(reflect.TypeOf((*IngressInput)(nil)).Elem(), &Ingress{})
   375  	pulumi.RegisterInputType(reflect.TypeOf((*IngressArrayInput)(nil)).Elem(), IngressArray{})
   376  	pulumi.RegisterInputType(reflect.TypeOf((*IngressMapInput)(nil)).Elem(), IngressMap{})
   377  	pulumi.RegisterOutputType(IngressOutput{})
   378  	pulumi.RegisterOutputType(IngressArrayOutput{})
   379  	pulumi.RegisterOutputType(IngressMapOutput{})
   380  }