A Service is an abstraction which defines a logical set of Pods and a policy by which to access them (sometimes this pattern is called a micro-service).
Creating a service
<Example> A service on top of nginx pods that were create by a deployment
- Create a YAML file
apiVersion: v1 kind: Service metadata: name: nginx-service spec: selector: app: my-nginx ports: - protocol: TCP port: 80 targetPort: 80 nodePort: 30085 type: NodePort
- Run or apply
kubectl create -f <yaml-file> kubectl apply -f <yaml-file>
Working with services in the cluster
kubectl get service kubectl describe service <service-name> kubectl delete service <service-name>
Checking the status of the kubelet service
sudo systemctl status kubelet