Skip to content

Commit

Permalink
Add support for k8s v1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
lblackstone committed Jul 30, 2021
1 parent bebc483 commit 550414f
Show file tree
Hide file tree
Showing 326 changed files with 3,832 additions and 2,776 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## HEAD (Unreleased)

- Update Helm and client-go deps (https://github.com/pulumi/pulumi-kubernetes/pull/1662)
- Add support for k8s v1.22.0. (https://github.com/pulumi/pulumi-kubernetes/pull/1551)

## 3.5.2 (July 29, 2021)

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ VERSION ?= $(shell pulumictl get version)
PROVIDER_PATH := provider/v3
VERSION_PATH := ${PROVIDER_PATH}/pkg/version.Version

KUBE_VERSION ?= v1.21.0
KUBE_VERSION ?= v1.22.0-rc.0
SWAGGER_URL ?= https://github.com/kubernetes/kubernetes/raw/${KUBE_VERSION}/api/openapi-spec/swagger.json
OPENAPI_DIR := provider/pkg/gen/openapi-specs
OPENAPI_FILE := ${OPENAPI_DIR}/swagger-${KUBE_VERSION}.json
Expand Down
44 changes: 25 additions & 19 deletions provider/cmd/pulumi-gen-kubernetes/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2018, Pulumi Corporation.
// Copyright 2016-2021, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,16 +40,6 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)

// This is the URL for the v1.17.0 swagger spec. This is the last version of the spec containing the following
// deprecated resources:
// - extensions/v1beta1/*
// - apps/v1beta1/*
// - apps/v1beta2/*
// Since these resources will continue to be important to users for the foreseeable future, we will merge in
// newer specs on top of this spec so that these resources continue to be available in our SDKs.
const Swagger117Url = "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.17.0/api/openapi-spec/swagger.json"
const Swagger117FileName = "swagger-v1.17.0.json"

// TemplateDir is the path to the base directory for code generator templates.
var TemplateDir string

Expand Down Expand Up @@ -144,20 +134,36 @@ func generateSchema(swaggerPath string) schema.PackageSpec {

swaggerDir := filepath.Dir(swaggerPath)

legacySwaggerPath := filepath.Join(swaggerDir, Swagger117FileName)
err = DownloadFile(legacySwaggerPath, Swagger117Url)
if err != nil {
panic(err)
// The following APIs have been deprecated and removed in the more recent versions of k8s:
// - extensions/v1beta1/*
// - apps/v1beta1/*
// - apps/v1beta2/*
// - networking/v1beta1/IngressClass
// Since these resources will continue to be important to users for the foreseeable future, we will merge in
// newer specs on top of this spec so that these resources continue to be available in our SDKs.
urlFmt := "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.%s.0/api/openapi-spec/swagger.json"
filenameFmt := "swagger-v1.%s.0.json"
for _, v := range []string{"17", "18", "19", "20"} {
legacySwaggerPath := filepath.Join(swaggerDir, fmt.Sprintf(filenameFmt, v))
err = DownloadFile(legacySwaggerPath, fmt.Sprintf(urlFmt, v))
if err != nil {
panic(err)
}
legacySwagger, err := ioutil.ReadFile(legacySwaggerPath)
if err != nil {
panic(err)
}
swagger = mergeSwaggerSpecs(legacySwagger, swagger)
}
legacySwagger, err := ioutil.ReadFile(legacySwaggerPath)

var schemaMap map[string]interface{}
err = json.Unmarshal(swagger, &schemaMap)
if err != nil {
panic(err)
}
mergedSwagger := mergeSwaggerSpecs(legacySwagger, swagger)
data := mergedSwagger.(map[string]interface{})

// Generate schema
return gen.PulumiSchema(data)
return gen.PulumiSchema(schemaMap)
}

func writeNodeJSClient(pkg *schema.Package, outdir, templateDir string) {
Expand Down
10 changes: 7 additions & 3 deletions provider/cmd/pulumi-gen-kubernetes/merge.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2020, Pulumi Corporation.
// Copyright 2016-2021, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@ import (
"github.com/imdario/mergo"
)

func mergeSwaggerSpecs(legacyBytes, currentBytes []byte) interface{} {
func mergeSwaggerSpecs(legacyBytes, currentBytes []byte) []byte {

var legacyObj, newObj map[string]interface{}
err := json.Unmarshal(legacyBytes, &legacyObj)
Expand All @@ -35,6 +35,10 @@ func mergeSwaggerSpecs(legacyBytes, currentBytes []byte) interface{} {
if err != nil {
panic(err)
}
b, err := json.Marshal(legacyObj)
if err != nil {
panic(err)
}

return legacyObj
return b
}
629 changes: 316 additions & 313 deletions provider/cmd/pulumi-resource-kubernetes/schema.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion provider/pkg/gen/typegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (d definition) isTopLevel() bool {
// Return `false` for the handful of top-level imperative resource types that can't be managed
// by Pulumi.
switch fmt.Sprintf("%s/%s", d.gvk.GroupVersion().String(), d.gvk.Kind) {
case "policy/v1beta1/Eviction", "v1/Status", "apps/v1beta1/Scale", "apps/v1beta2/Scale",
case "policy/v1beta1/Eviction", "policy/v1/Eviction", "v1/Status", "apps/v1beta1/Scale", "apps/v1beta2/Scale",
"autoscaling/v1/Scale", "extensions/v1beta1/Scale", "core/v1/ComponentStatus", "core/v1/ComponentStatusList":
return false
}
Expand Down
5 changes: 0 additions & 5 deletions provider/pkg/kinds/deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ func AddedInVersion(gvk *schema.GroupVersionKind) *cluster.ServerVersion {
case Lease, LeaseList:
return &v114
}
case CoreV1:
switch k {
case EphemeralContainers:
return &v121
}
case DiscoveryV1B1:
switch k {
case EndpointSlice, EndpointSliceList:
Expand Down
1 change: 0 additions & 1 deletion provider/pkg/kinds/kinds.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const (
EndpointSliceList Kind = "EndpointSliceList"
Endpoints Kind = "Endpoints"
EndpointsList Kind = "EndpointsList"
EphemeralContainers Kind = "EphemeralContainers"
Event Kind = "Event"
EventList Kind = "EventList"
FlowSchema Kind = "FlowSchema"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public InputList<Pulumi.Kubernetes.Types.Inputs.AdmissionRegistration.V1Beta1.Ru
}

/// <summary>
/// SideEffects states whether this webhook has side effects. Acceptable values are: Unknown, None, Some, NoneOnDryRun Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission chain and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some. Defaults to Unknown.
/// SideEffects states whether this webhook has side effects. Acceptable values are: Unknown, None, Some, NoneOnDryRun Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission change and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some. Defaults to Unknown.
/// </summary>
[Input("sideEffects")]
public Input<string>? SideEffects { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public InputList<string> ApiVersions
private InputList<string>? _operations;

/// <summary>
/// Operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or * for all of those operations and any future admission operations that are added. If '*' is present, the length of the slice must be one. Required.
/// Operations is the operations the admission hook cares about - CREATE, UPDATE, or * for all operations. If '*' is present, the length of the slice must be one. Required.
/// </summary>
public InputList<string> Operations
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public InputList<Pulumi.Kubernetes.Types.Inputs.AdmissionRegistration.V1Beta1.Ru
}

/// <summary>
/// SideEffects states whether this webhook has side effects. Acceptable values are: Unknown, None, Some, NoneOnDryRun Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission chain and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some. Defaults to Unknown.
/// SideEffects states whether this webhook has side effects. Acceptable values are: Unknown, None, Some, NoneOnDryRun Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission change and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some. Defaults to Unknown.
/// </summary>
[Input("sideEffects")]
public Input<string>? SideEffects { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public sealed class MutatingWebhook
/// </summary>
public readonly ImmutableArray<Pulumi.Kubernetes.Types.Outputs.AdmissionRegistration.V1Beta1.RuleWithOperations> Rules;
/// <summary>
/// SideEffects states whether this webhook has side effects. Acceptable values are: Unknown, None, Some, NoneOnDryRun Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission chain and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some. Defaults to Unknown.
/// SideEffects states whether this webhook has side effects. Acceptable values are: Unknown, None, Some, NoneOnDryRun Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission change and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some. Defaults to Unknown.
/// </summary>
public readonly string SideEffects;
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class RuleWithOperations
/// </summary>
public readonly ImmutableArray<string> ApiVersions;
/// <summary>
/// Operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or * for all of those operations and any future admission operations that are added. If '*' is present, the length of the slice must be one. Required.
/// Operations is the operations the admission hook cares about - CREATE, UPDATE, or * for all operations. If '*' is present, the length of the slice must be one. Required.
/// </summary>
public readonly ImmutableArray<string> Operations;
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public sealed class ValidatingWebhook
/// </summary>
public readonly ImmutableArray<Pulumi.Kubernetes.Types.Outputs.AdmissionRegistration.V1Beta1.RuleWithOperations> Rules;
/// <summary>
/// SideEffects states whether this webhook has side effects. Acceptable values are: Unknown, None, Some, NoneOnDryRun Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission chain and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some. Defaults to Unknown.
/// SideEffects states whether this webhook has side effects. Acceptable values are: Unknown, None, Some, NoneOnDryRun Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission change and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some. Defaults to Unknown.
/// </summary>
public readonly string SideEffects;
/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions sdk/dotnet/ApiExtensions/V1/CustomResourceDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public partial class CustomResourceDefinition : KubernetesResource
[Output("kind")]
public Output<string> Kind { get; private set; } = null!;

/// <summary>
/// Standard object's metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
/// </summary>
[Output("metadata")]
public Output<Pulumi.Kubernetes.Types.Outputs.Meta.V1.ObjectMeta> Metadata { get; private set; } = null!;

Expand Down Expand Up @@ -118,6 +121,9 @@ public class CustomResourceDefinitionArgs : Pulumi.ResourceArgs
[Input("kind")]
public Input<string>? Kind { get; set; }

/// <summary>
/// Standard object's metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
/// </summary>
[Input("metadata")]
public Input<Pulumi.Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs>? Metadata { get; set; }

Expand Down
6 changes: 6 additions & 0 deletions sdk/dotnet/ApiExtensions/V1/CustomResourceDefinitionList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public partial class CustomResourceDefinitionList : KubernetesResource
[Output("kind")]
public Output<string> Kind { get; private set; } = null!;

/// <summary>
/// Standard object's metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
/// </summary>
[Output("metadata")]
public Output<Pulumi.Kubernetes.Types.Outputs.Meta.V1.ListMeta> Metadata { get; private set; } = null!;

Expand Down Expand Up @@ -120,6 +123,9 @@ public InputList<Pulumi.Kubernetes.Types.Inputs.ApiExtensions.V1.CustomResourceD
[Input("kind")]
public Input<string>? Kind { get; set; }

/// <summary>
/// Standard object's metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
/// </summary>
[Input("metadata")]
public Input<Pulumi.Kubernetes.Types.Inputs.Meta.V1.ListMetaArgs>? Metadata { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public sealed class CustomResourceDefinition
/// 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
/// </summary>
public readonly string Kind;
/// <summary>
/// Standard object's metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
/// </summary>
public readonly Pulumi.Kubernetes.Types.Outputs.Meta.V1.ObjectMeta Metadata;
/// <summary>
/// spec describes how the user wants the resources to appear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Pulumi.Kubernetes.ApiExtensions.V1Beta1
{
/// <summary>
/// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format &lt;.spec.name&gt;.&lt;.spec.group&gt;. Deprecated in v1.16, planned for removal in v1.22. Use apiextensions.k8s.io/v1 CustomResourceDefinition instead.
/// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format &lt;.spec.name&gt;.&lt;.spec.group&gt;. Deprecated in v1.16, planned for removal in v1.19. Use apiextensions.k8s.io/v1 CustomResourceDefinition instead.
/// </summary>
[KubernetesResourceType("kubernetes:apiextensions.k8s.io/v1beta1:CustomResourceDefinition")]
public partial class CustomResourceDefinition : KubernetesResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ public InputList<string> Required
/// x-kubernetes-list-map-keys annotates an array with the x-kubernetes-list-type `map` by specifying the keys used as the index of the map.
///
/// This tag MUST only be used on lists that have the "x-kubernetes-list-type" extension set to "map". Also, the values specified for this attribute must be a scalar typed field of the child structure (no nesting is supported).
///
/// The properties specified must either be required or have a default value, to ensure those properties are present for all list items.
/// </summary>
public InputList<string> X_kubernetes_list_map_keys
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Pulumi.Kubernetes.Types.Outputs.ApiExtensions.V1Beta1
{

/// <summary>
/// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format &lt;.spec.name&gt;.&lt;.spec.group&gt;. Deprecated in v1.16, planned for removal in v1.22. Use apiextensions.k8s.io/v1 CustomResourceDefinition instead.
/// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format &lt;.spec.name&gt;.&lt;.spec.group&gt;. Deprecated in v1.16, planned for removal in v1.19. Use apiextensions.k8s.io/v1 CustomResourceDefinition instead.
/// </summary>
[OutputType]
public sealed class CustomResourceDefinition
Expand Down
2 changes: 0 additions & 2 deletions sdk/dotnet/ApiExtensions/V1Beta1/Outputs/JSONSchemaProps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ public sealed class JSONSchemaProps
/// x-kubernetes-list-map-keys annotates an array with the x-kubernetes-list-type `map` by specifying the keys used as the index of the map.
///
/// This tag MUST only be used on lists that have the "x-kubernetes-list-type" extension set to "map". Also, the values specified for this attribute must be a scalar typed field of the child structure (no nesting is supported).
///
/// The properties specified must either be required or have a default value, to ensure those properties are present for all list items.
/// </summary>
public readonly ImmutableArray<string> X_kubernetes_list_map_keys;
/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions sdk/dotnet/ApiRegistration/V1/APIService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public partial class APIService : KubernetesResource
[Output("kind")]
public Output<string> Kind { get; private set; } = null!;

/// <summary>
/// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
/// </summary>
[Output("metadata")]
public Output<Pulumi.Kubernetes.Types.Outputs.Meta.V1.ObjectMeta> Metadata { get; private set; } = null!;

Expand Down Expand Up @@ -120,6 +123,9 @@ public class APIServiceArgs : Pulumi.ResourceArgs
[Input("kind")]
public Input<string>? Kind { get; set; }

/// <summary>
/// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
/// </summary>
[Input("metadata")]
public Input<Pulumi.Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs>? Metadata { get; set; }

Expand Down
Loading

0 comments on commit 550414f

Please sign in to comment.