-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgencert.sh
More file actions
executable file
·46 lines (38 loc) · 2.48 KB
/
gencert.sh
File metadata and controls
executable file
·46 lines (38 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#-------------------------------------------------
HIERA_PATH="/home/pioupiou/repoGit/hiera"
HIERA_CERTNAME="${HIERA_PATH}/certname_sandbox/"
ROLE_PATH="${HIERA_PATH}/inventory/sandbox/role/paassandbox.yaml"
CTRL_TOTAL="3"
CTRL_DOMAIN="sandbox.lapin.io"
CTRLS=("yfs-ctrl-01" "yfs-ctrl-02" "yfs-ctrl-03")
IPS=("10.161.0.49" "10.161.0.50" "10.161.0.51")
#-------------------------------------------------
for ((n=0;n<CTRL_TOTAL;n++)); do
echo ${CTRLS[$n]} ${IPS[$n]} $CTRL_DOMAIN
done
for f in etcd_ca kube_ca kube_front_proxy_ca; do
cd $f || exit 1
./generate-ca rsa 2048
if [[ $f == 'etcd_ca' ]]; then
for ((n=0;n<CTRL_TOTAL;n++)); do
./generate-certificates ${CTRLS[$n]} ${IPS[$n]} $CTRL_DOMAIN
{ echo 'kubernetes::etcdserver_crt: |';sed 's/^/ /' ./output/pki/${CTRLS[$n]}/server.pem; } >> "${HIERA_CERTNAME}/${CTRLS[$n]}.yaml"
{ echo 'kubernetes::etcdserver_key: |';sed 's/^/ /' ./output/pki/${CTRLS[$n]}/server-key.pem; } >> "${HIERA_CERTNAME}/${CTRLS[$n]}.yaml"
{ echo 'kubernetes::etcdpeer_crt: |';sed 's/^/ /' ./output/pki/${CTRLS[$n]}/peer.pem; } >> "${HIERA_CERTNAME}/${CTRLS[$n]}.yaml"
{ echo 'kubernetes::etcdpeer_key: |';sed 's/^/ /' ./output/pki/${CTRLS[$n]}/peer-key.pem; } >> "${HIERA_CERTNAME}/${CTRLS[$n]}.yaml"
done
fi
cd ..
done
echo -e "kubernetes::discovery_token_hash: $(cat ./kube_ca/output/pki/discovery_token_hash)" >> "${ROLE_PATH}"
{ echo 'kubernetes::etcd_ca_crt: |'; sed 's/^/ /' ./etcd_ca/output/pki/ca.pem; } >> "${ROLE_PATH}"
{ echo 'kubernetes::etcd_ca_key: |'; sed 's/^/ /' ./etcd_ca/output/pki/ca-key.pem; } >> "${ROLE_PATH}"
{ echo 'kubernetes::etcdclient_crt: |'; sed 's/^/ /' ./etcd_ca/output/pki/client.pem; } >> "${ROLE_PATH}"
{ echo 'kubernetes::etcdclient_key: |'; sed 's/^/ /' ./etcd_ca/output/pki/client-key.pem; } >> "${ROLE_PATH}"
{ echo 'kubernetes::kubernetes_ca_crt: |'; sed 's/^/ /' ./kube_ca/output/pki/ca.pem; } >> "${ROLE_PATH}"
{ echo 'kubernetes::kubernetes_ca_key: |'; sed 's/^/ /' ./kube_ca/output/pki/ca-key.pem; } >> "${ROLE_PATH}"
{ echo 'kubernetes::kubernetes_front_proxy_ca_crt: |'; sed 's/^/ /' ./kube_front_proxy_ca/output/pki/front-proxy-ca.pem; } >> "${ROLE_PATH}"
{ echo 'kubernetes::kubernetes_front_proxy_ca_key: |'; sed 's/^/ /' ./kube_front_proxy_ca/output/pki/front-proxy-ca-key.pem; } >> "${ROLE_PATH}"
{ echo 'kubernetes::sa_pub: |'; sed 's/^/ /' ./kube_ca/output/pki/sa.pub; } >> "${ROLE_PATH}"
{ echo 'kubernetes::sa_key: |'; sed 's/^/ /' ./kube_ca/output/pki/sa.key; } >> "${ROLE_PATH}"