Usage of ApiObjectMetadataDefinition in object definition generated unexpected key output on synth
#!/usr/bin/env python
from constructs import Construct
from cdk8s import App, Chart, ApiObjectMetadataDefinition
from imports import k8s
from imports.io import argoproj
from imports import k8s
class MyChart(Chart):
def __init__(self, scope: Construct, id: str):
super().__init__(scope, id)
argo_namespace="aa"
labels={
"app": "argocd"
}
k8s_server="https://kubernetes.default.svc"
namespace="default"
name="app"
repo_url="http://xxx.gihub.com"
path="."
target_revision="master"
k8s.KubePod(self, "pod",
metadata=ApiObjectMetadataDefinition(
name=name,
namespace=namespace,
),
spec=k8s.PodSpec(
containers=[
k8s.Container(
name="test",
image="nginx:latest"
)
]
)
)
# define resources here
argoproj.Application(
self,
"argocdapp",
metadata=ApiObjectMetadataDefinition(
name=name,
namespace=namespace,
),
spec=argoproj.ApplicationSpec(
destination=argoproj.ApplicationSpecDestination(
namespace=namespace, server=k8s_server
),
sync_policy=argoproj.ApplicationSpecSyncPolicy(
automated=argoproj.ApplicationSpecSyncPolicyAutomated(
self_heal=True,
)
),
project=name,
source=argoproj.ApplicationSpecSource(
repo_url=repo_url,
path=path,
target_revision=target_revision,
)
),
)
app = App()
MyChart(app, "cdk8s-import-crd-python")
app.synth()
apiVersion: v1
kind: Pod
metadata:
name: app
namespace: default
spec:
containers:
- image: nginx:latest
name: test
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
_additionalAttributes:
name: app
namespace: default
name: app
namespace: default
spec:
destination:
namespace: default
server: https://kubernetes.default.svc
project: app
source:
path: "."
repoURL: http://xxx.gihub.com
targetRevision: master
syncPolicy:
automated:
selfHeal: true
_additionalAttributes:
name: app
namespace: default
metadata={"name": name,"namespace": namespace},