important-football-6131
02/26/2023, 8:14 PMbillowy-army-68599
02/26/2023, 9:43 PMimportant-football-6131
02/26/2023, 9:44 PMbillowy-army-68599
02/26/2023, 10:03 PMimportant-football-6131
02/26/2023, 10:10 PMconst deployment = new k8s.apps.v1.Deployment(
appName,
{
metadata: { name: appName },
spec: {
selector: {
matchLabels: { app: appName }
},
replicas: 1,
template: {
metadata: {
labels: { app: appName }
},
spec: {
containers: [
{
resources: {
limits: {
memory: '128Mi',
cpu: '100m'
},
requests: {
memory: '64Mi',
cpu: '100m'
}
},
name: appName,
image: appImage.imageUri,
ports: [{ containerPort: 8080 }],
env: []
}
]
}
}
}
},
{ provider: eksCluster.provider }
)
const service = new k8s.core.v1.Service(
`${appName}-svc`,
{
metadata: {
name: appName,
labels: deployment.metadata.labels
},
spec: {
type: 'ClusterIP',
ports: [{ port: 80, targetPort: 8080 }],
selector: { app: appName }
}
},
{
provider: eksCluster.provider
}
)
const appIngress = new k8s.networking.v1.Ingress('opl-ingress', {
metadata: {
name: 'opl-k8s-ingress',
annotations: {
'<http://nginx.ingress.kubernetes.io/rewrite-target|nginx.ingress.kubernetes.io/rewrite-target>': '/',
'<http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>': 'nginx',
}
},
spec: {
rules: [
{
host: publicUrl,
{
backend: {
service: {
name: ClientAppName,
port: {
number: 80
}
}
},
path: '/',
pathType: 'Prefix'
}
]
}
}
]
}
})
billowy-army-68599
02/26/2023, 10:35 PMbut if i copy the load balancer addressThat’s because the load balancer address doesn’t know where to your because you’re missing the host header. If you do:
curl --header "Host: <ingress address>" <loadbalancer address>
It’ll likely workimportant-football-6131
02/26/2023, 10:40 PMbillowy-army-68599
02/26/2023, 10:46 PMbut if i use the load balancer address it should redirect me to the serviceWell, if you’ve pointed DNS to the service it should yeah. You need a DNS CNAME for your ingress address to direct you to the service
important-football-6131
02/26/2023, 10:46 PMbillowy-army-68599
02/27/2023, 4:26 PMimportant-football-6131
02/27/2023, 7:17 PMbillowy-army-68599
02/27/2023, 7:17 PMimportant-football-6131
02/27/2023, 7:17 PMbillowy-army-68599
02/27/2023, 7:18 PMkubectl get svc --all-namespaces
what do you get back?important-football-6131
02/27/2023, 7:18 PMdefault kubernetes ClusterIP 172.20.0.1 <none> 443/TCP 46h
default myctrl-helm-94b738ff-ingress-nginx-controller LoadBalancer 172.20.28.30 <http://a60da7f31b9864e568bf8d320040c55e-1877713466.eu-west-2.elb.amazonaws.com|a60da7f31b9864e568bf8d320040c55e-1877713466.eu-west-2.elb.amazonaws.com> 80:30575/TCP,443:31871/TCP 26h
default myctrl-helm-94b738ff-ingress-nginx-controller-admission ClusterIP 172.20.1.216 <none> 443/TCP 26h
billowy-army-68599
02/27/2023, 7:25 PMimportant-football-6131
02/27/2023, 7:26 PMconst ctrl = new nginx.IngressController('myctrl', {
controller: {
publishService: {
enabled: true
}
}
})
// Next, expose the app using an Ingress.
const appIngress = new k8s.networking.v1.Ingress('opl-ingress', {
metadata: {
name: 'opl-k8s-ingress',
annotations: {
'<http://nginx.ingress.kubernetes.io/rewrite-target|nginx.ingress.kubernetes.io/rewrite-target>': '/',
'<http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>': 'nginx'
}
},
spec: {
rules: [
{
host: publicUrl,
http: {
paths: [
{
backend: {
service: {
name: ClientAppName,
port: {
number: 80
}
}
},
path: '/',
pathType: 'Prefix'
}
]
}
}
]
}
billowy-army-68599
02/27/2023, 7:28 PMkubectl get ing
on the namespace it’s installed intoimportant-football-6131
02/27/2023, 7:31 PMopl-k8s-ingress <none> <http://ourplacelettings.aengz.com|ourplacelettings.aengz.com> <http://a60da7f31b9864e568bf8d320040c55e-1877713466.eu-west-2.elb.amazonaws.com|a60da7f31b9864e568bf8d320040c55e-1877713466.eu-west-2.elb.amazonaws.com> 80 46h
billowy-army-68599
02/27/2023, 7:32 PMimportant-football-6131
02/27/2023, 7:32 PMbillowy-army-68599
02/27/2023, 7:32 PMimportant-football-6131
02/27/2023, 7:33 PMbillowy-army-68599
02/27/2023, 7:33 PMcurl -vvv <http://ourplacelettings.aengz.com|ourplacelettings.aengz.com>
important-football-6131
02/27/2023, 7:34 PMbillowy-army-68599
02/27/2023, 7:34 PMimportant-football-6131
02/27/2023, 7:35 PMbillowy-army-68599
02/27/2023, 7:36 PMimportant-football-6131
02/27/2023, 7:37 PMbillowy-army-68599
02/27/2023, 7:38 PMimportant-football-6131
02/27/2023, 7:39 PM