Difference between revisions of "Kind: Service"

From wikieduonline
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 5: Line 5:
  
 
== Oficial example ==
 
== Oficial example ==
  [[apiVersion: v1]]
+
 
 +
  apiVersion: v1
 
  kind: Service
 
  kind: Service
 
  metadata:
 
  metadata:
Line 11: Line 12:
 
  spec:
 
  spec:
 
   [[selector:]]
 
   [[selector:]]
     app: MyApp
+
     [[app.kubernetes.io/name]]: MyApp
 
   ports:
 
   ports:
 
     - protocol: TCP
 
     - protocol: TCP
 
       port: 80
 
       port: 80
       [[targetPort:]] 9376
+
       targetPort: 9376
  
 
== Examples ==
 
== Examples ==
Line 35: Line 36:
 
   [[sessionAffinity]]: None
 
   [[sessionAffinity]]: None
 
   type: [[ClusterIP]]
 
   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 ==
 
== Related ==
 
* <code>[[kind: StatefulSet]]</code>
 
* <code>[[kind: StatefulSet]]</code>
 
* <code>[[kubectl create service]]</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


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]

Advertising: