https://pulumi.com logo
Title
c

cool-lawyer-24254

01/05/2023, 7:42 AM
import * as awsx from "@pulumi/awsx/classic"; import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; import * as aws from "@pulumi/aws"; const cluster = new eks.Cluster("cluster", { }); // Deploy a serice const appName = "my-app"; const appLabels = { appClass: appName }; const deployment = new k8s.apps.v1.Deployment(
${appName}-dep
, { metadata: { labels: appLabels }, spec: { replicas: 2, selector: { matchLabels: appLabels }, template: { metadata: { labels: appLabels }, spec: { containers: [{ name: appName, image: awsx.ecr.buildAndPushImage("my-custom-nginx-service", "./app").image(), ports: [{ name: "http", containerPort: 80 }], }], } } }, }, { provider: cluster.provider }); const service = new k8s.core.v1.Service(
${appName}-svc
, { metadata: { labels: appLabels }, spec: { type: "LoadBalancer", ports: [{ port: 80, targetPort: 80 }], selector: appLabels, }, }, { provider: cluster.provider }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Publish the URL for the load balanced service. export const appURL = service.status.loadBalancer.ingress[0].hostname;