Difference between revisions of "Kind: Service"

From wikieduonline
Jump to navigation Jump to search
Line 59: Line 59:
 
* <code>[[kubectl create service]]</code>
 
* <code>[[kubectl create service]]</code>
 
* <code>[[kind: Endpoint]]</code>
 
* <code>[[kind: Endpoint]]</code>
 +
* <code>[[ExternalTrafficPolicy]]</code>
  
 
== See also ==
 
== See also ==

Revision as of 08:24, 23 February 2024

kind: Service to create a Kubernetes 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


 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

See also

Advertising: