1 Star 1 Fork 4

liy36/k8s-certs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
etcd-certs.sh 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
liy36 提交于 2022-08-15 14:09 . init k8s-certs
#!/usr/bin/env bash
__Author__="liy"
source ./functions.sh
export CERT_DIR="${ROOT_DIR}/${1:-"etcd"}"
function init_env(){
mkdir -pv $CERT_DIR
}
function create_ca(){
openssl genrsa -out $CERT_DIR/ca.key 2048
openssl req -config openssl.conf \
-new -x509 -days 3651 -sha256 \
-key $CERT_DIR/ca.key -extensions v3_ca \
-out $CERT_DIR/ca.crt -subj "/CN=etcd-ca"
touch $CERT_DIR/{index,index.txt}
echo 1000 > $CERT_DIR/serial
echo "unique_subject = no" > $CERT_DIR/index.txt.attr
}
function sign(){
# Peer
openssl_req $CERT_DIR peer "/CN=etcd"
openssl_sign $CERT_DIR/ca.crt $CERT_DIR/ca.key $CERT_DIR peer etcd_peer_cert
# Server
openssl_req $CERT_DIR server "/CN=etcd"
openssl_sign $CERT_DIR/ca.crt $CERT_DIR/ca.key $CERT_DIR server etcd_server_cert
# APIServerClient
openssl_req $CERT_DIR apiserver-etcd-client "/CN=etcd"
openssl_sign $CERT_DIR/ca.crt $CERT_DIR/ca.key $CERT_DIR apiserver-etcd-client client_cert
# Client
openssl_req $CERT_DIR client "/CN=etcd"
openssl_sign $CERT_DIR/ca.crt $CERT_DIR/ca.key $CERT_DIR client client_cert
}
function main(){
init_env
create_ca
sign
clean
}
main
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liy36/k8s-certs.git
git@gitee.com:liy36/k8s-certs.git
liy36
k8s-certs
k8s-certs
master

搜索帮助