This message was deleted.
# aws
s
This message was deleted.
c
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;
Docker file
FROM nginx:latest
EKS can pull containers from ECR, but there is an exception
q
From the last messages, it appears that the nodes aren't ready yet. What's the state of the pod?
c
Status is
Running
q
So, no issues?
c
Yeah
q
Cool!
c
and the endpoint is unreachable.
q
Which endpoints?
c
interesting point is that if I replace
image: awsx.ecr.buildAndPushImage("my-custom-nginx-service", "./app").image()
by
image: "nginx"
it works then.
endpoints? that one
service.status.loadBalancer.ingress[0].hostname
q
How was it checked? Ping, curl or some other way?
c
Yeah, as you see it's nginx service, if you just use web browser and check the url it should show default index.html page of the nginx
q
Which version of EKS?
c
the cluster is deployed under
1.23
version
I tried to update to
1.24
version too
q
Hmm..ok. But I think you mentioned that if the custom image in the deployment is replaced with upstream nginx image, it works, rit?
c
Yes.
q
To rule out that it's an issue with Pulumi, have you tried deploying it using the native yaml?
c
Do you mean not to use typescript and try yaml file?
q
To rule of issues with the custom image
If the endpoints are reachable with the custom image deployed the native way then we are sure there's nothing wrong with the image and focus on pulumi
c
Yeah, I'm sure container is ok itself here is another example which I deployed and checked locally, then I pushed it to DockerHub, but the result is the same, containers not starting
Copy code
FROM 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" ]
q
Is this the Dockerfile of the custome image?
c
Yes
server.js is just simple express app
q
After you deployed it locally, how did you access and test that it's accepting HTTP request?
c
Copy code
const 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}`);
});
Just checked by Postman
q
By deployed locally, what was it? Minikube, kind or something else?
c
To ensure that the container works properly I just made a custom image and checked run th e container locally, then I pushed it to DockerHubs private repo, then I used the container in Pulumi code, to exclude that in the first example where I try to pull it from ECR there are no issues related to EKS ECR connectivity.
The issue has been resolved. It was found that the issue was caused by building dockers locally on a Mac M1 chip. Adding the
FROM --platform=linux/amd64
flag into the Dockerfile solved the issue.