Create a Service
Expose and access applications running in Pods using a Kubernetes Service
Overview
In Kubernetes, a Service is a resource for exposing and accessing applications. It provides a stable network endpoint so that clients inside or outside the cluster can reach the application running in Pods. A Service uses a selector to route requests to backing Pods, and provides load balancing and service discovery.
Inside VKS, a Service is only reachable from within the cluster. To expose it on the public network, publish the service.
Deploy a Service
Deploying a Service in Kubernetes typically involves two steps:
- Create a Deployment to manage the application's Pods
- Create a Service to expose those Pods
Example
# vcluster service exposure
apiVersion: v1
kind: Service
metadata:
name: your-service-name
namespace: your-namespace
spec:
selector:
app: your-app-name # the app label of your Pod
type: ClusterIP
ports:
- port: 8000 # service port
protocol: TCP
targetPort: 8000 # container port inside your PodLast updated on
Was this page helpful?
