根證書是全部證書的基礎,後面的證書都是根據此證書而來(其實Kubernetes難就難在證書和受權,理解起來不容易),centos默認自帶的1.5.2默認不採用證書,就會簡單得多。linux
wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64
wget https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
wget https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64
chmod +x cfssl_linux-amd64 cfssljson_linux-amd64 cfssl-certinfo_linux-amd64
mv cfssl_linux-amd64 /usr/local/bin/cfssl
mv cfssljson_linux-amd64 /usr/local/bin/cfssljson
mv cfssl-certinfo_linux-amd64 /usr/bin/cfssl-certinfo複製代碼
準備證書文件,設置5年有效期json
cd /etc/ssl/
cat > /etc/ssl/ca-config.json <<EOF
{
"signing": {
"default": {
"expiry": "87600h"
},
"profiles": {
"kubernetes": {
"usages": [
"signing",
"key encipherment",
"server auth",
"client auth"
],
"expiry": "87600h"
}
}
}
}
EOF
複製代碼
cat > /etc/ssl/ca-csr.json <<EOF
{
"CN": "kubernetes",
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "CN",
"ST": "ChengDu",
"L": "ChengDu",
"O": "k8s",
"OU": "dessler"
}
]
}
EOF
複製代碼
cfssl gencert -initca ca-csr.json | cfssljson -bare ca -
複製代碼
執行完成之後,當前目錄會生成ca根證書,這個證書是後續證書的基礎centos
ls
ca-config.json ca.csr ca-csr.json ca-key.pem ca.pem
複製代碼