I have 2 angular applications, they are in different pods in the same (default) namespace on a Minikube cluster. I am using module-federation for communication between them.
My yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: host-app
spec:
replicas: 1
selector:
matchLabels:
app: host-app
template:
metadata:
labels:
app: host-app
spec:
containers:
- name: host-app
image: testexampleuser/host-mf-app
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: host-app-srv
spec:
selector:
app: host-app
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: remote-app
spec:
replicas: 1
selector:
matchLabels:
app: remote-app
template:
metadata:
labels:
app: remote-app
spec:
containers:
- name: remote-app
image: testexampleuser/remote-mf-app
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: remote-app-srv
spec:
selector:
app: remote-app
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- host: ms.test
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: host-app-srv
port:
number: 80
- path: /todo-list
pathType: Prefix
backend:
service:
name: host-app-srv
port:
number: 80
and my webpack.config.js for the main app:
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
const mf = require("@angular-architects/module-federation/webpack");
const path = require("path");
const share = mf.share;
const sharedMappings = new mf.SharedMappings();
sharedMappings.register(
path.join(__dirname, 'tsconfig.json'),
[/* mapped paths to share */]);
module.exports = {
output: {
uniqueName: "hostApp",
publicPath: "auto",
scriptType: "text/javascript"
},
optimization: {
runtimeChunk: false
},
resolve: {
alias: {
...sharedMappings.getAliases(),
}
},
experiments: {
outputModule: true
},
plugins: [
new ModuleFederationPlugin({
name: "hostApp",
remotes: {
remoteApp1: 'remoteApp1@http://remote-app-srv/remoteEntry.js'
},
shared: share({
"@angular/core": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/router": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
...sharedMappings.getDescriptors()
})
}),
sharedMappings.getPlugin()
],
};
In this I am specifying my url as http://remote-app-srv/remoteEntry.js, so trying to access it through the service name, but I have GET http://remote-app-srv/remoteEntry.js net::ERR_NAME_NOT_RESOLVED in the console, which is saying that it is not able to find the IP based on the service name. The same thing happens when using the fully qualified name for the service. However when using kubectl exec -it remote-app-64b485f7d8-pph7z -- nslookup remote-app-srv in the command prompt, I get
kubectl exec -it remote-app-64b485f7d8-pph7z -- nslookup remote-app-srv
Server: 10.96.0.10
Address: 10.96.0.10:53
Name: remote-app-srv.default.svc.cluster.local
Address: 10.99.114.182
** server can't find remote-app-srv.cluster.local: NXDOMAIN
** server can't find remote-app-srv.cluster.local: NXDOMAIN
** server can't find remote-app-srv.svc.cluster.local: NXDOMAIN
** server can't find remote-app-srv.svc.cluster.local: NXDOMAIN
command terminated with exit code 1
So it seems, that it is resolving correctly, but when using the service name in the app, it is not able to find the IP for that. What can be the cause of this issue?
Update
When I modify my ingress and include the /remoteEntry.js as a path, which then forwards to my remote-service, and modify my url as: http://ms.test/remoteEntry.js then in the console I have:
remoteEntry.js:1 GET http://ms.test/487.a4d1c1bd4d8ce404.js net::ERR_ABORTED 404 (Not Found)
__webpack_require__.l @ remoteEntry.js:1
__webpack_require__.f.j @ remoteEntry.js:1
(anonymous) @ remoteEntry.js:1
__webpack_require__.e @ remoteEntry.js:1
./TodoListModule @ remoteEntry.js:1
g @ remoteEntry.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
T @ 268.4135e908b4fc6bc1.js:1
g @ 268.4135e908b4fc6bc1.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
e @ polyfills.fe9dcec8806eea43.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
F @ 268.4135e908b4fc6bc1.js:1
q @ 268.4135e908b4fc6bc1.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
T @ 268.4135e908b4fc6bc1.js:1
g @ 268.4135e908b4fc6bc1.js:1
invoke @ polyfills.fe9dcec8806eea43.js:1
onInvoke @ 256.612799c9aae468e4.js:1
invoke @ polyfills.fe9dcec8806eea43.js:1
run @ polyfills.fe9dcec8806eea43.js:1
(anonymous) @ polyfills.fe9dcec8806eea43.js:1
invokeTask @ polyfills.fe9dcec8806eea43.js:1
onInvokeTask @ 256.612799c9aae468e4.js:1
invokeTask @ polyfills.fe9dcec8806eea43.js:1
runTask @ polyfills.fe9dcec8806eea43.js:1
y @ polyfills.fe9dcec8806eea43.js:1
invokeTask @ polyfills.fe9dcec8806eea43.js:1
U @ polyfills.fe9dcec8806eea43.js:1
W @ polyfills.fe9dcec8806eea43.js:1
ue @ polyfills.fe9dcec8806eea43.js:1
load (async)
e @ polyfills.fe9dcec8806eea43.js:1
scheduleTask @ polyfills.fe9dcec8806eea43.js:1
onScheduleTask @ polyfills.fe9dcec8806eea43.js:1
scheduleTask @ polyfills.fe9dcec8806eea43.js:1
scheduleTask @ polyfills.fe9dcec8806eea43.js:1
scheduleEventTask @ polyfills.fe9dcec8806eea43.js:1
(anonymous) @ polyfills.fe9dcec8806eea43.js:1
o.set @ polyfills.fe9dcec8806eea43.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
e @ polyfills.fe9dcec8806eea43.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
T @ 268.4135e908b4fc6bc1.js:1
g @ 268.4135e908b4fc6bc1.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
e @ polyfills.fe9dcec8806eea43.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
A @ 268.4135e908b4fc6bc1.js:1
O @ 268.4135e908b4fc6bc1.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
T @ 268.4135e908b4fc6bc1.js:1
g @ 268.4135e908b4fc6bc1.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
e @ polyfills.fe9dcec8806eea43.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
I @ 268.4135e908b4fc6bc1.js:1
D @ 268.4135e908b4fc6bc1.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
T @ 268.4135e908b4fc6bc1.js:1
g @ 268.4135e908b4fc6bc1.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
e @ polyfills.fe9dcec8806eea43.js:1
(anonymous) @ 268.4135e908b4fc6bc1.js:1
P @ 268.4135e908b4fc6bc1.js:1
Y @ 268.4135e908b4fc6bc1.js:1
loadChildren @ 268.4135e908b4fc6bc1.js:1
loadModuleFactoryOrRoutes @ 384.caca277fba7706c5.js:1
loadChildren @ 384.caca277fba7706c5.js:1
(anonymous) @ 384.caca277fba7706c5.js:1
Z @ 256.612799c9aae468e4.js:1
x @ 256.612799c9aae468e4.js:1
F._next @ 256.612799c9aae468e4.js:1
next @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
_trySubscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
X @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
X @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
e.subscribe.s @ 384.caca277fba7706c5.js:1
F._next @ 256.612799c9aae468e4.js:1
next @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F._next @ 256.612799c9aae468e4.js:1
next @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
_trySubscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 384.caca277fba7706c5.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 384.caca277fba7706c5.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
Z @ 256.612799c9aae468e4.js:1
x @ 256.612799c9aae468e4.js:1
F._next @ 256.612799c9aae468e4.js:1
next @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
_trySubscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
X @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 384.caca277fba7706c5.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 384.caca277fba7706c5.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 384.caca277fba7706c5.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 384.caca277fba7706c5.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
Z @ 256.612799c9aae468e4.js:1
x @ 256.612799c9aae468e4.js:1
F._next @ 256.612799c9aae468e4.js:1
next @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
_trySubscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
X @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 384.caca277fba7706c5.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 384.caca277fba7706c5.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 384.caca277fba7706c5.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 384.caca277fba7706c5.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
F @ 256.612799c9aae468e4.js:1
subscribe @ 256.612799c9aae468e4.js:1
e.subscribe.s @ 384.caca277fba7706c5.js:1
F._next @ 256.612799c9aae468e4.js:1
next @ 256.612799c9aae468e4.js:1
subscribe.i @ 384.caca277fba7706c5.js:1
F._next @ 256.612799c9aae468e4.js:1
next @ 256.612799c9aae468e4.js:1
(anonymous) @ 256.612799c9aae468e4.js:1
invoke @ polyfills.fe9dcec8806eea43.js:1
onInvoke @ 256.612799c9aae468e4.js:1
invoke @ polyfills.fe9dcec8806eea43.js:1
run @ polyfills.fe9dcec8806eea43.js:1
(anonymous) @ polyfills.fe9dcec8806eea43.js:1
invokeTask @ polyfills.fe9dcec8806eea43.js:1
onInvokeTask @ 256.612799c9aae468e4.js:1
invokeTask @ polyfills.fe9dcec8806eea43.js:1
runTask @ polyfills.fe9dcec8806eea43.js:1
y @ polyfills.fe9dcec8806eea43.js:1
invokeTask @ polyfills.fe9dcec8806eea43.js:1
U @ polyfills.fe9dcec8806eea43.js:1
W @ polyfills.fe9dcec8806eea43.js:1
ue @ polyfills.fe9dcec8806eea43.js:1
268.4135e908b4fc6bc1.js:1 ChunkLoadError: Loading chunk 487 failed.
(error: http://ms.test/487.a4d1c1bd4d8ce404.js)
at __webpack_require__.f.j (remoteEntry.js:1:7277)
at remoteEntry.js:1:1216
at Array.reduce (<anonymous>)
at __webpack_require__.e (remoteEntry.js:1:1177)
at ./TodoListModule (remoteEntry.js:1:83)
at Object.g (remoteEntry.js:1:143)
at 268.4135e908b4fc6bc1.js:1:528
at Generator.next (<anonymous>)
at T (268.4135e908b4fc6bc1.js:1:163)
at g (268.4135e908b4fc6bc1.js:1:365)
256.612799c9aae468e4.js:1 ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'ɵmod')
TypeError: Cannot read properties of undefined (reading 'ɵmod')
at Xe (256.612799c9aae468e4.js:1:31475)
at new Xa (256.612799c9aae468e4.js:1:136284)
at Xo.create (256.612799c9aae468e4.js:1:136822)
at 384.caca277fba7706c5.js:1:79337
at 256.612799c9aae468e4.js:1:10630
at F._next (256.612799c9aae468e4.js:1:10079)
at F.next (256.612799c9aae468e4.js:1:3860)
at Z.subscribe._ (256.612799c9aae468e4.js:1:11217)
at F._next (256.612799c9aae468e4.js:1:10079)
at F.next (256.612799c9aae468e4.js:1:3860)
at ye (polyfills.fe9dcec8806eea43.js:1:16009)
at ye (polyfills.fe9dcec8806eea43.js:1:15548)
at polyfills.fe9dcec8806eea43.js:1:16854
at N.invokeTask (polyfills.fe9dcec8806eea43.js:1:7153)
at Object.onInvokeTask (256.612799c9aae468e4.js:1:170779)
at N.invokeTask (polyfills.fe9dcec8806eea43.js:1:7074)
at z.runTask (polyfills.fe9dcec8806eea43.js:1:2495)
at y (polyfills.fe9dcec8806eea43.js:1:9194)
at P.invokeTask [as invoke] (polyfills.fe9dcec8806eea43.js:1:8237)
at U (polyfills.fe9dcec8806eea43.js:1:20912)
Which I find strange, because when I enter inside the pod, I can clearly see, that the file is available, moreover, I am even able to reach the content of http://ms.test/remoteEntry.js in the browser, it just not works when using in the app.
When you're using
Ingress, you should not use service for accessing your app. First you need to resolv thems.testto your minikube ip, then try the paths you set in your Ingress yaml file. For example you should try this :when you hit the
/path it will call thehost-app-srv. Hope it helps!