I deployed my own angular project on docker hub (one time the whole project and one time the dist folder after building the application), Both times logs showed successful deployment in the container.
Here is my config File for pod and service
apiVersion: apps/v1
kind: Deployment
metadata:
name: audit-logger-frontend
labels:
app: logger-frontend
spec:
replicas: 1
selector:
matchLabels:
app: logger-frontend
template:
metadata:
labels:
app: logger-frontend
spec:
containers:
- name: logger-frontend
image: huzaifi0604/logger-frontend:1.0
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: audit-logger-service
spec:
selector:
app: logger-frontend
type: NodePort
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 31000
and this is the DockerFile for the project i deployed on Dockerhub
Docker File for Deploying angular Application
# Use the official Node.js image
FROM node:18
# Updating the environment for the application
RUN apt-get update
# Set the working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies with legacy peer deps
RUN npm install --legacy-peer-deps
# Copy the rest of the application source code
COPY . .
# Expose the port the app runs on
EXPOSE 4200
# Start the application
CMD ["npm", "start"]
I tried using NodePort and LoadBalacer both with and without nodePort key. Exposed port 4200 in docker file and set as target and containerPort in config files, got correct endpoints on service descriptions even got the service URL for accessing in browser, but in my browser the application is just not accessible.
- These were my Logs for the pod created:
D:K8isAudit_Logger_Deployment>kubectl logs audit-logger-frontend-8595d84b97-tlkl8
> [email protected] start
> ng serve
- Building...
Initial chunk files | Names | Raw size
main.js | main | 94.68 kB |
polyfills.js | polyfills | 86.03 kB |
styles.css | styles | 70.77 kB |
| Initial total | 251.48 kB
Application bundle generation complete. [2.580 seconds]
Watch mode enabled. Watching for file changes...
Re-optimizing dependencies because vite config has changed
➜ Local: http://localhost:4200/
- and this was the service description
:K8isAudit_Logger_Deployment>kubectl describe service audit-logger-service
Name: audit-logger-service
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=logger-frontend
Type: LoadBalancer
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.104.15.127
IPs: 10.104.15.127
Port: <unset> 8000/TCP
TargetPort: 4200/TCP
NodePort: <unset> 30000/TCP
Endpoints: 10.244.0.5:4200
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
- Here are the Service URLs:
minikube service audit-logger-service
|-----------|----------------------|-------------|---------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|----------------------|-------------|---------------------------|
| default | audit-logger-service | 8000 | http://192.168.49.2:30000 |
|-----------|----------------------|-------------|---------------------------|
* Starting tunnel for service audit-logger-service.
|-----------|----------------------|-------------|-----------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-----------|----------------------|-------------|-----------------------|
| default | audit-logger-service | | http://127.0.0.1:7261 |
|-----------|----------------------|-------------|-----------------------|
* Opening service default/audit-logger-service in default browser...
! Because you are using a Docker driver on windows, the terminal needs to be open to run it.
Have any idea, what I might be doing incorrectly or might there be a network setting issue i m not aware of?
Muhammad Huzaifa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.