This guide demonstrates how to set up a service deployment for Kubernetes. You can follow the example YAML configuration provided below to create a service for your Kubernetes cluster.
apiVersion: v1
kind: Service
metadata:
name: posts-srv
spec:
type: NodePort
selector:
app: posts
ports:
- name: posts
protocol: TCP
port: 4000
targetPort: 4000
- Apply the configuration using the following command:
kubectl apply -f posts-srv.yaml
- Verify the service deployment:
kubectl get services
- Obtain detailed information about the service:
kubectl describe service posts-srv
- Check the logs for the service:
kubectl logs service posts-srv