博客
关于我
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负载均衡和F5的区别---系统运维工作笔记001
查看>>
nginx负载均衡和反相代理的配置
查看>>
nginx负载均衡器处理session共享的几种方法(转)
查看>>
nginx负载均衡的5种策略
查看>>
nginx负载均衡的5种策略(转载)
查看>>
nginx负载均衡的五种算法
查看>>
Nginx负载均衡详解
查看>>
Nginx负载均衡(upstream)
查看>>
nginx转发端口时与导致websocket不生效
查看>>
Nginx运维与实战(二)-Https配置
查看>>
Nginx部署_mysql代理_redis代理_phoenix代理_xxljob代理_websocket代理_Nacos代理_内网穿透代理_多系统转发---记录021_大数据工作笔记0181
查看>>
Nginx配置HTTPS服务
查看>>
Nginx配置Https证书
查看>>
Nginx配置http跳转https
查看>>
Nginx配置ssl实现https
查看>>
nginx配置ssl证书https解决公网ip可以访问但是域名不行的问题
查看>>
Nginx配置TCP代理指南
查看>>
NGINX配置TCP连接双向SSL
查看>>
Nginx配置——不记录指定文件类型日志
查看>>