Difference between revisions of "Kubernetes services"
Jump to navigation
Jump to search
(35 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | A Kubernetes [[service]] is an abstraction which defines a logical set of [[Pods]] and a [[policy]] by which to access. | + | A Kubernetes [[service]] is an abstraction which defines a logical set of [[Pods]] and a [[policy]] by which to access. When you create a Service, it creates a corresponding [[DNS]] entry. |
+ | * https://kubernetes.io/docs/concepts/services-networking/service/ | ||
+ | * <code>[[kind: Service]]</code> | ||
+ | == Commands == | ||
+ | * <code>[[kubectl create clusterip]]</code> | ||
+ | * <code>[[kubectl create service loadbalancer]]</code> | ||
+ | * <code>[[kubectl create nodeport]]</code> | ||
+ | * <code>[[kubectl create service externalname]]</code> | ||
+ | |||
+ | == Example == | ||
Kubernetes sample service: <code>my-service</code> | Kubernetes sample service: <code>my-service</code> | ||
apiVersion: v1 | apiVersion: v1 | ||
− | '''[[kind]] | + | '''[[kind: Service]]''' |
metadata: | metadata: | ||
name: my-service | name: my-service | ||
spec: | spec: | ||
− | selector: | + | [[selector:]] |
app: MyAppLabel | app: MyAppLabel | ||
− | ports: | + | [[ports:]] |
- protocol: [[TCP]] | - protocol: [[TCP]] | ||
port: 80 | port: 80 | ||
targetPort: 9376 | targetPort: 9376 | ||
− | If targetPort is not specified then same port value is used also as <code>[[targetPort]]</code> | + | If <code>targetPort</code> is not specified then same port value is used also as <code>[[targetPort]]</code> |
== Changelog == | == Changelog == | ||
+ | * [[v1.31]] (Aug 2024) [[K8s traffic distribution for Services]] | ||
* [[v1.18]] (March 2020) <code>AppProtocol</code> is a new optional field on ports in [[Endpoints]] and [[Services]] | * [[v1.18]] (March 2020) <code>AppProtocol</code> is a new optional field on ports in [[Endpoints]] and [[Services]] | ||
− | |||
== Related terms == | == Related terms == | ||
− | |||
− | |||
* <code>[[kubectl get services]]</code> | * <code>[[kubectl get services]]</code> | ||
− | * <code>[[kubectl get svc]]</code> | + | * <code>[[kubectl get svc]]</code>: <code>[[CLUSTER-IP]] [[EXTERNAL-IP]]</code> |
* <code>[[kubectl delete services]] hello-minikube</code> | * <code>[[kubectl delete services]] hello-minikube</code> | ||
− | |||
− | |||
* [[Deployments]] | * [[Deployments]] | ||
* <code>[[ConfigMaps]]</code> | * <code>[[ConfigMaps]]</code> | ||
+ | * <code>[[kubectl port-forward]]</code> | ||
+ | * [[Kubernetes Endpoints]]: <code>[[kind: Endpoint]]</code> | ||
+ | * <code>[[kind: ReplicaSet]]</code> | ||
+ | * <code>[[kubectl expose]]</code> | ||
+ | * [[Kubernetes headless service]] | ||
+ | * [[Terraform resource: kubernetes_service]] | ||
+ | * [[Kubernetes events]] | ||
+ | * <code>[[service.beta.kubernetes.io]]</code> | ||
+ | * [[service.externalTrafficPolicy]]=Cluster | ||
+ | |||
+ | == Activities == | ||
+ | * Review [[CKA 1.23]]: 20% - [[Kubernetes services|Service]] & [[Kubernetes networking|Networking]] | ||
+ | * Review [[CKA v1.18]]: Understand Services and other [[network primitives]] | ||
+ | * Review [[CKA v1.15]]: Understand Services | ||
== See also == | == See also == | ||
− | |||
* {{Kubernetes services}} | * {{Kubernetes services}} | ||
− | |||
− | |||
[[Category:Kubernetes]] | [[Category:Kubernetes]] |
Latest revision as of 15:07, 12 September 2024
A Kubernetes service is an abstraction which defines a logical set of Pods and a policy by which to access. When you create a Service, it creates a corresponding DNS entry.
Commands[edit]
kubectl create clusterip
kubectl create service loadbalancer
kubectl create nodeport
kubectl create service externalname
Example[edit]
Kubernetes sample service: my-service
apiVersion: v1 kind: Service metadata: name: my-service spec: selector: app: MyAppLabel ports: - protocol: TCP port: 80 targetPort: 9376
If targetPort
is not specified then same port value is used also as targetPort
Changelog[edit]
- v1.31 (Aug 2024) K8s traffic distribution for Services
- v1.18 (March 2020)
AppProtocol
is a new optional field on ports in Endpoints and Services
Related terms[edit]
kubectl get services
kubectl get svc
:CLUSTER-IP EXTERNAL-IP
kubectl delete services hello-minikube
- Deployments
ConfigMaps
kubectl port-forward
- Kubernetes Endpoints:
kind: Endpoint
kind: ReplicaSet
kubectl expose
- Kubernetes headless service
- Terraform resource: kubernetes_service
- Kubernetes events
service.beta.kubernetes.io
- service.externalTrafficPolicy=Cluster
Activities[edit]
- Review CKA 1.23: 20% - Service & Networking
- Review CKA v1.18: Understand Services and other network primitives
- Review CKA v1.15: Understand Services
See also[edit]
Advertising: