博客
关于我
OpenShift 4 之使用https协议访问Route
阅读量:329 次
发布时间: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/

你可能感兴趣的文章
使用第三方sdk,微信wechat扫码登录
查看>>
mysql中的行转列
查看>>
ValueError: check_hostname requires server_hostname
查看>>
基于LabVIEW的入门指南
查看>>
PCB布局系列汇总
查看>>
电容入门知识
查看>>
2019CCPC女生专场赛_K - Tetris_打表/模拟_暴力之王
查看>>
HDU1559(二维前缀和模板 Java&C++)
查看>>
“/”应用程序中的服务器错误。
查看>>
MUI之ajax获取后台接口数据
查看>>
使用sqlserver 查询不连续的数据
查看>>
用div+css+html+js 实现图片放大
查看>>
(原创)在Linux上安装运行Python3(CentOS7为例)
查看>>
变量覆盖漏洞
查看>>
weblogic之cve-2015-4852
查看>>
Java注释
查看>>
水调歌头·1024
查看>>
对不起
查看>>
C++ 函数重载
查看>>
Nginx简介
查看>>