| Container Management with Pulumi |
containers |
/containers |
Pulumi provides a cloud native programming model for container management. Any code, any cloud, any app. |
| title |
body |
code |
| Manage Clusters and Deploy Containers with Ease |
Pulumi supports managing clusters and their associated infrastructure, whether it is Kubernetes, Amazon ECS, Azure ACI, or Google GKE. Build and deploy application containers to private registies, all in one programming model.
Any code, any cloud, any language.
|
// Deploy Nginx to AWS Fargate
import * as awsx from "@pulumi/awsx";
let web = new awsx.elb.ApplicationLoadBalancer(
"net-lb", { external: true }).
createListener("web", { port: 80, external: true });
let appService = new awsx.ecs.FargateService("nginx-svc", {
taskDefinitionArgs: {
container: {
image: "nginx",
portMappings: [ web ],
},
},
desiredCount: 5,
});
export let url = web.endpoint.hostname;
|
|
| id |
label |
| what-is-container-management |
What is Container Management? |
|
| id |
label |
| deploying-containers |
Deploying Containers |
|
|
|
| id |
label |
| get-started |
Get Started |
|
| id |
label |
| contact |
Talk to a human |
|
|
| title |
body |
code |
cta |
| Deploy Nginx to AWS Fargate |
In this example, Pulumi defines and uses a new Amazon ECS Fargate cluster, and creates a load balanced service running the standard Nginx image from the Docker Hub. The same experience is available on other clouds and Pulumi can pull from any container registry.
|
// Deploy Nginx to AWS Fargate
import * as awsx from "@pulumi/awsx";
let web = new awsx.elb.ApplicationLoadBalancer(
"net-lb", { external: true }).
createListener("web", { port: 80, external: true });
let appService = new awsx.ecs.FargateService("nginx-svc", {
taskDefinitionArgs: {
container: {
image: "nginx",
portMappings: [ web ],
},
},
desiredCount: 5,
});
export let url = web.endpoint.hostname;
|
| url |
label |
| /docs/quickstart |
GET STARTED |
|
|
| title |
body |
code |
cta |
| Deploying with a custom build |
This example uses a trivial Dockerfile that derives from the <code>nginx</code> base image and copies the <code>./www</code> directory into the nginx HTML target so that it will be served up.
|
// Using a custom build based on Nginx
import * as awsx from "@pulumi/awsx";
let web = new awsx.elb.ApplicationLoadBalancer(
"net-lb", { external: true }).
createListener("web", { port: 80, external: true });
const appService = new awsx.ecs.FargateService("nginx-svc", {
taskDefinitionArgs: {
container: {
image: awsx.ecs.Image.fromPath("app-img", "./www");
portMappings: [ web ],
},
},
desiredCount: 5,
});
export const url = web.endpoint.hostname;
// Dockerfile
FROM nginx
COPY ./www /usr/share/nginx/html
|
| url |
label |
| /docs/quickstart |
GET STARTED |
|
|
| title |
body |
code |
cta |
| Creating a Kubernetes cluster |
Pulumi can provision Kubernetes clusters — in this example, an AWS EKS cluster — in addition to deploying application-level configuration, using a standard set of languages, abstractions, and tools.
|
import * as awsx from "@pulumi/awsx";
import * as eks from "@pulumi/eks";
// Create a VPC for our cluster.
const vpc = new awsx.ec2.Vpc("vpc", {});
// Create the EKS cluster itself.
const cluster = new eks.Cluster("cluster", {
vpcId: vpc.id,
subnetIds: vpc.publicSubnetIds,
instanceType: "t2.medium",
desiredCapacity: 4,
minSize: 3,
maxSize: 5,
storageClasses: "gp2",
deployDashboard: true,
});
// Export the cluster's kubeconfig.
export const kubeconfig = cluster.kubeconfig;
|
| url |
label |
| /docs/quickstart |
GET STARTED |
|
|
| title |
body |
code |
cta |
| Deploy containers to Microsoft ACI |
The <code>@pulumi/azure-native</code> library provides fine-grained control of Azure resources. In this example, we deploy a simple linux container to Microsoft ACI, in the West US zone.
|
import * as containerinstance from "@pulumi/azure-native/containerinstance";
import * as resources from "@pulumi/azure-native/resources";
const resourceGroup = new resources.ResourceGroup("resourcegroup", {
location: "West US",
});
const imageName = "mcr.microsoft.com/azuredocs/aci-helloworld";
const containerGroup = new containerinstance.ContainerGroup("containerGroup", {
resourceGroupName: resourceGroup.name,
osType: "Linux",
containers: [{
name: "acilinuxpublicipcontainergroup",
image: imageName,
resources: {
requests: {
cpu: 1.0,
memoryInGB: 1.5,
},
},
ports: [{ port: 80 }],
}],
ipAddresses: [{
ports: [{
port: 80,
protocol: "Tcp",
}],
type: "Public",
}],
restartPolicy: "always",
});
|
| url |
label |
| /docs/quickstart |
GET STARTED |
|
|
| title |
body |
code |
cta |
| Invoke a long-running container as a task |
This example shows a container used for executing a long-running task. Here, we use a container to perform a thumbnail extraction on a piece of video uploaded to an S3 bucket.
|
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
// A bucket to store videos and thumbnails.
const videos = new aws.s3.Bucket("bucket");
// A task which runs a containerized FFMPEG job to extract a thumbnail image.
const ffmpegThumbnailTask = new awsx.ecs.FargateTaskDefinition("ffmpegThumbTask", {
container: {
image: awsx.ecs.Image.fromPath("ffmpegThumbTask", "./docker-ffmpeg-thumb"),
memoryReservation: 512,
},
});
// When a new video is uploaded, run the FFMPEG task on the video file.
videos.onObjectCreated("onNewVideo",
new aws.lambda.CallbackFunction<aws.s3.BucketEvent, void>("onNewVideo", {
// Specify appropriate policies so that this AWS lambda can run EC2 tasks.
policies: [
aws.iam.ManagedPolicy.AWSLambdaExecute,
aws.iam.ManagedPolicy.AmazonECSFullAccess,
],
callback: async bucketArgs => {
for (const record of bucketArgs.Records) {
const file = record.s3.object.key;
const thumbnailFile = file.substring(0, file.indexOf('_')) + '.jpg';
const framePos = file.substring(file.indexOf('_')+1, file.indexOf('.')).replace('-',':');
await ffmpegThumbnailTask.run({
overrides: {
containerOverrides: [{
name: "container",
environment: [
{ name: "S3_BUCKET", value: bucketName.get() },
{ name: "INPUT_VIDEO", value: file },
{ name: "TIME_OFFSET", value: framePos },
{ name: "OUTPUT_FILE", value: thumbnailFile },
],
}],
},
});
}
},
}), { filterSuffix: ".mp4" });
exports.bucketName = videos.bucket;
|
| url |
label |
| /docs/quickstart |
GET STARTED |
|
|
|
| section_id |
hubspot_form_id |
headline |
quote |
| contact |
abf0bd4b-5e71-44a9-aad1-b55b5cce561d |
Need help with container management? |
| title |
name |
name_title |
content |
| Learn how top engineering teams are using Pulumi to manage containers in any cloud. |
Josh Imhoff |
Site Reliability Engineer, Cockroach Labs |
We are building a distributed-database-as-a-service product that runs on Kubernetes clusters across multiple
public clouds including Google Cloud, AWS and others. Pulumi's declarative model, the support for familiar programming
languages, and the uniform workflow on any cloud make our SRE team much more efficient.
|
|
|