Skip to content

Instantly share code, notes, and snippets.

@parashuramn
Created June 6, 2023 18:07
Show Gist options
  • Save parashuramn/78a8f22b46dddc794805ef925b8afc63 to your computer and use it in GitHub Desktop.
Save parashuramn/78a8f22b46dddc794805ef925b8afc63 to your computer and use it in GitHub Desktop.
service.yaml
kind: Service
apiVersion: v1
metadata:
name: hostname-service
spec:
# Expose the service on a static port on each node
# so that we can access the service from outside the cluster
type: NodePort
# When the node receives a request on the static port (30163)
# "select pods with the label 'app' set to 'echo-hostname'"
# and forward the request to one of them
selector:
app: echo-hostname
ports:
# Three types of ports for a service
# nodePort - a static port assigned on each the node
# port - port exposed internally in the cluster
# targetPort - the container port to send requests to
- nodePort: 30163
port: 8080
targetPort: 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment