removes curly brackets
parent
b974042d95
commit
26a86c64ec
|
@ -8,9 +8,9 @@ In this section you will provision a Certificate Authority that can be used to g
|
||||||
|
|
||||||
Generate the CA configuration file, certificate, and private key:
|
Generate the CA configuration file, certificate, and private key:
|
||||||
|
|
||||||
```
|
Have in mind all of the following commands this should be done on your terminal.
|
||||||
{
|
|
||||||
|
|
||||||
|
```
|
||||||
cat > ca-config.json <<EOF
|
cat > ca-config.json <<EOF
|
||||||
{
|
{
|
||||||
"signing": {
|
"signing": {
|
||||||
|
@ -26,7 +26,9 @@ cat > ca-config.json <<EOF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
cat > ca-csr.json <<EOF
|
cat > ca-csr.json <<EOF
|
||||||
{
|
{
|
||||||
"CN": "Kubernetes",
|
"CN": "Kubernetes",
|
||||||
|
@ -45,13 +47,13 @@ cat > ca-csr.json <<EOF
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cfssl gencert -initca ca-csr.json | cfssljson -bare ca
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Results:
|
```
|
||||||
|
cfssl gencert -initca ca-csr.json | cfssljson -bare ca
|
||||||
|
```
|
||||||
|
|
||||||
|
It should create two files:
|
||||||
|
|
||||||
```
|
```
|
||||||
ca-key.pem
|
ca-key.pem
|
||||||
|
@ -67,8 +69,6 @@ In this section you will generate client and server certificates for each Kubern
|
||||||
Generate the `admin` client certificate and private key:
|
Generate the `admin` client certificate and private key:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
|
|
||||||
cat > admin-csr.json <<EOF
|
cat > admin-csr.json <<EOF
|
||||||
{
|
{
|
||||||
"CN": "admin",
|
"CN": "admin",
|
||||||
|
@ -87,18 +87,18 @@ cat > admin-csr.json <<EOF
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
cfssl gencert \
|
cfssl gencert \
|
||||||
-ca=ca.pem \
|
-ca=ca.pem \
|
||||||
-ca-key=ca-key.pem \
|
-ca-key=ca-key.pem \
|
||||||
-config=ca-config.json \
|
-config=ca-config.json \
|
||||||
-profile=kubernetes \
|
-profile=kubernetes \
|
||||||
admin-csr.json | cfssljson -bare admin
|
admin-csr.json | cfssljson -bare admin
|
||||||
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Results:
|
It should generate two additional files:
|
||||||
|
|
||||||
```
|
```
|
||||||
admin-key.pem
|
admin-key.pem
|
||||||
|
@ -164,8 +164,6 @@ worker-2.pem
|
||||||
Generate the `kube-controller-manager` client certificate and private key:
|
Generate the `kube-controller-manager` client certificate and private key:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
|
|
||||||
cat > kube-controller-manager-csr.json <<EOF
|
cat > kube-controller-manager-csr.json <<EOF
|
||||||
{
|
{
|
||||||
"CN": "system:kube-controller-manager",
|
"CN": "system:kube-controller-manager",
|
||||||
|
@ -191,8 +189,6 @@ cfssl gencert \
|
||||||
-config=ca-config.json \
|
-config=ca-config.json \
|
||||||
-profile=kubernetes \
|
-profile=kubernetes \
|
||||||
kube-controller-manager-csr.json | cfssljson -bare kube-controller-manager
|
kube-controller-manager-csr.json | cfssljson -bare kube-controller-manager
|
||||||
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Results:
|
Results:
|
||||||
|
@ -208,8 +204,6 @@ kube-controller-manager.pem
|
||||||
Generate the `kube-proxy` client certificate and private key:
|
Generate the `kube-proxy` client certificate and private key:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
|
|
||||||
cat > kube-proxy-csr.json <<EOF
|
cat > kube-proxy-csr.json <<EOF
|
||||||
{
|
{
|
||||||
"CN": "system:kube-proxy",
|
"CN": "system:kube-proxy",
|
||||||
|
@ -236,7 +230,6 @@ cfssl gencert \
|
||||||
-profile=kubernetes \
|
-profile=kubernetes \
|
||||||
kube-proxy-csr.json | cfssljson -bare kube-proxy
|
kube-proxy-csr.json | cfssljson -bare kube-proxy
|
||||||
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Results:
|
Results:
|
||||||
|
@ -251,8 +244,6 @@ kube-proxy.pem
|
||||||
Generate the `kube-scheduler` client certificate and private key:
|
Generate the `kube-scheduler` client certificate and private key:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
|
|
||||||
cat > kube-scheduler-csr.json <<EOF
|
cat > kube-scheduler-csr.json <<EOF
|
||||||
{
|
{
|
||||||
"CN": "system:kube-scheduler",
|
"CN": "system:kube-scheduler",
|
||||||
|
@ -279,7 +270,6 @@ cfssl gencert \
|
||||||
-profile=kubernetes \
|
-profile=kubernetes \
|
||||||
kube-scheduler-csr.json | cfssljson -bare kube-scheduler
|
kube-scheduler-csr.json | cfssljson -bare kube-scheduler
|
||||||
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Results:
|
Results:
|
||||||
|
@ -297,8 +287,6 @@ The `kubernetes-the-hard-way` static IP address will be included in the list of
|
||||||
Generate the Kubernetes API Server certificate and private key:
|
Generate the Kubernetes API Server certificate and private key:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
|
|
||||||
KUBERNETES_PUBLIC_ADDRESS=$(gcloud compute addresses describe kubernetes-the-hard-way \
|
KUBERNETES_PUBLIC_ADDRESS=$(gcloud compute addresses describe kubernetes-the-hard-way \
|
||||||
--region $(gcloud config get-value compute/region) \
|
--region $(gcloud config get-value compute/region) \
|
||||||
--format 'value(address)')
|
--format 'value(address)')
|
||||||
|
@ -330,7 +318,6 @@ cfssl gencert \
|
||||||
-profile=kubernetes \
|
-profile=kubernetes \
|
||||||
kubernetes-csr.json | cfssljson -bare kubernetes
|
kubernetes-csr.json | cfssljson -bare kubernetes
|
||||||
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Results:
|
Results:
|
||||||
|
@ -347,8 +334,6 @@ The Kubernetes Controller Manager leverages a key pair to generate and sign serv
|
||||||
Generate the `service-account` certificate and private key:
|
Generate the `service-account` certificate and private key:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
|
|
||||||
cat > service-account-csr.json <<EOF
|
cat > service-account-csr.json <<EOF
|
||||||
{
|
{
|
||||||
"CN": "service-accounts",
|
"CN": "service-accounts",
|
||||||
|
@ -374,8 +359,6 @@ cfssl gencert \
|
||||||
-config=ca-config.json \
|
-config=ca-config.json \
|
||||||
-profile=kubernetes \
|
-profile=kubernetes \
|
||||||
service-account-csr.json | cfssljson -bare service-account
|
service-account-csr.json | cfssljson -bare service-account
|
||||||
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Results:
|
Results:
|
||||||
|
|
|
@ -60,7 +60,6 @@ worker-2.kubeconfig
|
||||||
Generate a kubeconfig file for the `kube-proxy` service:
|
Generate a kubeconfig file for the `kube-proxy` service:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
kubectl config set-cluster kubernetes-the-hard-way \
|
kubectl config set-cluster kubernetes-the-hard-way \
|
||||||
--certificate-authority=ca.pem \
|
--certificate-authority=ca.pem \
|
||||||
--embed-certs=true \
|
--embed-certs=true \
|
||||||
|
@ -79,7 +78,6 @@ Generate a kubeconfig file for the `kube-proxy` service:
|
||||||
--kubeconfig=kube-proxy.kubeconfig
|
--kubeconfig=kube-proxy.kubeconfig
|
||||||
|
|
||||||
kubectl config use-context default --kubeconfig=kube-proxy.kubeconfig
|
kubectl config use-context default --kubeconfig=kube-proxy.kubeconfig
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Results:
|
Results:
|
||||||
|
@ -93,7 +91,6 @@ kube-proxy.kubeconfig
|
||||||
Generate a kubeconfig file for the `kube-controller-manager` service:
|
Generate a kubeconfig file for the `kube-controller-manager` service:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
kubectl config set-cluster kubernetes-the-hard-way \
|
kubectl config set-cluster kubernetes-the-hard-way \
|
||||||
--certificate-authority=ca.pem \
|
--certificate-authority=ca.pem \
|
||||||
--embed-certs=true \
|
--embed-certs=true \
|
||||||
|
@ -112,7 +109,6 @@ Generate a kubeconfig file for the `kube-controller-manager` service:
|
||||||
--kubeconfig=kube-controller-manager.kubeconfig
|
--kubeconfig=kube-controller-manager.kubeconfig
|
||||||
|
|
||||||
kubectl config use-context default --kubeconfig=kube-controller-manager.kubeconfig
|
kubectl config use-context default --kubeconfig=kube-controller-manager.kubeconfig
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Results:
|
Results:
|
||||||
|
|
|
@ -28,19 +28,15 @@ wget -q --show-progress --https-only --timestamping \
|
||||||
Extract and install the `etcd` server and the `etcdctl` command line utility:
|
Extract and install the `etcd` server and the `etcdctl` command line utility:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
tar -xvf etcd-v3.3.5-linux-amd64.tar.gz
|
tar -xvf etcd-v3.3.5-linux-amd64.tar.gz
|
||||||
sudo mv etcd-v3.3.5-linux-amd64/etcd* /usr/local/bin/
|
sudo mv etcd-v3.3.5-linux-amd64/etcd* /usr/local/bin/
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configure the etcd Server
|
### Configure the etcd Server
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
sudo mkdir -p /etc/etcd /var/lib/etcd
|
sudo mkdir -p /etc/etcd /var/lib/etcd
|
||||||
sudo cp ca.pem kubernetes-key.pem kubernetes.pem /etc/etcd/
|
sudo cp ca.pem kubernetes-key.pem kubernetes.pem /etc/etcd/
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The instance internal IP address will be used to serve client requests and communicate with etcd cluster peers. Retrieve the internal IP address for the current compute instance:
|
The instance internal IP address will be used to serve client requests and communicate with etcd cluster peers. Retrieve the internal IP address for the current compute instance:
|
||||||
|
@ -94,11 +90,9 @@ EOF
|
||||||
### Start the etcd Server
|
### Start the etcd Server
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable etcd
|
sudo systemctl enable etcd
|
||||||
sudo systemctl start etcd
|
sudo systemctl start etcd
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> Remember to run the above commands on each controller node: `controller-0`, `controller-1`, and `controller-2`.
|
> Remember to run the above commands on each controller node: `controller-0`, `controller-1`, and `controller-2`.
|
||||||
|
|
|
@ -37,22 +37,18 @@ wget -q --show-progress --https-only --timestamping \
|
||||||
Install the Kubernetes binaries:
|
Install the Kubernetes binaries:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
chmod +x kube-apiserver kube-controller-manager kube-scheduler kubectl
|
chmod +x kube-apiserver kube-controller-manager kube-scheduler kubectl
|
||||||
sudo mv kube-apiserver kube-controller-manager kube-scheduler kubectl /usr/local/bin/
|
sudo mv kube-apiserver kube-controller-manager kube-scheduler kubectl /usr/local/bin/
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configure the Kubernetes API Server
|
### Configure the Kubernetes API Server
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
sudo mkdir -p /var/lib/kubernetes/
|
sudo mkdir -p /var/lib/kubernetes/
|
||||||
|
|
||||||
sudo mv ca.pem ca-key.pem kubernetes-key.pem kubernetes.pem \
|
sudo mv ca.pem ca-key.pem kubernetes-key.pem kubernetes.pem \
|
||||||
service-account-key.pem service-account.pem \
|
service-account-key.pem service-account.pem \
|
||||||
encryption-config.yaml /var/lib/kubernetes/
|
encryption-config.yaml /var/lib/kubernetes/
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The instance internal IP address will be used to advertise the API Server to members of the cluster. Retrieve the internal IP address for the current compute instance:
|
The instance internal IP address will be used to advertise the API Server to members of the cluster. Retrieve the internal IP address for the current compute instance:
|
||||||
|
@ -191,11 +187,9 @@ EOF
|
||||||
### Start the Controller Services
|
### Start the Controller Services
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable kube-apiserver kube-controller-manager kube-scheduler
|
sudo systemctl enable kube-apiserver kube-controller-manager kube-scheduler
|
||||||
sudo systemctl start kube-apiserver kube-controller-manager kube-scheduler
|
sudo systemctl start kube-apiserver kube-controller-manager kube-scheduler
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> Allow up to 10 seconds for the Kubernetes API Server to fully initialize.
|
> Allow up to 10 seconds for the Kubernetes API Server to fully initialize.
|
||||||
|
@ -227,12 +221,10 @@ EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
sudo mv kubernetes.default.svc.cluster.local \
|
sudo mv kubernetes.default.svc.cluster.local \
|
||||||
/etc/nginx/sites-available/kubernetes.default.svc.cluster.local
|
/etc/nginx/sites-available/kubernetes.default.svc.cluster.local
|
||||||
|
|
||||||
sudo ln -s /etc/nginx/sites-available/kubernetes.default.svc.cluster.local /etc/nginx/sites-enabled/
|
sudo ln -s /etc/nginx/sites-available/kubernetes.default.svc.cluster.local /etc/nginx/sites-enabled/
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -347,33 +339,26 @@ In this section you will provision an external load balancer to front the Kubern
|
||||||
Create the external load balancer network resources:
|
Create the external load balancer network resources:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
|
||||||
KUBERNETES_PUBLIC_ADDRESS=$(gcloud compute addresses describe kubernetes-the-hard-way \
|
KUBERNETES_PUBLIC_ADDRESS=$(gcloud compute addresses describe kubernetes-the-hard-way \
|
||||||
--region $(gcloud config get-value compute/region) \
|
--region $(gcloud config get-value compute/region) \
|
||||||
--format 'value(address)')
|
--format 'value(address)')
|
||||||
|
|
||||||
gcloud compute http-health-checks create kubernetes \
|
gcloud compute http-health-checks create kubernetes \
|
||||||
--description "Kubernetes Health Check" \
|
--description "Kubernetes Health Check" \
|
||||||
--host "kubernetes.default.svc.cluster.local" \
|
--host "kubernetes.default.svc.cluster.local" \
|
||||||
--request-path "/healthz"
|
--request-path "/healthz"
|
||||||
|
|
||||||
gcloud compute firewall-rules create kubernetes-the-hard-way-allow-health-check \
|
gcloud compute firewall-rules create kubernetes-the-hard-way-allow-health-check \
|
||||||
--network kubernetes-the-hard-way \
|
--network kubernetes-the-hard-way \
|
||||||
--source-ranges 209.85.152.0/22,209.85.204.0/22,35.191.0.0/16 \
|
--source-ranges 209.85.152.0/22,209.85.204.0/22,35.191.0.0/16 \
|
||||||
--allow tcp
|
--allow tcp
|
||||||
|
|
||||||
gcloud compute target-pools create kubernetes-target-pool \
|
gcloud compute target-pools create kubernetes-target-pool \
|
||||||
--http-health-check kubernetes
|
--http-health-check kubernetes
|
||||||
|
|
||||||
gcloud compute target-pools add-instances kubernetes-target-pool \
|
gcloud compute target-pools add-instances kubernetes-target-pool \
|
||||||
--instances controller-0,controller-1,controller-2
|
--instances controller-0,controller-1,controller-2
|
||||||
|
|
||||||
gcloud compute forwarding-rules create kubernetes-forwarding-rule \
|
gcloud compute forwarding-rules create kubernetes-forwarding-rule \
|
||||||
--address ${KUBERNETES_PUBLIC_ADDRESS} \
|
--address ${KUBERNETES_PUBLIC_ADDRESS} \
|
||||||
--ports 6443 \
|
--ports 6443 \
|
||||||
--region $(gcloud config get-value compute/region) \
|
--region $(gcloud config get-value compute/region) \
|
||||||
--target-pool kubernetes-target-pool
|
--target-pool kubernetes-target-pool
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Verification
|
### Verification
|
||||||
|
|
Loading…
Reference in New Issue