KubernetesResourceProps

class aws_cdk.aws_eks_legacy.KubernetesResourceProps(*, cluster, manifest)

Bases: object

Parameters:
  • cluster (Cluster) – (deprecated) The EKS cluster to apply this configuration to. [disable-awslint:ref-via-interface]

  • manifest (Sequence[Any]) – (deprecated) The resource manifest. Consists of any number of child resources. When the resource is created/updated, this manifest will be applied to the cluster through kubectl apply and when the resource or the stack is deleted, the manifest will be deleted through kubectl delete:: const manifest = { apiVersion: ‘v1’, kind: ‘Pod’, metadata: { name: ‘mypod’ }, spec: { containers: [ { name: ‘hello’, image: ‘paulbouwer/hello-kubernetes:1.5’, ports: [ { containerPort: 8080 } ] } ] } }

Stability:

deprecated

ExampleMetadata:

infused

Example:

# cluster: eks.Cluster
app_label = {"app": "hello-kubernetes"}

deployment = {
    "api_version": "apps/v1",
    "kind": "Deployment",
    "metadata": {"name": "hello-kubernetes"},
    "spec": {
        "replicas": 3,
        "selector": {"match_labels": app_label},
        "template": {
            "metadata": {"labels": app_label},
            "spec": {
                "containers": [{
                    "name": "hello-kubernetes",
                    "image": "paulbouwer/hello-kubernetes:1.5",
                    "ports": [{"container_port": 8080}]
                }
                ]
            }
        }
    }
}

service = {
    "api_version": "v1",
    "kind": "Service",
    "metadata": {"name": "hello-kubernetes"},
    "spec": {
        "type": "LoadBalancer",
        "ports": [{"port": 80, "target_port": 8080}],
        "selector": app_label
    }
}
# option 1: use a construct
eks.KubernetesResource(self, "hello-kub",
    cluster=cluster,
    manifest=[deployment, service]
)

# or, option2: use `addResource`
cluster.add_resource("hello-kub", service, deployment)

Attributes

cluster

(deprecated) The EKS cluster to apply this configuration to.

[disable-awslint:ref-via-interface]

Stability:

deprecated

manifest

(deprecated) The resource manifest.

Consists of any number of child resources.

When the resource is created/updated, this manifest will be applied to the cluster through kubectl apply and when the resource or the stack is deleted, the manifest will be deleted through kubectl delete:

const manifest = {
   apiVersion: 'v1',
   kind: 'Pod',
   metadata: { name: 'mypod' },
   spec: {
     containers: [ { name: 'hello', image: 'paulbouwer/hello-kubernetes:1.5', ports: [ { containerPort: 8080 } ] } ]
   }
}
Stability:

deprecated