Kubernetes Service Operations: Difference between revisions
Jump to navigation
Jump to search
Line 15: | Line 15: | ||
Describe the service in a metadata YAML file: | Describe the service in a metadata YAML file: | ||
<syntaxhighlight lang='yaml'> | <syntaxhighlight lang='yaml'> | ||
apiVersion: v1 | |||
kind: Service | |||
metadata: | |||
name: some-service | |||
spec: | |||
selector: | |||
function: serves-http | |||
ports: | |||
- port: 80 | |||
targetPort: 8888 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 00:25, 20 September 2020
Internal
Create a Service
With CLI
A service of any type (ClusterIP, NodePort, LoadBalancer, or ExternalName) can be created with the kubectl expose command.
More details:
With Metadata
Describe the service in a metadata YAML file:
apiVersion: v1
kind: Service
metadata:
name: some-service
spec:
selector:
function: serves-http
ports:
- port: 80
targetPort: 8888
More details about the service manifest available in:
POST it with:
kubectl apply -f ./service.yaml