博客
关于我
OpenShift 4 之使用https协议访问Route
阅读量:330 次
发布时间:2019-03-04

本文共 1012 字,大约阅读时间需要 3 分钟。

《》

说明:本文已经在OpenShift 4.6环境中验证

使用OpenShift的oc命令可以将Service内部访问转为(oc的expose子命令)可从外部访问的Route,这种转换缺省是使用http协议访问应用的。如果要支持https协议,除了需要生成证书外,还需要用“oc create route”来创建Route对象。

  1. 首先部署一个测试应用
$ oc new-project https$ oc new-app openshift/hello-openshift
  1. 生成访该hello应用的FQDN名称。
$ HELLO_HOSTNAME=hello.$(oc get ingresscontroller default -n openshift-ingress-operator -o jsonpath='{.status.domain}')
  1. 创建访问FQDN地址的SSL密钥和证书。
$ 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
  1. 根据密钥、证书和Service创建Route,并指定访问的FQDN
$ oc create route edge --service=hello-openshift --hostname=${HELLO_HOSTNAME} --key=example.key --cert=example.crt
  1. 用https协议访问Route
$ curl --cacert example.crt https://$(oc get route hello-openshift -o template --template '{    {.spec.host}}')Hello OpenShift!

转载地址:http://relh.baihongyu.com/

你可能感兴趣的文章
nginx 常用指令配置总结
查看>>
Nginx 常用配置清单
查看>>
nginx 常用配置记录
查看>>
nginx 开启ssl模块 [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx
查看>>
Nginx 我们必须知道的那些事
查看>>
Nginx 源码完全注释(11)ngx_spinlock
查看>>
Nginx 的 proxy_pass 使用简介
查看>>
Nginx 的 SSL 模块安装
查看>>
Nginx 的优化思路,并解析网站防盗链
查看>>
Nginx 的配置文件中的 keepalive 介绍
查看>>
Nginx 相关介绍(Nginx是什么?能干嘛?)
查看>>
Nginx 知识点一网打尽:动静分离、压缩、缓存、跨域、高可用、性能优化...
查看>>
nginx 禁止以ip形式访问服务器
查看>>
NGINX 端口负载均衡
查看>>
Nginx 结合 consul 实现动态负载均衡
查看>>