Kubernetes provider can't create a namespace with a name attribute
See original GitHub issueCommunity Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave “+1” or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
cdktf & Language Versions
{
"name": "tf-cdk",
"version": "1.0.0",
"main": "main.js",
"types": "main.ts",
"license": "MPL-2.0",
"private": true,
"scripts": {
"get": "cdktf get",
"build": "yarn get && tsc",
"synth": "cdktf synth",
"compile": "tsc",
"watch": "tsc -w",
"test": "echo ok",
"upgrade": "npm i cdktf@latest cdktf-cli@latest",
"upgrade:next": "npm i cdktf@next cdktf-cli@next"
},
"engines": {
"node": ">=10.12"
},
"dependencies": {
"cdktf": "0.0.10-pre.2655a66d496aff0bbaeae9a518bea153dae3cee0",
"constructs": "^3.0.4"
},
"devDependencies": {
"@types/node": "^14.0.23",
"cdktf-cli": "0.0.10",
"typescript": "^3.9.6"
}
}
Affected Resource(s)
import { Construct } from 'constructs';
import { App, TerraformStack } from 'cdktf';
import {KubernetesProvider, Namespace} from './.gen/providers/kubernetes';
class MyStack extends TerraformStack {
constructor(scope: Construct, id: string) {
super(scope, id);
// define resources here
new KubernetesProvider(this, 'kind', {});
new Namespace(this, 'tf-cdk', {
metadata: [{
labels: {},
name: 'tf-cdk'
}]
})
}
}
const app = new App();
new MyStack(app, 'tf-cdk');
app.synth();
Debug Output
main.ts:15:9 - error TS2322: Type '{ labels: {}; name: string; }' is not assignable to type 'NamespaceMetadata'.
Object literal may only specify known properties, and 'name' does not exist in type 'NamespaceMetadata'.
15 name: 'tf-cdk'
~~~~~~~~~~~~~~
Found 1 error.
Expected Behavior
Generated Terraform code in the output directory: cdktf.out
Actual Behavior
⠋ synthesizing ...
Warning: Render methods should be a pure function of props and state; triggering nested component updates from render is not allowed. If necessary, trigger nested updates in componentDidUpdate.
Check the render method of Unknown.
non-zero exit code 1
Steps to Reproduce
Try to create a namespace with a name attribute using the Kubernetes provider
Important Factoids
Name is a valid input for the kubernetes_namespace resource.
In the CDK schema doc in namespace.ts
it shows as optional and computed.
"name": {
"type": "string",
"description": "Name of the namespace, must be unique. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names",
"optional": true,
"computed": true
},
It’s absent from the NamespaceMetadata
interface
export interface NamespaceMetadata {
/** An unstructured key value map stored with the namespace that may be used to store arbitrary metadata. More info: http://kubernetes.io/docs/user-guide/annotations */
readonly annotations?: { [key: string]: string };
/** Prefix, used by the server, to generate a unique name ONLY IF the `name` field has not been provided. This value will also be combined with a unique suffix. Read more: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#idempotency */
readonly generateName?: string;
/** Map of string keys and values that can be used to organize and categorize (scope and select) the namespace. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels */
readonly labels?: { [key: string]: string };
}
References
None
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
kubernetes_namespace | Resources | hashicorp/kubernetes
kubernetes_namespace. Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called namespaces.
Read more >Namespaces Walkthrough | Kubernetes
We have created a deployment whose replica size is 2 that is running the pod called snowflake with a basic container that serves...
Read more >Create Namespace Resource - Pulumi
kubernetes.core/v1.Namespace. Namespace provides a scope for Names. Use of multiple namespaces is optional. Create Namespace Resource.
Read more >Manage Kubernetes Resources via Terraform
You can use the Terraform Kubernetes provider to interact with resources supported ... kind create cluster --name terraform-learn --config kind-config.yaml ...
Read more >Why does using data source attributes in Kubernetes terraform ...
The trace logs indicate that the kube_config object has empty value for several fields that are passed to the provider.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
When looking at the schema
And comparing it to the docs it looks like we could just guard it by
optional
beingtrue
.Besides from that, what we certainly don’t support at the moment are attribute references for nested types e.g.
generation
I’m going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you’ve found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.