本文共 1012 字,大约阅读时间需要 3 分钟。
《》
说明:本文已经在OpenShift 4.6环境中验证使用OpenShift的oc命令可以将Service内部访问转为(oc的expose子命令)可从外部访问的Route,这种转换缺省是使用http协议访问应用的。如果要支持https协议,除了需要生成证书外,还需要用“oc create route”来创建Route对象。
$ oc new-project https$ oc new-app openshift/hello-openshift
$ HELLO_HOSTNAME=hello.$(oc get ingresscontroller default -n openshift-ingress-operator -o jsonpath='{.status.domain}')
$ openssl req -newkey rsa:4096 -nodes -sha256 -keyout example.key -x509 -days 365 -out example.crt -subj "/C=CN/ST=BEIJING/L=BJ/O=REDHAT/OU=IT/CN=${HELLO_HOSTNAME}"
注意:FQDN长度不能超过64个字符,否则会报下面错误。
140559095121728:error:0D07A097:asn1 encoding routines:ASN1_mbstring_ncopy:string too long:crypto/asn1/a_mbstr.c:107:maxsize=64
$ oc create route edge --service=hello-openshift --hostname=${HELLO_HOSTNAME} --key=example.key --cert=example.crt
$ curl --cacert example.crt https://$(oc get route hello-openshift -o template --template '{ {.spec.host}}')Hello OpenShift!
转载地址:http://relh.baihongyu.com/