Difference between revisions of "Kind: Service"
Jump to navigation
Jump to search
(19 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{lc}} | {{lc}} | ||
+ | <code>[[kind:]] [[Service]]</code> to create a [[Kubernetes services|Kubernetes service]] | ||
* https://kubernetes.io/docs/concepts/services-networking/service/ | * https://kubernetes.io/docs/concepts/services-networking/service/ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | == Oficial example == | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: my-service | ||
+ | spec: | ||
+ | [[selector:]] | ||
+ | [[app.kubernetes.io/name]]: MyApp | ||
+ | ports: | ||
+ | - protocol: TCP | ||
+ | port: 80 | ||
+ | targetPort: 9376 | ||
+ | |||
+ | == Examples == | ||
+ | |||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | annotations: {} | ||
+ | name: your_service | ||
+ | namespace: your_namespace | ||
+ | spec: | ||
+ | ports: | ||
+ | - name: http | ||
+ | port: 8080 | ||
+ | protocol: TCP | ||
+ | targetPort: 8080 | ||
+ | selector: | ||
+ | app: you_app | ||
+ | [[sessionAffinity]]: None | ||
+ | type: [[ClusterIP]] | ||
+ | |||
+ | |||
+ | |||
+ | {{type LoadBalancer}} | ||
+ | |||
+ | |||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: example-service | ||
+ | spec: | ||
+ | selector: | ||
+ | app: example | ||
+ | ports: | ||
+ | - port: 8765 | ||
+ | targetPort: 9376 | ||
+ | [[externalTrafficPolicy]]: Local | ||
+ | type: LoadBalancer | ||
+ | |||
+ | == Related == | ||
+ | * <code>[[kind: StatefulSet]]</code> | ||
+ | * <code>[[kubectl create service]]</code> | ||
+ | * <code>[[kind: Endpoint]]</code> | ||
+ | * <code>[[ExternalTrafficPolicy]]</code> | ||
+ | * <code>[[kind: Deployment]]</code> | ||
== See also == | == See also == |
Latest revision as of 10:26, 21 April 2024
kind: Service
to create a Kubernetes service
Contents
Oficial example[edit]
apiVersion: v1 kind: Service metadata: name: my-service spec: selector: app.kubernetes.io/name: MyApp ports: - protocol: TCP port: 80 targetPort: 9376
Examples[edit]
apiVersion: v1 kind: Service metadata: annotations: {} name: your_service namespace: your_namespace spec: ports: - name: http port: 8080 protocol: TCP targetPort: 8080 selector: app: you_app sessionAffinity: None type: ClusterIP
apiVersion: v1 kind: Service metadata: name: example-service spec: selector: app: example ports: - port: 8765 targetPort: 9376 type: LoadBalancer
apiVersion: v1 kind: Service metadata: name: example-service spec: selector: app: example ports: - port: 8765 targetPort: 9376 externalTrafficPolicy: Local type: LoadBalancer
Related[edit]
See also[edit]
- Kubernetes services,
kubectl get services, kubectl describe service
,kubectl create service
[loadbalancer
|nodeport
|clusterip
|externalname ], kubectl expose
,headless service, service.beta.kubernetes.io
kind:
[Pod | Ingress | ClusterConfiguration
|Config | ConfigMap | ServiceAccount | Deployment | List | Secret | Status ], spec: metadata: data:
Advertising: