Mustafa CavusogluMC

Command Palette

Search for a command to run...

AboutExperiencesProjects
Linux3Docker7Git4Kubernetes7Network2uv1Miniconda1OpenShift4
Back to Home
OpenShift

Routes, services, and networking configuration in OpenShift

routeservicenetworkingtlsdomain

OpenShift Networking & Routes

Exposing applications and managing networking in OpenShift.

Routes

# Create a route
oc expose svc/my-app

# Create route with custom hostname
oc expose svc/my-app --hostname=app.example.com

# Create route with path
oc expose svc/my-app --path=/api

# Create secure route (edge termination)
oc create route edge my-route --service=my-app --hostname=app.example.com

# Create route with passthrough termination
oc create route passthrough my-route --service=my-app --hostname=app.example.com

# List routes
oc get routes

# Describe a route
oc describe route my-route

# Delete a route
oc delete route my-route

Services

# List services
oc get services
oc get svc

# Expose a deployment as service
oc expose dc/my-app --port=8080

# Expose with target port
oc expose dc/my-app --port=80 --target-port=8080

# Create service from file
oc create -f service.yaml

# Describe a service
oc describe svc my-app

Networking Troubleshooting

# Check pod connectivity
oc exec my-pod -- curl -s http://service-name:port

# Check DNS resolution
oc exec my-pod -- nslookup service-name
oc exec my-pod -- nslookup service-name.project.svc.cluster.local

# Check service endpoints
oc get endpoints my-service

# View network policies
oc get networkpolicies

# Describe network policy
oc describe networkpolicy my-policy

Example Service and Route YAML

apiVersion: v1
kind: Service
metadata:
  name: my-app
spec:
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 8080
  type: ClusterIP
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  name: my-app
spec:
  host: app.example.com
  to:
    kind: Service
    name: my-app
  tls:
    termination: edge
    insecureEdgeTerminationPolicy: Redirect