You are managing a Kubernetes cluster where a Deployment named ui-app
already exists in the namespace dev-lab
. The container image used is nginx
.
Your task is to:
-
Update the Deployment
ui-app
in thedev-lab
namespace to ensure thenginx
container exposes port 80/tcp explicitly. -
Create a Service named
ui-service
in the same namespace to expose the pod(s) of the Deployment on port 80/tcp. -
Ensure that the Service is of type NodePort, so the application is accessible externally via any node IP and a static port.
Note:
-
Do not recreate the Deployment—only modify it.
-
Use standard port range if assigning
nodePort
manually (30000–32767)
# Create namespace
kubectl create ns dev-lab
# Create Deployment named ui-app with nginx image (no port exposed yet)
cat <<EOF > ui-app-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: ui-app
namespace: dev-lab
spec:
replicas: 1
selector:
matchLabels:
app: ui-app
template:
metadata:
labels:
app: ui-app
spec:
containers:
- name: nginx
image: nginx
EOF
# Apply the Deployment
kubectl apply -f ui-app-deploy.yaml
Comments
Post a Comment