使用OpenSSL生成Kubernetes證書的介紹
kubernetes支持Base認(rèn)證/Token認(rèn)證/CA認(rèn)證三種,這篇文章用于記錄一下CA認(rèn)證所需要的最簡單程度的命令。
kubernetes構(gòu)成
測試版本為1.10,但不限于此版本,為openssl證書較為通用的方式。
所需證書
所需要的證書相關(guān)文件的說明如下:
CA證書
CA證書私鑰
命令:openssl genrsa -out ca.key 2048
[root@host121 k8scert]# openssl genrsa -out ca.key 2048 Generating RSA private key, 2048 bit long modulus ........................................................+++ ..................+++ e is 65537 (0x10001) [root@host121 k8scert]#
CA證書
命令:openssl genrsa -out ca.key 2048
[root@host121 k8scert]# openssl req -x509 -new -nodes -key ca.key -subj "/CN=host121" -days 5000 -out ca.crt [root@host121 k8scert]# ls archive ca.crt ca.key [root@host121 k8scert]#
XXX用證書
apiserver/ControllerManager/kublet等所需證書可用如下方式創(chuàng)建
證書私鑰
命令:openssl genrsa -out server.key 2048
[root@host121 k8scert]# openssl genrsa -out server.key 2048 Generating RSA private key, 2048 bit long modulus ..............................+++ ........................................................................+++ e is 65537 (0x10001) [root@host121 k8scert]#
證書簽名請求文件
命令:openssl req -new -key server.key -subj “/CN=host121” -out server.csr
[root@host121 k8scert]# openssl req -new -key server.key -subj "/CN=host121" -out server.csr [root@host121 k8scert]#
subj中設(shè)定的subject的信息為用戶自己的數(shù)據(jù),一般將CN設(shè)定為域名/機器名/或者IP名稱,比如kubelet為所在node的IP即可
證書
命令:openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 5000
[root@host121 k8scert]# openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 5000 Signature ok subject=/CN=host121 Getting CA Private Key [root@host121 k8scert]#
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接
相關(guān)文章
詳解通過Docker搭建Mysql容器+Tomcat容器連接環(huán)境
本篇文章主要介紹了通過Docker搭建Mysql容器+Tomcat容器連接環(huán)境,具有一定的參考價值,有興趣的可以了解一下。2017-01-01docker安裝tomcat并部署Springboot項目war包的方法
這篇文章主要介紹了docker安裝tomcat并部署Springboot項目war包的方法,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-11-11詳解Docker 配置國內(nèi)免費registry mirror
本篇文章主要介紹了 Docker 配置國內(nèi)免費registry mirror,具有一定的參考價值,有興趣的小伙伴們可以參考一下2017-07-07