Last active
May 4, 2022 19:27
-
-
Save mjhea0/b08ed217144ad307085a05450f3ac6be to your computer and use it in GitHub Desktop.
Revisions
-
mjhea0 revised this gist
Aug 20, 2018 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -149,14 +149,12 @@ server-f2-base-node-jqbii9.novalocal Ready <none> 5m v1.11.1 server-f2-base-node-jr3695.novalocal Ready master 19m v1.11.1 ``` Configure the dashboard: ```sh $ kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml $ kubectl describe services kubernetes-dashboard --namespace=kube-system $ kubectl proxy --address 0.0.0.0 --port 8001 --accept-hosts='^*$' ``` Test at [http://192.168.16.179:8001/healthz/ping](http://192.168.16.179:8001/healthz/ping) -
mjhea0 revised this gist
Aug 9, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ This setup uses 3 machines: ## All Machines The following commands need to be run on all machines. ### Configure /etc/hosts @@ -86,7 +86,7 @@ $ systemctl start docker.service ## Master Setup The following commands need to be run on the master. ### Init Kubernetes @@ -114,7 +114,7 @@ $ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Docum ## Worker(s) Setup The following commands need to be run on the worker machines. ### Init Kubernetes -
mjhea0 created this gist
Aug 7, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,162 @@ # Install a 3-Node Kubernetes Cluster on Centos 7 This setup uses 3 machines: 1. Centos7 1. 100GB HDD 1. 32 GB RAM 1. 8 CPU ## All Machines The following commands need to be ran on all machines. ### Configure /etc/hosts Update */etc/hosts* so that each machine can ping one other using the hostname: ``` 192.168.16.179 kubemaster 192.168.16.168 kube2 192.168.16.182 kube3 ``` > Be sure to update the IP addresses! ### Disable SELinux This allows the Kubernetes cluster to communicate. ```sh $ setenforce 0 $ sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux ``` ### Disable Swap https://github.com/kubernetes/kubernetes/issues/53533 ```sh $ swapoff -a ``` ### Install Docker ```sh $ yum install -y yum-utils device-mapper-persistent-data lvm2 $ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo $ yum install -y docker-ce ``` ### Install Kubernetes Add the repository info for yum in */etc/yum.repos.d/kubernetes.repo*: ``` [kubernetes] name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg ``` Install Kubernetes: ```sh $ yum install -y kubelet kubeadm kubectl ``` Add Kubernetes to the `cgroupfs` group: ``` $ sed -i 's/cgroup-driver=systemd/cgroup-driver=cgroupfs/g' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf ``` Restart systemd daemon and kubelet: ```sh $ systemctl daemon-reload $ systemctl restart kubelet $ systemctl enable kubelet.service $ systemctl start docker.service ``` ## Master Setup The following commands need to be ran on the master. ### Init Kubernetes Initialize the Kubernetes cluster, making sure to update `apiserver-advertise-address`: ```sh $ kubeadm init --apiserver-advertise-address=192.168.16.179 --pod-network-cidr=192.168.1.0/16 ``` This could take a few minutes to complete. Once done, take note of the `token` and `discovery-token`. Set up the Kubernetes Config: ```sh $ mkdir -p $HOME/.kube $ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config $ sudo chown $(id -u):$(id -g) $HOME/.kube/config ``` Deploy flannel network to the cluster: ```sh $ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml ``` ## Worker(s) Setup The following commands need to be ran on the worker machines. ### Init Kubernetes Join the worker to the cluster, making sure to replace `TOKEN` and `DISCOVERY_TOKEN`: ```sh $ kubeadm join 192.168.1.99:6443 --token TOKEN --discovery-token-ca-cert-hash DISCOVERY_TOKEN ``` Set up the Kubernetes Config: ```sh $ mkdir -p $HOME/.kube $ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config $ sudo chown $(id -u):$(id -g) $HOME/.kube/config ``` ## Master Back on the master, let's verify the Kubernetes install. ### Sanity Check Are the nodes reachable? ```sh $ kubectl get nodes NAME STATUS ROLES AGE VERSION server-f2-base-node-2a0h8a.novalocal Ready <none> 5m v1.11.1 server-f2-base-node-jqbii9.novalocal Ready <none> 5m v1.11.1 server-f2-base-node-jr3695.novalocal Ready master 19m v1.11.1 ``` Spin up a quick web app: ```sh $ kubectl create namespace sock-shop $ kubectl apply -n sock-shop -f "https://github.com/microservices-demo/microservices-demo/blob/master/deploy/kubernetes/complete-demo.yaml?raw=true" $ kubectl -n sock-shop get svc front-end $ kubectl get pods --namespace=sock-shop $ kubectl proxy --address 0.0.0.0 --port 8001 --accept-hosts='^*$' & ``` Test at [http://192.168.16.179:8001/healthz/ping](http://192.168.16.179:8001/healthz/ping)