cool-lawyer-24254
01/05/2023, 7:42 AMimport * 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;
FROM nginx:latest
quaint-eye-38036
01/05/2023, 9:12 AMcool-lawyer-24254
01/05/2023, 9:14 AMRunning
quaint-eye-38036
01/05/2023, 9:14 AMcool-lawyer-24254
01/05/2023, 9:14 AMquaint-eye-38036
01/05/2023, 9:14 AMcool-lawyer-24254
01/05/2023, 9:15 AMquaint-eye-38036
01/05/2023, 9:15 AMcool-lawyer-24254
01/05/2023, 9:16 AMimage: awsx.ecr.buildAndPushImage("my-custom-nginx-service", "./app").image()
by image: "nginx"
it works then.service.status.loadBalancer.ingress[0].hostname
quaint-eye-38036
01/05/2023, 9:19 AMcool-lawyer-24254
01/05/2023, 9:21 AMquaint-eye-38036
01/05/2023, 9:22 AMcool-lawyer-24254
01/05/2023, 9:23 AM1.23
version1.24
version tooquaint-eye-38036
01/05/2023, 9:24 AMcool-lawyer-24254
01/05/2023, 9:25 AMquaint-eye-38036
01/05/2023, 9:27 AMcool-lawyer-24254
01/05/2023, 9:29 AMquaint-eye-38036
01/05/2023, 9:30 AMcool-lawyer-24254
01/05/2023, 9:33 AMFROM node:16
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
# RUN npm install
RUN npm ci --only=production
# Bundle app source
COPY . .
EXPOSE 80
CMD [ "node", "server.js" ]
quaint-eye-38036
01/05/2023, 9:36 AMcool-lawyer-24254
01/05/2023, 9:36 AMquaint-eye-38036
01/05/2023, 9:38 AMcool-lawyer-24254
01/05/2023, 9:38 AMconst express = require('express');
const PORT = 80;
// App
const app = express();
app.get('/', (req, res) => {
res.send('Hello!');
});
app.listen(PORT, () => {
console.log(`Running on ${PORT}`);
});
quaint-eye-38036
01/05/2023, 9:40 AMcool-lawyer-24254
01/05/2023, 9:44 AMFROM --platform=linux/amd64
flag into the Dockerfile solved the issue.