more brackets
parent
26a86c64ec
commit
51eaa0b86b
|
@ -60,24 +60,24 @@ 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 \
|
||||||
--server=https://${KUBERNETES_PUBLIC_ADDRESS}:6443 \
|
--server=https://${KUBERNETES_PUBLIC_ADDRESS}:6443 \
|
||||||
--kubeconfig=kube-proxy.kubeconfig
|
--kubeconfig=kube-proxy.kubeconfig
|
||||||
|
|
||||||
kubectl config set-credentials system:kube-proxy \
|
kubectl config set-credentials system:kube-proxy \
|
||||||
--client-certificate=kube-proxy.pem \
|
--client-certificate=kube-proxy.pem \
|
||||||
--client-key=kube-proxy-key.pem \
|
--client-key=kube-proxy-key.pem \
|
||||||
--embed-certs=true \
|
--embed-certs=true \
|
||||||
--kubeconfig=kube-proxy.kubeconfig
|
--kubeconfig=kube-proxy.kubeconfig
|
||||||
|
|
||||||
kubectl config set-context default \
|
kubectl config set-context default \
|
||||||
--cluster=kubernetes-the-hard-way \
|
--cluster=kubernetes-the-hard-way \
|
||||||
--user=system:kube-proxy \
|
--user=system:kube-proxy \
|
||||||
--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:
|
||||||
|
@ -123,26 +123,24 @@ kube-controller-manager.kubeconfig
|
||||||
Generate a kubeconfig file for the `kube-scheduler` service:
|
Generate a kubeconfig file for the `kube-scheduler` 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 \
|
||||||
--server=https://127.0.0.1:6443 \
|
--server=https://127.0.0.1:6443 \
|
||||||
--kubeconfig=kube-scheduler.kubeconfig
|
--kubeconfig=kube-scheduler.kubeconfig
|
||||||
|
|
||||||
kubectl config set-credentials system:kube-scheduler \
|
kubectl config set-credentials system:kube-scheduler \
|
||||||
--client-certificate=kube-scheduler.pem \
|
--client-certificate=kube-scheduler.pem \
|
||||||
--client-key=kube-scheduler-key.pem \
|
--client-key=kube-scheduler-key.pem \
|
||||||
--embed-certs=true \
|
--embed-certs=true \
|
||||||
--kubeconfig=kube-scheduler.kubeconfig
|
--kubeconfig=kube-scheduler.kubeconfig
|
||||||
|
|
||||||
kubectl config set-context default \
|
kubectl config set-context default \
|
||||||
--cluster=kubernetes-the-hard-way \
|
--cluster=kubernetes-the-hard-way \
|
||||||
--user=system:kube-scheduler \
|
--user=system:kube-scheduler \
|
||||||
--kubeconfig=kube-scheduler.kubeconfig
|
--kubeconfig=kube-scheduler.kubeconfig
|
||||||
|
|
||||||
kubectl config use-context default --kubeconfig=kube-scheduler.kubeconfig
|
kubectl config use-context default --kubeconfig=kube-scheduler.kubeconfig
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Results:
|
Results:
|
||||||
|
@ -156,26 +154,24 @@ kube-scheduler.kubeconfig
|
||||||
Generate a kubeconfig file for the `admin` user:
|
Generate a kubeconfig file for the `admin` user:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
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 \
|
||||||
--server=https://127.0.0.1:6443 \
|
--server=https://127.0.0.1:6443 \
|
||||||
--kubeconfig=admin.kubeconfig
|
--kubeconfig=admin.kubeconfig
|
||||||
|
|
||||||
kubectl config set-credentials admin \
|
kubectl config set-credentials admin \
|
||||||
--client-certificate=admin.pem \
|
--client-certificate=admin.pem \
|
||||||
--client-key=admin-key.pem \
|
--client-key=admin-key.pem \
|
||||||
--embed-certs=true \
|
--embed-certs=true \
|
||||||
--kubeconfig=admin.kubeconfig
|
--kubeconfig=admin.kubeconfig
|
||||||
|
|
||||||
kubectl config set-context default \
|
kubectl config set-context default \
|
||||||
--cluster=kubernetes-the-hard-way \
|
--cluster=kubernetes-the-hard-way \
|
||||||
--user=admin \
|
--user=admin \
|
||||||
--kubeconfig=admin.kubeconfig
|
--kubeconfig=admin.kubeconfig
|
||||||
|
|
||||||
kubectl config use-context default --kubeconfig=admin.kubeconfig
|
kubectl config use-context default --kubeconfig=admin.kubeconfig
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Results:
|
Results:
|
||||||
|
|
|
@ -38,6 +38,7 @@ 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/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -188,7 +189,9 @@ EOF
|
||||||
|
|
||||||
```
|
```
|
||||||
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
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -342,18 +345,23 @@ 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 \
|
||||||
|
|
|
@ -19,10 +19,9 @@ gcloud compute ssh worker-0
|
||||||
Install the OS dependencies:
|
Install the OS dependencies:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
sudo apt-get update
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get -y install socat conntrack ipset
|
sudo apt-get -y install socat conntrack ipset
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> The socat binary enables support for the `kubectl port-forward` command.
|
> The socat binary enables support for the `kubectl port-forward` command.
|
||||||
|
@ -56,14 +55,17 @@ sudo mkdir -p \
|
||||||
Install the worker binaries:
|
Install the worker binaries:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
chmod +x kubectl kube-proxy kubelet runc.amd64 runsc
|
||||||
chmod +x kubectl kube-proxy kubelet runc.amd64 runsc
|
|
||||||
sudo mv runc.amd64 runc
|
sudo mv runc.amd64 runc
|
||||||
sudo mv kubectl kube-proxy kubelet runc runsc /usr/local/bin/
|
|
||||||
sudo tar -xvf crictl-v1.0.0-beta.0-linux-amd64.tar.gz -C /usr/local/bin/
|
sudo mv kubectl kube-proxy kubelet runc runsc /usr/local/bin/
|
||||||
sudo tar -xvf cni-plugins-amd64-v0.6.0.tgz -C /opt/cni/bin/
|
|
||||||
sudo tar -xvf containerd-1.1.0.linux-amd64.tar.gz -C /
|
sudo tar -xvf crictl-v1.0.0-beta.0-linux-amd64.tar.gz -C /usr/local/bin/
|
||||||
}
|
|
||||||
|
sudo tar -xvf cni-plugins-amd64-v0.6.0.tgz -C /opt/cni/bin/
|
||||||
|
|
||||||
|
sudo tar -xvf containerd-1.1.0.linux-amd64.tar.gz -C /
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configure CNI Networking
|
### Configure CNI Networking
|
||||||
|
@ -163,11 +165,11 @@ EOF
|
||||||
### Configure the Kubelet
|
### Configure the Kubelet
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
sudo mv ${HOSTNAME}-key.pem ${HOSTNAME}.pem /var/lib/kubelet/
|
||||||
sudo mv ${HOSTNAME}-key.pem ${HOSTNAME}.pem /var/lib/kubelet/
|
|
||||||
sudo mv ${HOSTNAME}.kubeconfig /var/lib/kubelet/kubeconfig
|
sudo mv ${HOSTNAME}.kubeconfig /var/lib/kubelet/kubeconfig
|
||||||
sudo mv ca.pem /var/lib/kubernetes/
|
|
||||||
}
|
sudo mv ca.pem /var/lib/kubernetes/
|
||||||
```
|
```
|
||||||
|
|
||||||
Create the `kubelet-config.yaml` configuration file:
|
Create the `kubelet-config.yaml` configuration file:
|
||||||
|
@ -264,11 +266,11 @@ EOF
|
||||||
### Start the Worker Services
|
### Start the Worker Services
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable containerd kubelet kube-proxy
|
sudo systemctl enable containerd kubelet kube-proxy
|
||||||
sudo systemctl start containerd kubelet kube-proxy
|
|
||||||
}
|
sudo systemctl start containerd kubelet kube-proxy
|
||||||
```
|
```
|
||||||
|
|
||||||
> Remember to run the above commands on each worker node: `worker-0`, `worker-1`, and `worker-2`.
|
> Remember to run the above commands on each worker node: `worker-0`, `worker-1`, and `worker-2`.
|
||||||
|
|
|
@ -11,26 +11,24 @@ Each kubeconfig requires a Kubernetes API Server to connect to. To support high
|
||||||
Generate a kubeconfig file suitable for authenticating as the `admin` user:
|
Generate a kubeconfig file suitable for authenticating as the `admin` user:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
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)')
|
||||||
|
|
||||||
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 \
|
||||||
--server=https://${KUBERNETES_PUBLIC_ADDRESS}:6443
|
--server=https://${KUBERNETES_PUBLIC_ADDRESS}:6443
|
||||||
|
|
||||||
kubectl config set-credentials admin \
|
kubectl config set-credentials admin \
|
||||||
--client-certificate=admin.pem \
|
--client-certificate=admin.pem \
|
||||||
--client-key=admin-key.pem
|
--client-key=admin-key.pem
|
||||||
|
|
||||||
kubectl config set-context kubernetes-the-hard-way \
|
kubectl config set-context kubernetes-the-hard-way \
|
||||||
--cluster=kubernetes-the-hard-way \
|
--cluster=kubernetes-the-hard-way \
|
||||||
--user=admin
|
--user=admin
|
||||||
|
|
||||||
kubectl config use-context kubernetes-the-hard-way
|
kubectl config use-context kubernetes-the-hard-way
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Verification
|
## Verification
|
||||||
|
|
|
@ -17,16 +17,14 @@ gcloud -q compute instances delete \
|
||||||
Delete the external load balancer network resources:
|
Delete the external load balancer network resources:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
gcloud -q compute forwarding-rules delete kubernetes-forwarding-rule \
|
||||||
gcloud -q compute forwarding-rules delete kubernetes-forwarding-rule \
|
|
||||||
--region $(gcloud config get-value compute/region)
|
--region $(gcloud config get-value compute/region)
|
||||||
|
|
||||||
gcloud -q compute target-pools delete kubernetes-target-pool
|
gcloud -q compute target-pools delete kubernetes-target-pool
|
||||||
|
|
||||||
gcloud -q compute http-health-checks delete kubernetes
|
gcloud -q compute http-health-checks delete kubernetes
|
||||||
|
|
||||||
gcloud -q compute addresses delete kubernetes-the-hard-way
|
gcloud -q compute addresses delete kubernetes-the-hard-way
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Delete the `kubernetes-the-hard-way` firewall rules:
|
Delete the `kubernetes-the-hard-way` firewall rules:
|
||||||
|
@ -42,14 +40,12 @@ gcloud -q compute firewall-rules delete \
|
||||||
Delete the `kubernetes-the-hard-way` network VPC:
|
Delete the `kubernetes-the-hard-way` network VPC:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
gcloud -q compute routes delete \
|
||||||
gcloud -q compute routes delete \
|
|
||||||
kubernetes-route-10-200-0-0-24 \
|
kubernetes-route-10-200-0-0-24 \
|
||||||
kubernetes-route-10-200-1-0-24 \
|
kubernetes-route-10-200-1-0-24 \
|
||||||
kubernetes-route-10-200-2-0-24
|
kubernetes-route-10-200-2-0-24
|
||||||
|
|
||||||
gcloud -q compute networks subnets delete kubernetes
|
gcloud -q compute networks subnets delete kubernetes
|
||||||
|
|
||||||
gcloud -q compute networks delete kubernetes-the-hard-way
|
gcloud -q compute networks delete kubernetes-the-hard-way
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue