Kubernetes多master部署(2)---证书制作
作者:互联网
在master01(10.50.182.65)操作:
#安装证书生成工具cfssl mkdir -p /opt/ssl cd /opt/ssl 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 * 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
证书脚本 certificate.sh:
其中hosts地址要根据实际使用地址进行调整,内网网段也要加进去,其余不用动。
#证书根机构 cat > ca-config.json <<EOF { "signing": { "default": { "expiry": "87600h" }, "profiles": { "kubernetes": { "expiry": "87600h", "usages": [ "signing", "key encipherment", "server auth", "client auth" ] } } } } EOF #生成根证书的具体信息 cat > ca-csr.json <<EOF { "CN": "kubernetes", "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "CN", "L": "hangzhou", "ST": "hangzhou", "O": "k8s", "OU": "System" } ] } EOF #用cfssl生成证书 cfssl gencert -initca ca-csr.json | cfssljson -bare ca - #----------------------- #用于api http通信的证书信息 cat > server-csr.json <<EOF { "CN": "kubernetes", "hosts": [ "127.0.0.1", "10.50.182.65", "10.50.182.66", "10.50.182.67", "10.50.182.69", "10.10.10.1", "kubernetes", "kubernetes.default", "kubernetes.default.svc", "kubernetes.default.svc.cluster", "kubernetes.default.svc.cluster.local" ], "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "CN", "L": "BeiJing", "ST": "BeiJing", "O": "k8s", "OU": "System" } ] } EOF #生成server证书 cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=kubernetes server-csr.json | cfssljson -bare server #----------------------- #集群管理员证书,权限 cat > admin-csr.json <<EOF { "CN": "admin", "hosts": [], "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "CN", "L": "BeiJing", "ST": "BeiJing", "O": "system:masters", "OU": "System" } ] } EOF #生成管理员证书 cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=kubernetes admin-csr.json | cfssljson -bare admin #----------------------- #关于网络策略的证书 cat > kube-proxy-csr.json <<EOF { "CN": "system:kube-proxy", "hosts": [], "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "CN", "L": "BeiJing", "ST": "BeiJing", "O": "k8s", "OU": "System" } ] } EOF #生成网络策略证书 cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=kubernetes kube-proxy-csr.json | cfssljson -bare kube-proxy cp server* ca* /opt/kubernetes/ssl/
标签:bin,amd64,Kubernetes,证书,json,cfssl,master,linux,csr 来源: https://www.cnblogs.com/litzhiai/p/10813877.html