Skip to content

Instantly share code, notes, and snippets.

@Miciah
Created November 3, 2021 01:04
Show Gist options
  • Save Miciah/5fd6c88b45803dd3ebb55f63f28ca83e to your computer and use it in GitHub Desktop.
Save Miciah/5fd6c88b45803dd3ebb55f63f28ca83e to your computer and use it in GitHub Desktop.
Example of using route spec.subdomain
% # /msg @cluster-bot launch openshift/openshift-apiserver#254,openshift/cluster-ingress-operator#674,openshift/router#357
% oc get dnses.config/cluster -o 'jsonpath={.spec.baseDomain}{"\n"}'
ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com
% cat ~/tmp/ingresscontroller-custom.yaml
apiVersion: operator.openshift.io/v1
kind: IngressController
metadata:
name: custom
namespace: openshift-ingress-operator
spec:
domain: custom.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com
replicas: 1
endpointPublishingStrategy:
type: LoadBalancerService
% oc create -f ~/tmp/ingresscontroller-custom.yaml
ingresscontroller.operator.openshift.io/custom created
% oc adm new-project hello-openshift && oc -n hello-openshift create -f ~/src/github.com/openshift/origin/examples/hello-openshift/hello-pod.json && oc -n hello-openshift expose pod/hello-openshift && oc -n hello-openshift create -f ~/tmp/hello-openshift-route.yaml && oc -n hello-openshift get routes
Created project hello-openshift
pod/hello-openshift created
service/hello-openshift exposed
route.route.openshift.io/hello-openshift-edge created
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
hello-openshift-edge hello-openshift.custom.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com ... 1 more hello-openshift <all> edge None
% oc -n hello-openshift get routes/hello-openshift-edge -o yaml
apiVersion: route.openshift.io/v1
kind: Route
metadata:
creationTimestamp: "2021-11-03T00:53:12Z"
managedFields:
- apiVersion: route.openshift.io/v1
fieldsType: FieldsV1
fieldsV1:
f:spec:
f:subdomain: {}
f:tls:
.: {}
f:termination: {}
f:to:
f:kind: {}
f:name: {}
f:weight: {}
f:wildcardPolicy: {}
manager: kubectl-create
operation: Update
time: "2021-11-03T00:53:12Z"
- apiVersion: route.openshift.io/v1
fieldsType: FieldsV1
fieldsV1:
f:spec:
f:host: {}
f:status:
f:ingress: {}
manager: openshift-router
operation: Update
time: "2021-11-03T00:53:12Z"
name: hello-openshift-edge
namespace: hello-openshift
resourceVersion: "27103"
uid: b1cd4ced-038d-4f93-b30f-eaa1553d0564
spec:
subdomain: hello-openshift
tls:
termination: edge
to:
kind: Service
name: hello-openshift
weight: 100
wildcardPolicy: None
status:
ingress:
- conditions:
- lastTransitionTime: "2021-11-03T00:53:12Z"
status: "True"
type: Admitted
host: hello-openshift.apps.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com
routerCanonicalHostname: router-default.apps.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com
routerName: default
wildcardPolicy: None
- conditions:
- lastTransitionTime: "2021-11-03T00:53:12Z"
status: "True"
type: Admitted
host: hello-openshift.custom.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com
routerCanonicalHostname: router-custom.custom.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com
routerName: custom
wildcardPolicy: None
% nslookup router-default.apps.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com
Server: 127.0.0.1
Address: 127.0.0.1#53
Non-authoritative answer:
Name: router-default.apps.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com
Address: 34.121.65.119
% curl -k https://hello-openshift.apps.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com --resolve hello-openshift.apps.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com:443:34.121.65.119
Hello OpenShift!
% nslookup router-custom.custom.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com
Server: 127.0.0.1
Address: 127.0.0.1#53
Non-authoritative answer:
Name: router-custom.custom.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com
Address: 35.238.209.184
% curl -k https://hello-openshift.custom.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com --resolve hello-openshift.custom.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com:443:35.238.209.184
Hello OpenShift!
% # Now try using the default router's domain with the custom router and vice versa. The following curl commands should fail:
% curl -k -I https://hello-openshift.apps.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com --resolve hello-openshift.apps.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com:443:35.238.209.184
HTTP/1.0 503 Service Unavailable
pragma: no-cache
cache-control: private, max-age=0, no-cache, no-store
content-type: text/html
% curl -k -I https://hello-openshift.custom.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com --resolve hello-openshift.custom.ci-ln-c9vsmcb-72292.origin-ci-int-gce.dev.rhcloud.com:443:34.121.65.119
HTTP/1.0 503 Service Unavailable
pragma: no-cache
cache-control: private, max-age=0, no-cache, no-store
content-type: text/html
%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment