Skip to content

Instantly share code, notes, and snippets.

@thojkooi
Created June 23, 2018 15:48
Show Gist options
  • Save thojkooi/20f1bbe5ea06f7a42ce277379a73847f to your computer and use it in GitHub Desktop.
Save thojkooi/20f1bbe5ea06f7a42ce277379a73847f to your computer and use it in GitHub Desktop.
Generate etcd certificates for kubeadm
#!/bin/bash
# First generate the config file
cat >ca-config.json <<EOF
{
"signing": {
"default": {
"expiry": "43800h"
},
"profiles": {
"server": {
"expiry": "43800h",
"usages": [
"signing",
"key encipherment",
"server auth",
"client auth"
]
},
"client": {
"expiry": "43800h",
"usages": [
"signing",
"key encipherment",
"client auth"
]
},
"peer": {
"expiry": "43800h",
"usages": [
"signing",
"key encipherment",
"server auth",
"client auth"
]
}
}
}
}
EOF
# Next the CSR config
cat >ca-csr.json <<EOF
{
"CN": "etcd",
"key": {
"algo": "rsa",
"size": 2048
}
}
EOF
cfssl gencert -initca ca-csr.json | cfssljson -bare ca -
# Generate etcd client certificates
cat >client.json <<EOF
{
"CN": "client",
"key": {
"algo": "ecdsa",
"size": 256
}
}
EOF
cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=client client.json | cfssljson -bare client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment