Class KubernetesManifestProps
Properties for KubernetesManifest.
Inheritance
Namespace: Amazon.CDK.AWS.EKS
Assembly: Amazon.CDK.AWS.EKS.dll
Syntax (csharp)
public class KubernetesManifestProps : Object, IKubernetesManifestProps, IKubernetesManifestOptions
Syntax (vb)
Public Class KubernetesManifestProps
Inherits Object
Implements IKubernetesManifestProps, IKubernetesManifestOptions
Remarks
ExampleMetadata: infused
Examples
Cluster cluster;
IDictionary<string, string> appLabel = new Dictionary<string, string> { { "app", "hello-kubernetes" } };
IDictionary<string, object> deployment = new Dictionary<string, object> {
{ "apiVersion", "apps/v1" },
{ "kind", "Deployment" },
{ "metadata", new Dictionary<string, string> { { "name", "hello-kubernetes" } } },
{ "spec", new Dictionary<string, object> {
{ "replicas", 3 },
{ "selector", new Dictionary<string, IDictionary<string, string>> { { "matchLabels", appLabel } } },
{ "template", new Dictionary<string, IDictionary<string, IDictionary<string, string>>> {
{ "metadata", new Dictionary<string, IDictionary<string, string>> { { "labels", appLabel } } },
{ "spec", new Dictionary<string, IDictionary<string, object>[]> {
{ "containers", new [] { new Dictionary<string, object> {
{ "name", "hello-kubernetes" },
{ "image", "paulbouwer/hello-kubernetes:1.5" },
{ "ports", new [] { new Dictionary<string, int> { { "containerPort", 8080 } } } }
} } }
} }
} }
} }
};
IDictionary<string, object> service = new Dictionary<string, object> {
{ "apiVersion", "v1" },
{ "kind", "Service" },
{ "metadata", new Dictionary<string, string> { { "name", "hello-kubernetes" } } },
{ "spec", new Dictionary<string, object> {
{ "type", "LoadBalancer" },
{ "ports", new [] { new Dictionary<string, int> { { "port", 80 }, { "targetPort", 8080 } } } },
{ "selector", appLabel }
} }
};
// option 1: use a construct
// option 1: use a construct
new KubernetesManifest(this, "hello-kub", new KubernetesManifestProps {
Cluster = cluster,
Manifest = new [] { deployment, service }
});
// or, option2: use `addManifest`
cluster.AddManifest("hello-kub", service, deployment);
Synopsis
Constructors
KubernetesManifestProps() |
Properties
Cluster | The EKS cluster to apply this manifest to. |
IngressAlb | Automatically detect |
IngressAlbScheme | Specify the ALB scheme that should be applied to |
Manifest | The manifest to apply. |
Overwrite | Overwrite any existing resources. |
Prune | When a resource is removed from a Kubernetes manifest, it no longer appears in the manifest, and there is no way to know that this resource needs to be deleted. |
SkipValidation | A flag to signify if the manifest validation should be skipped. |
Constructors
KubernetesManifestProps()
public KubernetesManifestProps()
Properties
Cluster
The EKS cluster to apply this manifest to.
public ICluster Cluster { get; set; }
Property Value
Remarks
[disable-awslint:ref-via-interface]
IngressAlb
Automatically detect Ingress
resources in the manifest and annotate them so they are picked up by an ALB Ingress Controller.
public Nullable<bool> IngressAlb { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false
IngressAlbScheme
Specify the ALB scheme that should be applied to Ingress
resources.
public Nullable<AlbScheme> IngressAlbScheme { get; set; }
Property Value
System.Nullable<AlbScheme>
Remarks
Only applicable if ingressAlb
is set to true
.
Default: AlbScheme.INTERNAL
Manifest
The manifest to apply.
public IDictionary<string, object>[] Manifest { get; set; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.Object>[]
Remarks
Consists of any number of child resources.
When the resources are created/updated, this manifest will be applied to the
cluster through kubectl apply
and when the resources or the stack is
deleted, the resources in the manifest will be deleted through kubectl delete
.
Examples
new [] { new Struct {
ApiVersion = "v1",
Kind = "Pod",
Metadata = new Struct { Name = "mypod" },
Spec = new Struct {
Containers = new [] { new Struct { Name = "hello", Image = "paulbouwer/hello-kubernetes:1.5", Ports = new [] { new Struct { ContainerPort = 8080 } } } }
}
} };
Overwrite
Overwrite any existing resources.
public Nullable<bool> Overwrite { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
If this is set, we will use kubectl apply
instead of kubectl create
when the resource is created. Otherwise, if there is already a resource
in the cluster with the same name, the operation will fail.
Default: false
Prune
When a resource is removed from a Kubernetes manifest, it no longer appears in the manifest, and there is no way to know that this resource needs to be deleted.
public Nullable<bool> Prune { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
To address this, kubectl apply
has a --prune
option which will
query the cluster for all resources with a specific label and will remove
all the labeld resources that are not part of the applied manifest. If this
option is disabled and a resource is removed, it will become "orphaned" and
will not be deleted from the cluster.
When this option is enabled (default), the construct will inject a label to
all Kubernetes resources included in this manifest which will be used to
prune resources when the manifest changes via kubectl apply --prune
.
The label name will be aws.cdk.eks/prune-<ADDR>
where <ADDR>
is the
42-char unique address of this construct in the construct tree. Value is
empty.
Default: - based on the prune option of the cluster, which is true
unless
otherwise specified.
SkipValidation
A flag to signify if the manifest validation should be skipped.
public Nullable<bool> SkipValidation { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false