手动制作CA证书
1.安装 CFSSL
[[email protected] ~]# cd /usr/local/src
[[email protected] src]# wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64
[[email protected] src]# wget https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
[[email protected] src]# wget https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64
[[email protected] src]# chmod +x cfssl*
[[email protected] src]# mv cfssl-certinfo_linux-amd64 /data/kubernetes/bin/cfssl-certinfo
[[email protected] src]# mv cfssljson_linux-amd64 /data/kubernetes/bin/cfssljson
[[email protected] src]# mv cfssl_linux-amd64 /data/kubernetes/bin/cfssl
复制cfssl命令文件拷贝到所有节点
[[email protected] ~]# scp /data/kubernetes/bin/cfssl* 10.31.90.201: /data/kubernetes/bin
[[email protected] ~]# scp /data/kubernetes/bin/cfssl* 10.31.90.202: /data/kubernetes/bin
将/data/kubernetes/bin加入环境变量
[[email protected] ~]# echo ‘PATH=/data/kubernetes/bin:$PATH‘ >>/etc/profile
[[email protected] ~]# source /etc/profile
2.初始化cfssl
生产初始配置文件,我们根据这些文件改
[[email protected] src]# mkdir ssl && cd ssl
[[email protected] ssl]# cfssl print-defaults config > config.json
[[email protected] ssl]# cfssl print-defaults csr > csr.json
3.创建用来生成 CA 文件的 JSON 配置文件
server auth表示client可以用该ca对server提供的证书进行验证
client auth表示server可以用该ca对client提供的证书进行验证
[[email protected] ssl]# vim ca-config.json
{
"signing": {
"default": {
"expiry": "87600h"
},
"profiles": {
"kubernetes": {
"usages": [
"signing",
"key encipherment",
"server auth",
"client auth"
],
"expiry": "87600h"
}
}
}
}
4.创建用来生成 CA 证书签名请求(CSR)的 JSON 配置文件
[[email protected] ssl]# vim ca-csr.json
{
"CN": "kubernetes",
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "CN",
"ST": "BeiJing",
"L": "BeiJing",
"O": "k8s",
"OU": "System"
}
]
}
5.生成CA证书(ca.pem)和密钥(ca-key.pem)
[[email protected] ssl]# cfssl gencert -initca ca-csr.json | cfssljson -bare ca
[[email protected] ssl]# ls -l ca*
-rw-r--r-- 1 root root 292 Dec 24 16:11 ca-config.json
-rw-r--r-- 1 root root 1001 Dec 24 16:15 ca.csr
-rw-r--r-- 1 root root 208 Dec 24 16:14 ca-csr.json
-rw------- 1 root root 1679 Dec 24 16:15 ca-key.pem
-rw-r--r-- 1 root root 1359 Dec 24 16:15 ca.pem
6.分发证书
[[email protected] ssl]# cp ca.csr ca.pem ca-key.pem ca-config.json /data/kubernetes/ssl
SCP证书到所有节点
[[email protected] ssl]# for n in `seq 202 206`;do scp ca.csr ca.pem ca-key.pem ca-config.json [email protected]$n:/data/kubernetes/ssl;done
ca.cs
后续会陆续更新所有的安装文档,如果你觉得我写的不错,希望大家多多关注点赞,非常感谢!
原文地址:http://blog.51cto.com/billy98/2334704
时间: 2024-11-09 10:00:46