kubernetes支持Base認(rèn)證/Token認(rèn)證/CA認(rèn)證三種,這篇文章用于記錄一下CA認(rèn)證所需要的最簡(jiǎn)單程度的命令。
kubernetes構(gòu)成
![](http://img.jbzj.com/file_images/article/201901/20191291605949.png?20190291619)
測(cè)試版本為1.10,但不限于此版本,為openssl證書(shū)較為通用的方式。
所需證書(shū)
所需要的證書(shū)相關(guān)文件的說(shuō)明如下:
![](http://img.jbzj.com/file_images/article/201901/20191291638328.png?20190291650)
CA證書(shū)
CA證書(shū)私鑰
![](http://img.jbzj.com/file_images/article/201901/20191291730732.png?20190291742)
命令: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證書(shū)
![](http://img.jbzj.com/file_images/article/201901/20191291813106.png?20190291824)
命令: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用證書(shū)
apiserver/ControllerManager/kublet等所需證書(shū)可用如下方式創(chuàng)建
證書(shū)私鑰
![](http://img.jbzj.com/file_images/article/201901/20191291903988.png?20190291913)
命令: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]#
證書(shū)簽名請(qǐng)求文件
![](http://img.jbzj.com/file_images/article/201901/20191291938856.png?20190291949)
命令: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的信息為用戶(hù)自己的數(shù)據(jù),一般將CN設(shè)定為域名/機(jī)器名/或者IP名稱(chēng),比如kubelet為所在node的IP即可
證書(shū)
![](http://img.jbzj.com/file_images/article/201901/20191292027600.png?20190292036)
命令: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é)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接