You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
3.1 KiB
166 lines
3.1 KiB
#!/bin/bash
|
|
|
|
#WORKER0_HOST=<Public hostname of your first worker node cloud server>
|
|
#WORKER0_IP=<Private IP of your first worker node cloud server>
|
|
#WORKER1_HOST=<Public hostname of your second worker node cloud server>
|
|
#WORKER1_IP=<Private IP of your second worker node cloud server>
|
|
|
|
cd ~/kthw
|
|
|
|
cat > admin-csr.json << EOF
|
|
{
|
|
"CN": "admin",
|
|
"key": {
|
|
"algo": "rsa",
|
|
"size": 2048
|
|
},
|
|
"names": [
|
|
{
|
|
"C": "US",
|
|
"L": "Flint",
|
|
"O": "system:masters",
|
|
"OU": "Kubernetes The Hard Way",
|
|
"ST": "Michigan"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
cfssl gencert \
|
|
-ca=ca.pem \
|
|
-ca-key=ca-key.pem \
|
|
-config=ca-config.json \
|
|
-profile=kubernetes \
|
|
admin-csr.json | cfssljson -bare admin
|
|
|
|
cat > ${WORKER0_HOST}-csr.json << EOF
|
|
{
|
|
"CN": "system:node:${WORKER0_HOST}",
|
|
"key": {
|
|
"algo": "rsa",
|
|
"size": 2048
|
|
},
|
|
"names": [
|
|
{
|
|
"C": "US",
|
|
"L": "Flint",
|
|
"O": "system:nodes",
|
|
"OU": "Kubernetes The Hard Way",
|
|
"ST": "Oregon"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
cfssl gencert \
|
|
-ca=ca.pem \
|
|
-ca-key=ca-key.pem \
|
|
-config=ca-config.json \
|
|
-hostname=${WORKER0_IP},${WORKER0_HOST} \
|
|
-profile=kubernetes \
|
|
${WORKER0_HOST}-csr.json | cfssljson -bare ${WORKER0_HOST}
|
|
|
|
cat > ${WORKER1_HOST}-csr.json << EOF
|
|
{
|
|
"CN": "system:node:${WORKER1_HOST}",
|
|
"key": {
|
|
"algo": "rsa",
|
|
"size": 2048
|
|
},
|
|
"names": [
|
|
{
|
|
"C": "US",
|
|
"L": "Flint",
|
|
"O": "system:nodes",
|
|
"OU": "Kubernetes The Hard Way",
|
|
"ST": "Michigan"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
cfssl gencert \
|
|
-ca=ca.pem \
|
|
-ca-key=ca-key.pem \
|
|
-config=ca-config.json \
|
|
-hostname=${WORKER1_IP},${WORKER1_HOST} \
|
|
-profile=kubernetes \
|
|
${WORKER1_HOST}-csr.json | cfssljson -bare ${WORKER1_HOST}
|
|
|
|
cat > kube-controller-manager-csr.json << EOF
|
|
{
|
|
"CN": "system:kube-controller-manager",
|
|
"key": {
|
|
"algo": "rsa",
|
|
"size": 2048
|
|
},
|
|
"names": [
|
|
{
|
|
"C": "US",
|
|
"L": "Flint",
|
|
"O": "system:kube-controller-manager",
|
|
"OU": "Kubernetes The Hard Way",
|
|
"ST": "Michigan"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
cfssl gencert \
|
|
-ca=ca.pem \
|
|
-ca-key=ca-key.pem \
|
|
-config=ca-config.json \
|
|
-profile=kubernetes \
|
|
kube-controller-manager-csr.json | cfssljson -bare kube-controller-manager
|
|
|
|
cat > kube-proxy-csr.json << EOF
|
|
{
|
|
"CN": "system:kube-proxy",
|
|
"key": {
|
|
"algo": "rsa",
|
|
"size": 2048
|
|
},
|
|
"names": [
|
|
{
|
|
"C": "US",
|
|
"L": "Flint",
|
|
"O": "system:node-proxier",
|
|
"OU": "Kubernetes The Hard Way",
|
|
"ST": "Michigan"
|
|
}
|
|
]
|
|
}
|
|
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
|
|
|
|
cat > kube-scheduler-csr.json << EOF
|
|
{
|
|
"CN": "system:kube-scheduler",
|
|
"key": {
|
|
"algo": "rsa",
|
|
"size": 2048
|
|
},
|
|
"names": [
|
|
{
|
|
"C": "US",
|
|
"L": "Flint",
|
|
"O": "system:kube-scheduler",
|
|
"OU": "Kubernetes The Hard Way",
|
|
"ST": "Michigan"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
cfssl gencert \
|
|
-ca=ca.pem \
|
|
-ca-key=ca-key.pem \
|
|
-config=ca-config.json \
|
|
-profile=kubernetes \
|
|
kube-scheduler-csr.json | cfssljson -bare kube-scheduler
|
|
|