
What does exposing a container mean?
Containers deployed on Kubernetes run inside the Kubernetes cluster by default.
So if you want to reach them from the outside, you have to create a Service.
On Kubernetes, creating a Service is also described as exposing, and it is like mapping an outside port to a port on the inner container.

# Exposing — YAML
To expose something on Kubernetes you can deploy a Service or expose it directly from the CLI.
When you deploy a Service, you can write a YAML file and apply it.
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app.kubernetes.io/name: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376The YAML above means port 80 is exposed externally and is mapped to port 9376 on the container.
You can also set type, external-IP, and so on when you deploy it.
Exposing with expose
kubectl expose -n <namespace> <kind> <pod> -name [서비스네임] --port --target-portYou can also expose it from the CLI as shown above.
Comments 0
A nickname and a password are required. The same password edits or deletes the comment later. Comments appear after a review.