Interface IKubernetesManifestProps
Properties for KubernetesManifest.
Inherited Members
Namespace: Amazon.CDK.AWS.EKS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface IKubernetesManifestProps : IKubernetesManifestOptions
Syntax (vb)
Public Interface IKubernetesManifestProps
Inherits 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
Properties
Cluster | The EKS cluster to apply this manifest to. |
Manifest | The manifest to apply. |
Overwrite | Overwrite any existing resources. |
Properties
Cluster
The EKS cluster to apply this manifest to.
ICluster Cluster { get; }
Property Value
Remarks
[disable-awslint:ref-via-interface]
Manifest
The manifest to apply.
IDictionary<string, object>[] Manifest { get; }
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.
virtual Nullable<bool> Overwrite { get; }
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