Nginx Service in Kubernetes
5 min readOct 30, 2024
When you run the command kubectl get svc nginx-deployment -o yaml
, Kubernetes will output the details of the Service named nginx-deployment
in YAML format. This command is useful when you want to inspect the full configuration of a Service, including its metadata, selectors, ports, and other details.
Here’s an example of what the output might look like:
apiVersion: v1
kind: Service
metadata:
creationTimestamp: "2024-10-18T10:12:10Z"
name: nginx-deployment
namespace: default
resourceVersion: "456789"
uid: 12345abc-6789-defg-0123-hijklmnopqrst
spec:
clusterIP: 10.96.234.56
clusterIPs:
- 10.96.234.56
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
Breakdown of the YAML Output:
- apiVersion: Specifies the API version for the resource (in this case,
v1
for Services). - kind: The resource type, which is
Service
here. - metadata: Provides details about the Service such as its name, namespace, unique identifier (
uid
), and creation timestamp.
- name: The name of the Service (
nginx-deployment
). - namespace: The namespace the Service belongs to…