gce-centos-k8s/docs/0_Environment_Setup.md
Jonny Ervine c556fbaad5 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
2020-02-19 07:40:43 +00:00

5.7 KiB

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) to automate this deployment using CentOS on GCE.

This first script 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 present that should tear down the existing configuration and delete all GCE resources which should mean billing caused by the kubernetes environment is stopped.