new file: 10_delete_kube-dns.sh
new file: 11_delete_all.sh new file: 12_uninstall_etcd.sh new file: 3_install_configure_kubernetes.sh new file: 5.1_worker_kubelet_setup.sh new file: 5.2_worker_kube-proxy_setup.sh new file: 5_worker_node_setup.sh new file: 6_client_admin_config.sh new file: 7_pod_routing.sh new file: 8_deploying_kube-dns.sh new file: 9_further_tests.sh new file: certs-dir/admin-csr.json new file: certs-dir/admin-key.pem new file: certs-dir/admin.csr new file: certs-dir/admin.kubeconfig new file: certs-dir/admin.pem new file: certs-dir/ca-config.json new file: certs-dir/ca-csr.json new file: certs-dir/ca-key.pem new file: certs-dir/ca.csr new file: certs-dir/ca.pem new file: certs-dir/encryption-config.yaml new file: certs-dir/kube-controller-manager-csr.json new file: certs-dir/kube-controller-manager-key.pem new file: certs-dir/kube-controller-manager.csr new file: certs-dir/kube-controller-manager.kubeconfig new file: certs-dir/kube-controller-manager.pem new file: certs-dir/kube-proxy-csr.json new file: certs-dir/kube-proxy-key.pem new file: certs-dir/kube-proxy.csr new file: certs-dir/kube-proxy.kubeconfig new file: certs-dir/kube-proxy.pem new file: certs-dir/kube-scheduler-csr.json new file: certs-dir/kube-scheduler-key.pem new file: certs-dir/kube-scheduler.csr new file: certs-dir/kube-scheduler.kubeconfig new file: certs-dir/kube-scheduler.pem new file: certs-dir/kubernetes-csr.json new file: certs-dir/kubernetes-key.pem new file: certs-dir/kubernetes.csr new file: certs-dir/kubernetes.pem new file: certs-dir/service-account-csr.json new file: certs-dir/service-account-key.pem new file: certs-dir/service-account.csr new file: certs-dir/service-account.pem new file: certs-dir/worker-0-csr.json new file: certs-dir/worker-0-key.pem new file: certs-dir/worker-0.csr new file: certs-dir/worker-0.kubeconfig new file: certs-dir/worker-0.pem new file: certs-dir/worker-1-csr.json new file: certs-dir/worker-1-key.pem new file: certs-dir/worker-1.csr new file: certs-dir/worker-1.kubeconfig new file: certs-dir/worker-1.pem new file: cni/bridge new file: cni/cni-plugins-amd64-v0.6.0.tgz new file: cni/dhcp new file: cni/flannel new file: cni/host-local new file: cni/ipvlan new file: cni/loopback new file: cni/macvlan new file: cni/portmap new file: cni/ptp new file: cni/sample new file: cni/tuning new file: cni/vlan new file: controller-0/apiserver new file: controller-0/config new file: controller-0/controller-manager new file: controller-0/etcd.conf new file: controller-0/etcd.service new file: controller-0/kube-apiserver.service new file: controller-0/kube-apiserver_rbac.yaml new file: controller-0/kube-controller-manager.service new file: controller-0/kube-scheduler.service new file: controller-0/kube-scheduler.yaml new file: controller-0/kubernetes.default.svc.cluster.local.conf new file: controller-0/kubernetes.repo new file: controller-0/rbac_authorizations.yaml new file: controller-0/scheduler new file: controller-1/apiserver new file: controller-1/config new file: controller-1/controller-manager new file: controller-1/etcd.conf new file: controller-1/etcd.service new file: controller-1/kube-apiserver.service new file: controller-1/kube-apiserver_rbac.yaml new file: controller-1/kube-controller-manager.service new file: controller-1/kube-scheduler.service new file: controller-1/kube-scheduler.yaml new file: controller-1/kubernetes.default.svc.cluster.local.conf new file: controller-1/kubernetes.repo new file: controller-1/rbac_authorizations.yaml new file: controller-1/scheduler new file: controller_manager_setup.sh new file: controller_setup.sh new file: controller_uninstall.sh new file: controllers new file: ctrl-mgr_vars new file: docs/0_Environment_Setup.md new file: docs/10_Create_kube-proxy_Instances.md new file: docs/11_Create_client_kubectl_admin.md new file: docs/12_Create_Pod_Routing_Rules.md new file: docs/13_Create_kube-dns_instances.md new file: docs/14_Additional_Functional_Tests.md new file: docs/15_Delete_kube-dns_Deployment.md new file: docs/16_Uninstall_etcd.md new file: docs/17_Uninstall_Everything.md new file: docs/1_GCloud_Resource_Setup.md new file: docs/2_Certificate_and_Authentication_Creation.md new file: docs/3_Install_and_Configure_etcd.md new file: docs/4_Install_and_Configure_apiserver.md new file: docs/5_Install_and_Configure_Controller_Manager.md new file: docs/6_Install_and_Configure_Scheduler.md new file: docs/7_Create_nginx_Health_Monitor.md new file: docs/8_Create_Load_Balancer.md new file: docs/9a_Create_Kubernetes_Workers_with_Docker.md new file: docs/9b_Create_Kubernetes_Workers_with_containerd.md new file: etcd-listen new file: etcd_setup.sh new file: etcd_vars new file: instance new file: kube-apiserver_setup.sh.orig new file: kube-dns.yaml new file: notes new file: old_stuff/cni/bridge new file: old_stuff/cni/cni-plugins-amd64-v0.6.0.tgz new file: old_stuff/cni/dhcp new file: old_stuff/cni/flannel new file: old_stuff/cni/host-local new file: old_stuff/cni/ipvlan new file: old_stuff/cni/loopback new file: old_stuff/cni/macvlan new file: old_stuff/cni/portmap new file: old_stuff/cni/ptp new file: old_stuff/cni/sample new file: old_stuff/cni/tuning new file: old_stuff/cni/vlan new file: old_stuff/controller-0/apiserver new file: old_stuff/controller-0/config new file: old_stuff/controller-0/controller-manager new file: old_stuff/controller-0/etcd.conf new file: old_stuff/controller-0/etcd.service new file: old_stuff/controller-0/kube-apiserver.service new file: old_stuff/controller-0/kube-apiserver_rbac.yaml new file: old_stuff/controller-0/kube-controller-manager.service new file: old_stuff/controller-0/kube-scheduler.service new file: old_stuff/controller-0/kube-scheduler.yaml new file: old_stuff/controller-0/kubernetes.default.svc.cluster.local.conf new file: old_stuff/controller-0/kubernetes.repo new file: old_stuff/controller-0/rbac_authorizations.yaml new file: old_stuff/controller-0/scheduler new file: old_stuff/controller-1/apiserver new file: old_stuff/controller-1/config new file: old_stuff/controller-1/controller-manager new file: old_stuff/controller-1/etcd.conf new file: old_stuff/controller-1/etcd.service new file: old_stuff/controller-1/kube-apiserver.service new file: old_stuff/controller-1/kube-apiserver_rbac.yaml new file: old_stuff/controller-1/kube-controller-manager.service new file: old_stuff/controller-1/kube-scheduler.service new file: old_stuff/controller-1/kube-scheduler.yaml new file: old_stuff/controller-1/kubernetes.default.svc.cluster.local.conf new file: old_stuff/controller-1/kubernetes.repo new file: old_stuff/controller-1/rbac_authorizations.yaml new file: old_stuff/controller-1/scheduler new file: old_stuff/controllers new file: scheduler_setup.sh new file: scripts/.gce_kubernetes.config new file: scripts/.variables new file: scripts/.worker_variables_0 new file: scripts/.worker_variables_1 new file: scripts/0_env_setup.sh new file: scripts/10_worker_kube-proxy_setup.sh new file: scripts/11_client_kubectl_admin_setup.sh new file: scripts/12_setup_pod_routing.sh new file: scripts/13_setup_core-dns.sh new file: scripts/13_setup_kube-dns.sh new file: scripts/14_additional_functional_tests.sh new file: scripts/14b_additional_functional_tests.sh new file: scripts/15_delete_kube-dns_pod.sh new file: scripts/16_uninstall_etcd.sh new file: scripts/17_uninstall_everything.sh new file: scripts/1_client_side_gcloud_setup.sh new file: scripts/2_cert_and_auth_create.sh new file: scripts/3_install_configure_etcd.sh new file: scripts/4_install_configure_apiserver.sh new file: scripts/5_install_configure_controller_manager.sh new file: scripts/6_install_configure_scheduler.sh new file: scripts/7_nginx_health_monitor_setup.sh new file: scripts/8_create_load_balancer.sh new file: scripts/9a_worker_kubelet_via_docker_setup.sh new file: scripts/9b_worker_kubelet_via_containerd_setup.sh new file: scripts/controller-files/kube-apiserver_rbac.yaml new file: scripts/controller-files/kubernetes.default.svc.cluster.local.conf new file: scripts/controller-files/rbac_authorizations.yaml new file: scripts/controller_manager_setup.sh new file: scripts/controller_manager_setup.sh.template new file: scripts/core-dns.yaml new file: scripts/ctrl-mgr_vars new file: scripts/etcd_setup.sh new file: scripts/etcd_vars new file: scripts/gvisor_tests.sh new file: scripts/instance new file: scripts/kube-apiserver_setup.sh new file: scripts/kube-apiserver_setup.sh.template new file: scripts/kube-dns.yaml new file: scripts/kube-dns.yaml.1 new file: scripts/kube-dns.yaml.2 new file: scripts/kube-dns.yaml.3 new file: scripts/nginx_health_monitor_setup.sh new file: scripts/scheduler_setup.sh new file: scripts/scheduler_setup.sh.template new file: scripts/untrusted.yaml new file: scripts/worker_kube-proxy_setup.sh new file: scripts/worker_kube-proxy_setup.sh.template new file: scripts/worker_kubelet_containerd_setup.sh.template new file: scripts/worker_kubelet_setup.sh new file: scripts/worker_kubelet_setup.sh.template new file: test.sh new file: test2 new file: u3_uninstall_kubernetes_controllers.sh new file: worker-0/10-bridge.conf new file: worker-0/99-loopback.conf new file: worker-0/config new file: worker-0/kube-proxy-config.yaml new file: worker-0/kube-proxy.service new file: worker-0/kubelet new file: worker-0/kubelet-config.yaml new file: worker-0/kubelet.service new file: worker-0/proxy new file: worker-1/10-bridge.conf new file: worker-1/99-loopback.conf new file: worker-1/config new file: worker-1/kube-proxy-config.yaml new file: worker-1/kube-proxy.service new file: worker-1/kubelet new file: worker-1/kubelet-config.yaml new file: worker-1/kubelet.service new file: worker-1/proxy new file: worker_kube-proxy_setup.sh new file: worker_kube-proxy_setup.sh.template new file: worker_kubelet_setup.sh new file: worker_setup.sh Initial commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
### Setting up Kubernetes on CentOS on GCE ###
|
||||
|
||||
Google Cloud provides US$300 of free credit for one year when first signing up for Google Cloud. This credit can be used to demonstrate Kubernetes running on CentOS and provide a great learning playground at no cost. I have written a series of scripts (heavily inspired/copied from [Kubernetes: The Hard Way by Kelsey Hightower](https://github.com/kelseyhightower/kubernetes-the-hard-way)) to automate this deployment using CentOS on GCE.
|
||||
|
||||
This [first script](https://gogs.ervine.org/jonny/gce-centos-kubernetes/src/master/scripts/0_env_setup.sh) is used to collect details that will be used to set up the Kubernetes environment on the GCE Cloud. A series of questions will be asked and the responses saved to a config file for later use.
|
||||
|
||||
**You must have logged into the Google Cloud via the SDK for this whole process to work correctly.**
|
||||
|
||||
The information you're asked for is as follows:
|
||||
|
||||
- Google Compute Region to use. This can be any Google Compute Region - obviously if it is geographically closer to you, the response should be faster (or of lower latency). Nothing that is performed in this set of scripts/exercises requires the region to be nearby though, and the US regions tend to be the lowest cost options on the Google Cloud. As such, the default region to use is US-West-1 (us-west-1)
|
||||
|
||||
- Google Compute Zone to use. This will depend upon the region chosen previously. No error checking is performed, so you will need to be certain that you choose a valid zone for the previously selected region. If the zone does not exist in the region, then the later scripts will simply fail. Again, a default is chosen based on the lowest cost option, and is set to US West1 C (us-west1-c)
|
||||
|
||||
- Google Compute Project to use. The scripts will not create a new project, so you should have a project already created on the Google Cloud Console. You will need to provide the unique name of the project here.
|
||||
|
||||
- Kubernetes version to use (tested with 1.10.2, 1.10.3, 1.10.5, and 1.10.6 - 1.10.6 is the default. 1.11.x have not been tested and might work)
|
||||
|
||||
- The scripts will create a new network (VPC) to operate on. This needs to be given a name. The default is set to kubernetes (avoid using underscores in Google Cloud object names).
|
||||
|
||||
- Within this network a subnet for the Kubernetes nodes and masters must be created, and also given a name. The default is set to kubernetes-subnet.
|
||||
|
||||
- A public IP address will be created for the Kubernetes cluster, and will also have a name. The default is set to kube-public-ip.
|
||||
|
||||
- The Kubernetes subnet should have a CIDR network address associated to it. This is the address range that the masters and nodes will share and communicate over. By default (and in most Kubernetes examples) this is set to 10.240.0.0/24. You can change this if you want - however there should be no compelling reason to.
|
||||
|
||||
- The script will then attempt to calculate the network part of the CIDR address entered previously. If using the default values, this should be 10.240.0 - if you are using your own network address values, you need to ensure that this is set correctly.
|
||||
|
||||
- The CIDR network address used by the Kubernetes pods is set next. This is the network range used by the containers running in the pods. This should be a separate network address space to that used by the nodes and masters. By default, this is set to 10.200.0.0/16. The overall address space is set to use a Class B pool, with each Kubernetes node using a Class C sub-division of this space. e.g. 10.200.0.0/16 is the overall network, and node1 will use 10.200.1.0/24 for the pods hosted on node1.
|
||||
|
||||
- Again, the script attempts to calculate the network part of the address specified, and should default to 10.200 - if using your own values, ensure this is set correctly.
|
||||
|
||||
- The script will also attempt to calculate the address space prefix (netmask) to be used for the nodes. Given the defaults above, the prefix would be set to 24.
|
||||
|
||||
- A firewall rule will be created to allow traffic to flow between nodes internally. This firewall rule requires a name. The default is set to kubernetes-allow-internal.
|
||||
|
||||
- A second firewall rule to allow traffic from the external (Internet) network must be created to allow traffic such as SSH, Kubernetes, and HTTP. This rule name is set by default to kubernetes-allow-external
|
||||
|
||||
- The script will then ask how many master nodes in the Kubernetes the user wants to create. The default is set to 2 (to demonstrate a multi-master configuration). The more nodes created, the more expensive the cluster will be.
|
||||
|
||||
- Finally, the number of worker nodes is required. As per the master nodes, the default is set to 2, but this can be increased. More nodes will be more expensive.
|
||||
|
||||
The environment script saves these variables in a file named .gce_kubernetes.config for use in subsequent scripts.
|
||||
|
||||
The script is set up to use Google Compute Engine g1-small instances which have few resources. The resulting Kubernetes cluster will not be able to host many containers, but should be able to demonstrate small deployments. The instance size can be increased or the number of nodes can be increased (both at increased cost). It would be possible to prompt for this setting as well in a future version.
|
||||
|
||||
Subsequent scripts are then used to create the Kubernetes controller and worker nodes useing the information previously supplied. Sticking to the default values should just work. The final script should perform a series of tests to validate that the kubernetes cluster is functional and accessible.
|
||||
|
||||
There is a [final script](https://gogs.ervine.org/jonny/gce-centos-kubernetes/src/master/scripts/17_uninstall_everything.sh) present that should tear down the existing configuration and delete all GCE resources which should mean billing caused by the kubernetes environment is stopped.
|
||||
@@ -0,0 +1,8 @@
|
||||
This script installs kube-proxy on the nodes designated as worker nodes.
|
||||
|
||||
The script creates a kube-proxy installation script from a template - prefilling the clusterCIDR address from the environment variables prior to copying.
|
||||
|
||||
The script then copies the kube-proxy setup script to each worker node, and then executes via sudo the script on each node. This is done serially - could potentially be with just one loop though.
|
||||
|
||||
The kube-proxy systemd service script is created and filled with the correct configuration parameters. The configuration is filled and then systemctl reloaded. The kube-proxy binary is downloaded and the service is started and enabled.
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
This script creates an admin.kubeconfig file to use with kubectl to interact and administer the kubernetes cluster.
|
||||
|
||||
The directory is changed to the directory where the cryptographic material was created, and any existing admin.kubeconfig file is deleted.
|
||||
|
||||
The script then populates the admin.kubeconfig file with information from the environment variables and from the GCE environment.
|
||||
|
||||
A final test is then run to use the new admin.kubeconfig file to verify that it is working as expected. Output similar to the below should be observed:
|
||||
|
||||
NAME STATUS MESSAGE ERROR
|
||||
scheduler Healthy ok
|
||||
controller-manager Healthy ok
|
||||
etcd-0 Healthy {"health": "true"}
|
||||
etcd-1 Healthy {"health": "true"}
|
||||
|
||||
NAME STATUS ROLES AGE VERSION
|
||||
worker-0 Ready <none> 27m v1.10.3
|
||||
worker-1 Ready <none> 26m v1.10.3
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
The next step is create the pod routing rules to allow pods to communicate with one another.
|
||||
|
||||
These rules are set up on the Google Compute Engine - and use values from the environment variables specified at the start.
|
||||
|
||||
This should be very straightforward, and a summary of the rules created should be printed when the script finishes, which should look similar to:
|
||||
|
||||
NAME NETWORK DEST_RANGE NEXT_HOP PRIORITY
|
||||
default-route-00c2371bebacb414 kubernetes 10.240.0.0/24 kubernetes 1000
|
||||
default-route-13b1fd44c0bcabff kubernetes 0.0.0.0/0 default-internet-gateway 1000
|
||||
kubernetes-pod-route-worker-0 kubernetes 10.200.0.0/24 10.240.0.20 1000
|
||||
kubernetes-pod-route-worker-1 kubernetes 10.200.1.0/24 10.240.0.21 1000
|
||||
@@ -0,0 +1,9 @@
|
||||
The next step downloads and runs the kube-dns pods to ensure that name resolution services can be provided to pods. The yaml description for kube-dns is taken directly from Kelsey Hightower's examples, however kube-dns is a fairly common deployment, so there should be plenty of alternative exampels if required. The example from Kubernetes the Hard Way is used here because I have earlier set the clusterDNS IP address to a value that is also set in the kube-dns yaml file from the Kelsey Hightower source.
|
||||
|
||||
Once the kube-dns pods have been deployed a test busybox pod is deployed and DNS services are tested by performing a lookup against the kubernetes service, which should return a name/IP adress pair.
|
||||
|
||||
Server: 10.32.0.10
|
||||
Address 1: 10.32.0.10 kube-dns.kube-system.svc.cluster.local
|
||||
|
||||
Name: kubernetes
|
||||
Address 1: 10.32.0.1 kubernetes.default.svc.cluster.local
|
||||
@@ -0,0 +1,23 @@
|
||||
This is the final set of functional tests.
|
||||
|
||||
Test One:
|
||||
Confirming the encryption of data at rest using the encryption key that was created earlier in the exercises.
|
||||
A kubernetes secret is created from the command line, and then the contents of the stored secret (in etcd) are checked. If all is working correctly, the secret contents should be encrypted, and this is confirmed by finding the encryption header in etcd output:
|
||||
|
||||
Prefix should be: k8s:enc:aescbc:v1:key1
|
||||
|
||||
|
||||
Test Two:
|
||||
NGINX Deployment
|
||||
A single pod nginx deployment is created and is then made available to the client workstation be using the kubectl port-forward function. This exposes the nginx port 80 to the local client on port 8080 and can be tested via a web browser or a utulity like curl or wget.
|
||||
|
||||
Test Three:
|
||||
The logs from the nginx pod are diplayed on the screen using the kubectl command.
|
||||
|
||||
Test Four:
|
||||
A command is executed inside the running pod - the version of nginx is displayed through the nginx -v command.
|
||||
|
||||
Test Five:
|
||||
The nginx instance is exposed via a NodePort service and a firewall rule created to allow the outside world to communicate with the exposed service. Note to self: Shouldn't this be exposed through the GCE load balancer rather than a NodePort?
|
||||
|
||||
Future: Add in the untrusted workload via gVisor ... needs runsc installed on the worker nodes.
|
||||
@@ -0,0 +1 @@
|
||||
This script was written as a clean up for the kube-dns pod/deployment only. This allows you to roll back the kube-dns deployment.
|
||||
@@ -0,0 +1,3 @@
|
||||
This script should clean up and remove the etcd instances from the controller nodes.
|
||||
|
||||
Useful for cleaning up servers without actually deleting them.
|
||||
@@ -0,0 +1 @@
|
||||
This is the complete clean up script and should delete all the cloud resources that have been previously set up. This should mean no further billing is performed. The script will also clean up local resources that were created, so that if the scripts are re-run, new resources are created for the new environment being used.
|
||||
@@ -0,0 +1,13 @@
|
||||
This script will create the Google Cloud resources used by our Kubernetes project.
|
||||
|
||||
First off, the variables created by answering the environment set up script are read.
|
||||
|
||||
The network, subnet, and firewall rules are created. The script should print out the firewall rules when these commands complete - however it can take a bit of time after creating a firewall rule for it to show in the firewall rule list.
|
||||
|
||||
A public IP address is then created.
|
||||
|
||||
The Kubernetes Master node instances are then created. These instances use a 200GB boot disk (this could probably be reduced) and will be assigned to the Kubernetes subnet CIDR created in the environment set up script (default was 10.240.0.0/24). The script will create the controller instances with IP addresses of 10.240.0.1X where X is the instance number. If you chose to have 9 controllers, the you woulc have IP addresses: 10.240.0.10 through to 10.240.0.18. The script has been tested with up to 9 controllers. 11 and more would then take IP addresses to 10.240.0.110 and beyond, which should work, but hasn't been tested.
|
||||
|
||||
Similarly, the worker nodes are created next. They have a similar set up as the master nodes and are added to the same network. By default, they will use IP addresses of type 10.240.0.2X where X is the instance number. The same limits as that for the master nodes applies. They also have the pod CIDR network address for that node added as metadata to each instance.
|
||||
|
||||
Once the instances are created, they are then updated via a looped yum update command. The more instances being created, the longer this will take.
|
||||
@@ -0,0 +1,36 @@
|
||||
This script will automate the creation of the PKI material, kubeconfigs, and other authentication files for the Kubernetes cluster.
|
||||
|
||||
We start by downloading the CloudFlare SSL utilities. The PKI cryptographic material can be created using many different utilities (openssl, easy-rsa etc.), however the cfssl tools were used by Kelsey Hightower, and have been used in many other tutorials as well.
|
||||
|
||||
This script will create a directory called certs-dir into which all the other output files will be saved.
|
||||
|
||||
The first file created is the self-signed Certificate Authority. If you have your own CA you want to use, you'll need to perform this step manually, making sure you create all the necessary files. This CA will be used to sign all subsequent PKI files listed below. [Files created: ca-config.json ca.csr ca-csr.json ca-key.pem ca.pem]
|
||||
|
||||
Key material is then created for the 'admin' user of our Kubernetes cluster.[Files created: admin.csr admin-csr.json admin-key.pem admin.pem]
|
||||
|
||||
Client certificates are created for each worker node [Files created: worker-X.csr worker-X-csr.json worker-X-key.pem worker-X.pem] (where X is the instance number of the worker node) NOTE: THIS IS USING A HARDCODED VALUE OF 2 FOR THE WORKER NODES. THIS NEEDS TO BE UPDATED TO CALCULATE THE NUMBER OF WORKER NODES.
|
||||
|
||||
The Kubernetes controller manager certificate and key are created next. [Files created: kube-controller-manager.csr kube-controller-manager-csr.json kube-controller-manager-key.pem kube-controller-manager.pem]
|
||||
|
||||
The Kubernetes Proxy certificate and key are created next. [Files created: kube-proxy.xsr kube-proxy-csr.json kube-proxy-key.pem kube-proxy.pem]
|
||||
|
||||
The Kubernetes Scheduler certificate and key are then created. [Files created: kube-scheduler.csr kube-scheduler-csr.json kube-scheduler-key.pem kube-scheduler.pem]
|
||||
|
||||
The Kubernets API Server certificate and key are created next. [Files created: kubernetes.csr kubernetes-csr.json kubernetes-key.pem kubernetes.pem] NOTE: THIS IS USING HARDCODED IP ADDRESSES AND IS ONLY SET FOR 2 MASTER NODES. THIS NEEDS TO BE UPDATED TO CALCULATE THE MASTER NODE ADDRESSES CORRECTLY
|
||||
|
||||
The service account certificate and key are then created. [Files created: service-account.xsr service-account-csr.json service-account-key.pem service-account.pem]
|
||||
|
||||
The client kubeconfig authentication files are created for each worker node. [Files created: worker-X.kubeconfig] (where X is the instance number of the worker node) NOTE:
|
||||
THIS IS USING A HARDCODED VALUE OF 2 FOR THE WORKER NODES. THIS NEEDS TO BE UPDATED TO CALCULATE THE NUMBER OF WORKER NODES.
|
||||
|
||||
The Kubernetes Proxy kubeconfig file is created next. [Files created: kube-proxy.kubeconfig]
|
||||
|
||||
The Kubernetes Controller Manager kubeconfig is created next. [Files created: kube-controller-manager.kubeconfig]
|
||||
|
||||
The Kubernetes Scheduler kubeconfig is created next. [Files created: kube-scheduler.kubeconfig]
|
||||
|
||||
The admin user kubeconfig file is then created. [Files created: admin.kubeconfig]
|
||||
|
||||
The relevant key material files are then copied to the worker nodes and master nodes as required.
|
||||
|
||||
Finally, a data encryption key is created and copied to the master nodes.
|
||||
@@ -0,0 +1,16 @@
|
||||
This script ets up the etcd daemon on the master nodes. It starts by copying across a script etcd_setup.sh to each master node and then executing it on the master node. This script performs the following functions. A .variables file is also copied across to each controller, which contains instance specific variables created from the environment details created during the first step. These variables are the number of master nodes in the cluster, and the kubernetes cluster subnet address.
|
||||
|
||||
NOTE: The following steps run on each controller node serially (i.e. one after another)
|
||||
The Kubernetes yum repository is set up, and docker, etcd, and kubectl are installed. The docker daemon is started and enabled at this point.
|
||||
|
||||
SELinux is set to permissive mode - this is bad practice ... and at a later date I'll look to create policies that allow SELinux to remain enabled.
|
||||
|
||||
The key material for etcd is then copied to the /etc/etcd/ directory.
|
||||
|
||||
The /etc/etcd/etcd.conf file is then updated to include the correct details for the Kubernetes cluster. Some of this is simply filled in with local environment parameters (e.g. hostname or local IP address). The ETCD_INITIAL_CLUSTER parameter must include all the IP addresses of the members of the etcd cluster. This is why we must pass the number of master nodes in the cluster as a variable to each master node.
|
||||
|
||||
The etcd package from the EPEL repository doesn't automatically enable most of the settings we require. Having updated the /etc/etcd/etcd.conf file, the /etc/systemd/system/etcd.service file is created with the correct startup parameters enabled that we need.
|
||||
|
||||
The /var/lib/etcd/default.etcd directory (if it exists) is removed so that when we start etcd it is using the brand new configuration we've created.
|
||||
|
||||
The etcd daemon is then started and enabled - after performing a systemctl daemon-reload. A final check is performed to ensure that the etcd member nodes are working. This will only be correct on the final master node as this installation runs serially on the master nodes.
|
||||
@@ -0,0 +1,15 @@
|
||||
This script sets up the API server on the master nodes. To prepare for this, we pass the Kubernetes subnet and number of master nodes into a variable file and copy this to each master node. A separate kube-apiserver_setup.sh script is copied across to each controller and executed on each controller in a serial order.
|
||||
|
||||
The kube-apiserver_setup.sh script performs the following actions:
|
||||
|
||||
A string variable containing the addresses of the etcd servers is generated from the variabels passed earlier. This will be used in a later configuration file.
|
||||
|
||||
The kube-apiserver binary is downloaded from the upstream project and copied to /usr/local/bin - currently this uses 1.10.3. It should be trivial to update this to use 1.10.4 and 1.10.5. Updating to 1.11.0 will require further work.
|
||||
|
||||
The required cryptographic material is copied to a newly created directory /var/lib/kubernetes
|
||||
|
||||
A new /etc/systemd/system/kube-apiserver.service file is created and will read it's configuration from files created later.
|
||||
|
||||
The /etc/kubernetes/apiserver configuration file is then populated with the necessary data - this will use the etcd server address string generated earlier.
|
||||
|
||||
The kube-apiserver is then started and enabled, after systemctl daemon-reload has been run (to load in the new kube-apiserver.service file)
|
||||
@@ -0,0 +1,13 @@
|
||||
The Kubernetes Controller Manager service is installed and configured by this script. The CIDR used by the pods needs to be passed to each master. As such a variable file and controller_manager_setup.sh file are copied to each master node.
|
||||
|
||||
The controller_manager_setup.sh script will perform the following actions on each master node in a serial order:
|
||||
|
||||
Download the kube-controller-manager binary from the upstream Kubernetes release and copy to /usr/local/bin
|
||||
|
||||
The kube-controller-manager.kubeconfig file is copied to the /var/lib/kubernetes directory to allow the controller-manager to authenticate to Kubernetes.
|
||||
|
||||
A new /etc/systemd/system/kube-controller-manager.service file is created to enable the Controller Manager service.
|
||||
|
||||
The /etc/kubernetes/controller-manager configuration file is filled with the necessary configuration data (this includes the pod CIDR taken from the environment variables passed to each controller).
|
||||
|
||||
The kube-controller-manager daemon is then started and enabled, after systemctl daemon-reload has been run.
|
||||
@@ -0,0 +1,13 @@
|
||||
The Kubernetes scheduler setup script file copies across a setup script to each master node, and then runs this script in a serial order. The scheduler_setup.sh script file perofrms the following actions:
|
||||
|
||||
The Kubernetes scheduler binary is downloaded from the upstream project and copied to /usr/local/bin
|
||||
|
||||
The /etc/kubernetes/kube-scheduler.yaml file is created with the correct data, which will be used in the start up parameters for the scheduler daemon.
|
||||
|
||||
The scheduler.kubeconfig file is moved to the /var/lib/kubernetes directory.
|
||||
|
||||
A new /etc/systemd/system/kube-scheduler.service file is created with the expected startup parameters. These parameters include the kube-scheduler.yaml file listed above.
|
||||
|
||||
The /etc/kubernetes/scheduler file is created and populated next.
|
||||
|
||||
Finally, the kube-scheduler daemon is started and enabled, after systemctl daemon-reload is executed.
|
||||
@@ -0,0 +1,11 @@
|
||||
This script will create the nginx based health monitor that will expose the Kubernetes API server HTTPS endpoint via HTTP which can then be used by the Google Cloud Load Balancer (which only supports HTTP based health checks and not HTTPS based health checks)
|
||||
|
||||
Two RABC yaml files are copied to each master node, as well as the nginx reverse proxy configuration file, and a script to set up the nginx daemon on each master node. The setup script, named nginx_health_monitor_setup.sh performs the following actions:
|
||||
|
||||
The nginx package installed, and the health monitor configuration file copied to the correct location.
|
||||
|
||||
The nginx daemon is then enabled and started.
|
||||
|
||||
The Kubernetes component statuses are checked, and the nginx instance is tested to make sure it is working as well.
|
||||
|
||||
The RBAC yaml files are then applied to the Kubernetes cluster.
|
||||
@@ -0,0 +1,13 @@
|
||||
This script sets up the load balancer on the Google Cloud.
|
||||
|
||||
The script reads environment variables so that it knows how many instances are to be serving the load balancer.
|
||||
|
||||
The script first creates the HTTP based health check that checks the nginx endpoint created previously.
|
||||
|
||||
A firewall rule is created to allow the HTTP health check to work.
|
||||
|
||||
A target pool is created and then populated with the master node instances.
|
||||
|
||||
A forwarding rule is then created so that traffic to the public address is passed to the target pool.
|
||||
|
||||
A connection check is made from the local machine (i.e. outside of the Google Cloud) to the Kubernetes public address.
|
||||
@@ -0,0 +1,18 @@
|
||||
There are two versions of this script - one to use docker, which is 9a, and the other to use containerd, which is 9b.
|
||||
|
||||
The 9a (docker) variant does not setup the untrusted runtime environment using runsc and gVisor. However, docker is easier and more straightforward to deploy on CentOS via yum.
|
||||
|
||||
This script installs Kubernetes on the nodes designated as worker nodes.
|
||||
|
||||
The script reads the KUBE_POD_ADDR (this is pod specific) and KUBE_NODE_POD_PREFIX environment variables and copies these to each workder node.
|
||||
|
||||
The script then copies the kubelet setup script to each worker node, and then executes via sudo the script on each node.
|
||||
|
||||
The node setup script installs and enables docker on each node, and then installs kubelet from the Kubernetes repository. Currently this is installing 1.10.3 - action item for the future is to use an updated version, or make the version configurable via an environment variable.
|
||||
|
||||
The container networking configuraation is provided in /etc/cni - this uses the variables previously copied across.
|
||||
|
||||
The kubelet is downloaded and the correct configuration applied from the environment variables.
|
||||
|
||||
The kubelet service is then enabled and started.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
This script installs Kubernetes on the nodes designated as worker nodes.
|
||||
|
||||
The script reads the KUBE_POD_ADDR (this is pod specific) and KUBE_NODE_POD_PREFIX environment variables and copies these to each workder node.
|
||||
|
||||
The script then copies the kubelet setup script to each worker node, and then executes via sudo the script on each node.
|
||||
|
||||
The node setup script installs and enables docker on each node, and then installs kubelet from the Kubernetes repository. Currently this is installing 1.10.3 - action item for the future is to use an updated version, or make the version configurable via an environment variable.
|
||||
|
||||
The container networking configuraation is provided in /etc/cni - this uses the variables previously copied across.
|
||||
|
||||
The kubelet is downloaded and the correct configuration applied from the environment variables.
|
||||
|
||||
The kubelet service is then enabled and started.
|
||||
|
||||
Reference in New Issue
Block a user