github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.30.2/go/kubernetes/apps/v1/deployment.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 // Deployment enables declarative updates for Pods and ReplicaSets. 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 Deployment has begun to be updated by the Deployment controller. If the current 22 // generation of the Deployment is > 1, then this means that the current generation must 23 // be different from the generation reported by the last outputs. 24 // 2. There exists a ReplicaSet whose revision is equal to the current revision of the 25 // Deployment. 26 // 3. The Deployment's '.status.conditions' has a status of type 'Available' whose 'status' 27 // member is set to 'True'. 28 // 4. If the Deployment has generation > 1, then '.status.conditions' has a status of type 29 // 'Progressing', whose 'status' member is set to 'True', and whose 'reason' is 30 // 'NewReplicaSetAvailable'. For generation <= 1, this status field does not exist, 31 // because it doesn't do a rollout (i.e., it simply creates the Deployment and 32 // corresponding ReplicaSet), and therefore there is no rollout to mark as 'Progressing'. 33 // 34 // If the Deployment has not reached a Ready state after 10 minutes, it will 35 // time out and mark the resource update as Failed. You can override the default timeout value 36 // by setting the 'customTimeouts' option on the resource. 37 // 38 // ## Example Usage 39 // ### Create a Deployment with auto-naming 40 // ```go 41 // package main 42 // 43 // import ( 44 // 45 // appsv1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/apps/v1" 46 // corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" 47 // metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1" 48 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 49 // 50 // ) 51 // 52 // func main() { 53 // pulumi.Run(func(ctx *pulumi.Context) error { 54 // _, err := appsv1.NewDeployment(ctx, "deployment", &appsv1.DeploymentArgs{ 55 // Metadata: &metav1.ObjectMetaArgs{ 56 // Labels: pulumi.StringMap{ 57 // "app": pulumi.String("nginx"), 58 // }, 59 // }, 60 // Spec: &appsv1.DeploymentSpecArgs{ 61 // Replicas: pulumi.Int(3), 62 // Selector: &metav1.LabelSelectorArgs{ 63 // MatchLabels: pulumi.StringMap{ 64 // "app": pulumi.String("nginx"), 65 // }, 66 // }, 67 // Template: &corev1.PodTemplateSpecArgs{ 68 // Metadata: &metav1.ObjectMetaArgs{ 69 // Labels: pulumi.StringMap{ 70 // "app": pulumi.String("nginx"), 71 // }, 72 // }, 73 // Spec: &corev1.PodSpecArgs{ 74 // Containers: corev1.ContainerArray{ 75 // &corev1.ContainerArgs{ 76 // Image: pulumi.String("nginx:1.14.2"), 77 // Name: pulumi.String("nginx"), 78 // Ports: corev1.ContainerPortArray{ 79 // &corev1.ContainerPortArgs{ 80 // ContainerPort: pulumi.Int(80), 81 // }, 82 // }, 83 // }, 84 // }, 85 // }, 86 // }, 87 // }, 88 // }) 89 // if err != nil { 90 // return err 91 // } 92 // return nil 93 // }) 94 // } 95 // 96 // ``` 97 // ### Create a Deployment with a user-specified name 98 // ```go 99 // package main 100 // 101 // import ( 102 // 103 // appsv1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/apps/v1" 104 // corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" 105 // metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1" 106 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 107 // 108 // ) 109 // 110 // func main() { 111 // pulumi.Run(func(ctx *pulumi.Context) error { 112 // _, err := appsv1.NewDeployment(ctx, "deployment", &appsv1.DeploymentArgs{ 113 // Metadata: &metav1.ObjectMetaArgs{ 114 // Labels: pulumi.StringMap{ 115 // "app": pulumi.String("nginx"), 116 // }, 117 // Name: pulumi.String("nginx-deployment"), 118 // }, 119 // Spec: &appsv1.DeploymentSpecArgs{ 120 // Replicas: pulumi.Int(3), 121 // Selector: &metav1.LabelSelectorArgs{ 122 // MatchLabels: pulumi.StringMap{ 123 // "app": pulumi.String("nginx"), 124 // }, 125 // }, 126 // Template: &corev1.PodTemplateSpecArgs{ 127 // Metadata: &metav1.ObjectMetaArgs{ 128 // Labels: pulumi.StringMap{ 129 // "app": pulumi.String("nginx"), 130 // }, 131 // }, 132 // Spec: &corev1.PodSpecArgs{ 133 // Containers: corev1.ContainerArray{ 134 // &corev1.ContainerArgs{ 135 // Image: pulumi.String("nginx:1.14.2"), 136 // Name: pulumi.String("nginx"), 137 // Ports: corev1.ContainerPortArray{ 138 // &corev1.ContainerPortArgs{ 139 // ContainerPort: pulumi.Int(80), 140 // }, 141 // }, 142 // }, 143 // }, 144 // }, 145 // }, 146 // }, 147 // }) 148 // if err != nil { 149 // return err 150 // } 151 // return nil 152 // }) 153 // } 154 // 155 // ``` 156 type Deployment struct { 157 pulumi.CustomResourceState 158 159 // 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 160 ApiVersion pulumi.StringPtrOutput `pulumi:"apiVersion"` 161 // 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 162 Kind pulumi.StringPtrOutput `pulumi:"kind"` 163 // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 164 Metadata metav1.ObjectMetaPtrOutput `pulumi:"metadata"` 165 // Specification of the desired behavior of the Deployment. 166 Spec DeploymentSpecPtrOutput `pulumi:"spec"` 167 // Most recently observed status of the Deployment. 168 Status DeploymentStatusPtrOutput `pulumi:"status"` 169 } 170 171 // NewDeployment registers a new resource with the given unique name, arguments, and options. 172 func NewDeployment(ctx *pulumi.Context, 173 name string, args *DeploymentArgs, opts ...pulumi.ResourceOption) (*Deployment, error) { 174 if args == nil { 175 args = &DeploymentArgs{} 176 } 177 178 args.ApiVersion = pulumi.StringPtr("apps/v1") 179 args.Kind = pulumi.StringPtr("Deployment") 180 aliases := pulumi.Aliases([]pulumi.Alias{ 181 { 182 Type: pulumi.String("kubernetes:apps/v1beta1:Deployment"), 183 }, 184 { 185 Type: pulumi.String("kubernetes:apps/v1beta2:Deployment"), 186 }, 187 { 188 Type: pulumi.String("kubernetes:extensions/v1beta1:Deployment"), 189 }, 190 }) 191 opts = append(opts, aliases) 192 var resource Deployment 193 err := ctx.RegisterResource("kubernetes:apps/v1:Deployment", name, args, &resource, opts...) 194 if err != nil { 195 return nil, err 196 } 197 return &resource, nil 198 } 199 200 // GetDeployment gets an existing Deployment resource's state with the given name, ID, and optional 201 // state properties that are used to uniquely qualify the lookup (nil if not required). 202 func GetDeployment(ctx *pulumi.Context, 203 name string, id pulumi.IDInput, state *DeploymentState, opts ...pulumi.ResourceOption) (*Deployment, error) { 204 var resource Deployment 205 err := ctx.ReadResource("kubernetes:apps/v1:Deployment", name, id, state, &resource, opts...) 206 if err != nil { 207 return nil, err 208 } 209 return &resource, nil 210 } 211 212 // Input properties used for looking up and filtering Deployment resources. 213 type deploymentState struct { 214 } 215 216 type DeploymentState struct { 217 } 218 219 func (DeploymentState) ElementType() reflect.Type { 220 return reflect.TypeOf((*deploymentState)(nil)).Elem() 221 } 222 223 type deploymentArgs struct { 224 // 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 225 ApiVersion *string `pulumi:"apiVersion"` 226 // 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 227 Kind *string `pulumi:"kind"` 228 // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 229 Metadata *metav1.ObjectMeta `pulumi:"metadata"` 230 // Specification of the desired behavior of the Deployment. 231 Spec *DeploymentSpec `pulumi:"spec"` 232 } 233 234 // The set of arguments for constructing a Deployment resource. 235 type DeploymentArgs struct { 236 // 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 237 ApiVersion pulumi.StringPtrInput 238 // 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 239 Kind pulumi.StringPtrInput 240 // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 241 Metadata metav1.ObjectMetaPtrInput 242 // Specification of the desired behavior of the Deployment. 243 Spec DeploymentSpecPtrInput 244 } 245 246 func (DeploymentArgs) ElementType() reflect.Type { 247 return reflect.TypeOf((*deploymentArgs)(nil)).Elem() 248 } 249 250 type DeploymentInput interface { 251 pulumi.Input 252 253 ToDeploymentOutput() DeploymentOutput 254 ToDeploymentOutputWithContext(ctx context.Context) DeploymentOutput 255 } 256 257 func (*Deployment) ElementType() reflect.Type { 258 return reflect.TypeOf((**Deployment)(nil)).Elem() 259 } 260 261 func (i *Deployment) ToDeploymentOutput() DeploymentOutput { 262 return i.ToDeploymentOutputWithContext(context.Background()) 263 } 264 265 func (i *Deployment) ToDeploymentOutputWithContext(ctx context.Context) DeploymentOutput { 266 return pulumi.ToOutputWithContext(ctx, i).(DeploymentOutput) 267 } 268 269 // DeploymentArrayInput is an input type that accepts DeploymentArray and DeploymentArrayOutput values. 270 // You can construct a concrete instance of `DeploymentArrayInput` via: 271 // 272 // DeploymentArray{ DeploymentArgs{...} } 273 type DeploymentArrayInput interface { 274 pulumi.Input 275 276 ToDeploymentArrayOutput() DeploymentArrayOutput 277 ToDeploymentArrayOutputWithContext(context.Context) DeploymentArrayOutput 278 } 279 280 type DeploymentArray []DeploymentInput 281 282 func (DeploymentArray) ElementType() reflect.Type { 283 return reflect.TypeOf((*[]*Deployment)(nil)).Elem() 284 } 285 286 func (i DeploymentArray) ToDeploymentArrayOutput() DeploymentArrayOutput { 287 return i.ToDeploymentArrayOutputWithContext(context.Background()) 288 } 289 290 func (i DeploymentArray) ToDeploymentArrayOutputWithContext(ctx context.Context) DeploymentArrayOutput { 291 return pulumi.ToOutputWithContext(ctx, i).(DeploymentArrayOutput) 292 } 293 294 // DeploymentMapInput is an input type that accepts DeploymentMap and DeploymentMapOutput values. 295 // You can construct a concrete instance of `DeploymentMapInput` via: 296 // 297 // DeploymentMap{ "key": DeploymentArgs{...} } 298 type DeploymentMapInput interface { 299 pulumi.Input 300 301 ToDeploymentMapOutput() DeploymentMapOutput 302 ToDeploymentMapOutputWithContext(context.Context) DeploymentMapOutput 303 } 304 305 type DeploymentMap map[string]DeploymentInput 306 307 func (DeploymentMap) ElementType() reflect.Type { 308 return reflect.TypeOf((*map[string]*Deployment)(nil)).Elem() 309 } 310 311 func (i DeploymentMap) ToDeploymentMapOutput() DeploymentMapOutput { 312 return i.ToDeploymentMapOutputWithContext(context.Background()) 313 } 314 315 func (i DeploymentMap) ToDeploymentMapOutputWithContext(ctx context.Context) DeploymentMapOutput { 316 return pulumi.ToOutputWithContext(ctx, i).(DeploymentMapOutput) 317 } 318 319 type DeploymentOutput struct{ *pulumi.OutputState } 320 321 func (DeploymentOutput) ElementType() reflect.Type { 322 return reflect.TypeOf((**Deployment)(nil)).Elem() 323 } 324 325 func (o DeploymentOutput) ToDeploymentOutput() DeploymentOutput { 326 return o 327 } 328 329 func (o DeploymentOutput) ToDeploymentOutputWithContext(ctx context.Context) DeploymentOutput { 330 return o 331 } 332 333 // 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 334 func (o DeploymentOutput) ApiVersion() pulumi.StringPtrOutput { 335 return o.ApplyT(func(v *Deployment) pulumi.StringPtrOutput { return v.ApiVersion }).(pulumi.StringPtrOutput) 336 } 337 338 // 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 339 func (o DeploymentOutput) Kind() pulumi.StringPtrOutput { 340 return o.ApplyT(func(v *Deployment) pulumi.StringPtrOutput { return v.Kind }).(pulumi.StringPtrOutput) 341 } 342 343 // Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 344 func (o DeploymentOutput) Metadata() metav1.ObjectMetaPtrOutput { 345 return o.ApplyT(func(v *Deployment) metav1.ObjectMetaPtrOutput { return v.Metadata }).(metav1.ObjectMetaPtrOutput) 346 } 347 348 // Specification of the desired behavior of the Deployment. 349 func (o DeploymentOutput) Spec() DeploymentSpecPtrOutput { 350 return o.ApplyT(func(v *Deployment) DeploymentSpecPtrOutput { return v.Spec }).(DeploymentSpecPtrOutput) 351 } 352 353 // Most recently observed status of the Deployment. 354 func (o DeploymentOutput) Status() DeploymentStatusPtrOutput { 355 return o.ApplyT(func(v *Deployment) DeploymentStatusPtrOutput { return v.Status }).(DeploymentStatusPtrOutput) 356 } 357 358 type DeploymentArrayOutput struct{ *pulumi.OutputState } 359 360 func (DeploymentArrayOutput) ElementType() reflect.Type { 361 return reflect.TypeOf((*[]*Deployment)(nil)).Elem() 362 } 363 364 func (o DeploymentArrayOutput) ToDeploymentArrayOutput() DeploymentArrayOutput { 365 return o 366 } 367 368 func (o DeploymentArrayOutput) ToDeploymentArrayOutputWithContext(ctx context.Context) DeploymentArrayOutput { 369 return o 370 } 371 372 func (o DeploymentArrayOutput) Index(i pulumi.IntInput) DeploymentOutput { 373 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Deployment { 374 return vs[0].([]*Deployment)[vs[1].(int)] 375 }).(DeploymentOutput) 376 } 377 378 type DeploymentMapOutput struct{ *pulumi.OutputState } 379 380 func (DeploymentMapOutput) ElementType() reflect.Type { 381 return reflect.TypeOf((*map[string]*Deployment)(nil)).Elem() 382 } 383 384 func (o DeploymentMapOutput) ToDeploymentMapOutput() DeploymentMapOutput { 385 return o 386 } 387 388 func (o DeploymentMapOutput) ToDeploymentMapOutputWithContext(ctx context.Context) DeploymentMapOutput { 389 return o 390 } 391 392 func (o DeploymentMapOutput) MapIndex(k pulumi.StringInput) DeploymentOutput { 393 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Deployment { 394 return vs[0].(map[string]*Deployment)[vs[1].(string)] 395 }).(DeploymentOutput) 396 } 397 398 func init() { 399 pulumi.RegisterInputType(reflect.TypeOf((*DeploymentInput)(nil)).Elem(), &Deployment{}) 400 pulumi.RegisterInputType(reflect.TypeOf((*DeploymentArrayInput)(nil)).Elem(), DeploymentArray{}) 401 pulumi.RegisterInputType(reflect.TypeOf((*DeploymentMapInput)(nil)).Elem(), DeploymentMap{}) 402 pulumi.RegisterOutputType(DeploymentOutput{}) 403 pulumi.RegisterOutputType(DeploymentArrayOutput{}) 404 pulumi.RegisterOutputType(DeploymentMapOutput{}) 405 }