This repository has been archived by the owner on Nov 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4e92db
commit e90c58b
Showing
20 changed files
with
2,623 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
2018-01-12 20:41:13,930 p=11818 u=cshort | - dashboard was created successfully | ||
2018-01-12 20:55:37,360 p=12488 u=cshort | PLAY [master] ****************************************************************************************************************************************** | ||
2018-01-12 20:55:37,594 p=12488 u=cshort | TASK [Gathering Facts] ********************************************************************************************************************************* | ||
2018-01-12 20:55:38,275 p=12488 u=cshort | fatal: [pik8s000]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to remote host \"192.168.86.200\". Make sure this host can be reached over ssh", "unreachable": true} | ||
2018-01-12 20:55:38,277 p=12488 u=cshort | PLAY RECAP ********************************************************************************************************************************************* | ||
2018-01-12 20:55:38,277 p=12488 u=cshort | pik8s000 : ok=0 changed=0 unreachable=1 failed=0 | ||
2018-01-12 20:56:12,647 p=12499 u=cshort | PLAY [master] ****************************************************************************************************************************************** | ||
2018-01-12 20:56:12,679 p=12499 u=cshort | TASK [Gathering Facts] ********************************************************************************************************************************* | ||
2018-01-12 20:56:16,837 p=12499 u=cshort | ok: [pik8s000] | ||
2018-01-12 20:56:16,846 p=12499 u=cshort | TASK [dashboard : Install k8s Dashboard] *************************************************************************************************************** | ||
2018-01-12 20:56:17,669 p=12499 u=cshort | skipping: [pik8s000] | ||
2018-01-12 20:56:17,685 p=12499 u=cshort | TASK [dashboard : Fetch kubeconfig file] *************************************************************************************************************** | ||
2018-01-12 20:56:17,726 p=12499 u=cshort | skipping: [pik8s000] | ||
2018-01-12 20:56:17,728 p=12499 u=cshort | PLAY RECAP ********************************************************************************************************************************************* | ||
2018-01-12 20:56:17,728 p=12499 u=cshort | pik8s000 : ok=1 changed=0 unreachable=0 failed=0 | ||
2018-01-12 20:56:22,187 p=12513 u=cshort | PLAY [master] ****************************************************************************************************************************************** | ||
2018-01-12 20:56:22,227 p=12513 u=cshort | TASK [dashboard : Install k8s Dashboard] *************************************************************************************************************** | ||
2018-01-12 20:56:26,578 p=12513 u=cshort | changed: [pik8s000] | ||
2018-01-12 20:56:26,589 p=12513 u=cshort | TASK [dashboard : Fetch kubeconfig file] *************************************************************************************************************** | ||
2018-01-12 20:56:27,477 p=12513 u=cshort | changed: [pik8s000] | ||
2018-01-12 20:56:27,480 p=12513 u=cshort | PLAY RECAP ********************************************************************************************************************************************* | ||
2018-01-12 20:56:27,481 p=12513 u=cshort | pik8s000 : ok=2 changed=2 unreachable=0 failed=0 | ||
2018-01-12 21:18:09,926 p=12859 u=cshort | PLAY [master] ****************************************************************************************************************************************** | ||
2018-01-12 21:18:10,022 p=12859 u=cshort | TASK [dashboard : Install k8s Dashboard] *************************************************************************************************************** | ||
2018-01-12 21:18:14,019 p=12859 u=cshort | fatal: [pik8s000]: FAILED! => {"changed": true, "cmd": "kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml", "delta": "0:00:02.639921", "end": "2018-01-12 21:18:13.930595", "msg": "non-zero return code", "rc": 1, "start": "2018-01-12 21:18:11.290674", "stderr": "Error from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": secrets \"kubernetes-dashboard-certs\" already exists\nError from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": serviceaccounts \"kubernetes-dashboard\" already exists\nError from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": roles.rbac.authorization.k8s.io \"kubernetes-dashboard-minimal\" already exists\nError from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": rolebindings.rbac.authorization.k8s.io \"kubernetes-dashboard-minimal\" already exists\nError from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": deployments.apps \"kubernetes-dashboard\" already exists\nError from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": services \"kubernetes-dashboard\" already exists", "stderr_lines": ["Error from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": secrets \"kubernetes-dashboard-certs\" already exists", "Error from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": serviceaccounts \"kubernetes-dashboard\" already exists", "Error from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": roles.rbac.authorization.k8s.io \"kubernetes-dashboard-minimal\" already exists", "Error from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": rolebindings.rbac.authorization.k8s.io \"kubernetes-dashboard-minimal\" already exists", "Error from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": deployments.apps \"kubernetes-dashboard\" already exists", "Error from server (AlreadyExists): error when creating \"https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml\": services \"kubernetes-dashboard\" already exists"], "stdout": "", "stdout_lines": []} | ||
2018-01-12 21:18:14,023 p=12859 u=cshort | PLAY RECAP ********************************************************************************************************************************************* | ||
2018-01-12 21:18:14,023 p=12859 u=cshort | pik8s000 : ok=0 changed=0 unreachable=0 failed=1 | ||
2018-01-12 21:43:56,061 p=12940 u=cshort | PLAY [master] ****************************************************************************************************************************************** | ||
2018-01-12 21:43:56,127 p=12940 u=cshort | TASK [dashboard : Install k8s Dashboard] *************************************************************************************************************** | ||
2018-01-12 21:44:02,217 p=12940 u=cshort | changed: [pik8s000] | ||
2018-01-12 21:44:02,230 p=12940 u=cshort | TASK [dashboard : Fetch kubeconfig file] *************************************************************************************************************** | ||
2018-01-12 21:44:03,028 p=12940 u=cshort | ok: [pik8s000] | ||
2018-01-12 21:44:03,031 p=12940 u=cshort | PLAY RECAP ********************************************************************************************************************************************* | ||
2018-01-12 21:44:03,032 p=12940 u=cshort | pik8s000 : ok=2 changed=1 unreachable=0 failed=0 | ||
2018-01-15 10:45:44,546 p=20275 u=cshort | PLAY [master] ****************************************************************************************************************************************** | ||
2018-01-15 10:45:44,609 p=20275 u=cshort | TASK [Gathering Facts] ********************************************************************************************************************************* | ||
2018-01-15 10:45:48,693 p=20275 u=cshort | ok: [pik8s000] | ||
2018-01-15 10:45:48,706 p=20275 u=cshort | TASK [dashboard : Install k8s Dashboard] *************************************************************************************************************** | ||
2018-01-15 10:45:53,565 p=20275 u=cshort | changed: [pik8s000] | ||
2018-01-15 10:45:53,575 p=20275 u=cshort | TASK [dashboard : Configure Dashboard Access] ********************************************************************************************************** | ||
2018-01-15 10:45:56,661 p=20275 u=cshort | changed: [pik8s000] | ||
2018-01-15 10:45:56,672 p=20275 u=cshort | TASK [dashboard : Fetch kubeconfig file] *************************************************************************************************************** | ||
2018-01-15 10:45:57,499 p=20275 u=cshort | ok: [pik8s000] | ||
2018-01-15 10:45:57,502 p=20275 u=cshort | PLAY RECAP ********************************************************************************************************************************************* | ||
2018-01-15 10:45:57,502 p=20275 u=cshort | pik8s000 : ok=4 changed=2 unreachable=0 failed=0 | ||
2018-01-15 13:52:03,596 p=21471 u=cshort | PLAY [master] ****************************************************************************************************************************************** | ||
2018-01-15 13:52:03,782 p=21471 u=cshort | TASK [dashboard : Install k8s Dashboard] *************************************************************************************************************** | ||
2018-01-15 13:52:08,530 p=21471 u=cshort | changed: [pik8s000] | ||
2018-01-15 13:52:08,540 p=21471 u=cshort | TASK [dashboard : Configure Dashboard Access] ********************************************************************************************************** | ||
2018-01-15 13:52:11,446 p=21471 u=cshort | changed: [pik8s000] | ||
2018-01-15 13:52:11,460 p=21471 u=cshort | TASK [dashboard : Fetch kubeconfig file] *************************************************************************************************************** | ||
2018-01-15 13:52:12,452 p=21471 u=cshort | ok: [pik8s000] | ||
2018-01-15 13:52:12,455 p=21471 u=cshort | PLAY RECAP ********************************************************************************************************************************************* | ||
2018-01-15 13:52:12,455 p=21471 u=cshort | pik8s000 : ok=3 changed=2 unreachable=0 failed=0 | ||
2018-01-15 13:53:07,039 p=21510 u=cshort | PLAY [master] ****************************************************************************************************************************************** | ||
2018-01-15 13:53:07,105 p=21510 u=cshort | TASK [dashboard : Install k8s Dashboard] *************************************************************************************************************** | ||
2018-01-15 13:53:10,574 p=21510 u=cshort | changed: [pik8s000] | ||
2018-01-15 13:53:10,591 p=21510 u=cshort | TASK [dashboard : Configure Dashboard Access] ********************************************************************************************************** | ||
2018-01-15 13:53:13,554 p=21510 u=cshort | changed: [pik8s000] | ||
2018-01-15 13:53:13,566 p=21510 u=cshort | TASK [dashboard : Fetch kubeconfig file] *************************************************************************************************************** | ||
2018-01-15 13:53:14,481 p=21510 u=cshort | ok: [pik8s000] | ||
2018-01-15 13:53:14,485 p=21510 u=cshort | PLAY RECAP ********************************************************************************************************************************************* | ||
2018-01-15 13:53:14,485 p=21510 u=cshort | pik8s000 : ok=3 changed=2 unreachable=0 failed=0 |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# rak8s (pronounced rackets - /ˈrækɪts/) | ||
|
||
## Stand up a Raspberry Pi based Kubernetes cluster with Ansible | ||
|
||
### Why? | ||
|
||
Because Raspberry Pis are rad, Ansible is awesome, and Kubernetes is a killer app! Also, it's cheaper than a year of GKE. | ||
|
||
### Prerequisites | ||
|
||
* Raspberry Pi 3 (3 or more) | ||
* [Raspbian Lite](https://www.raspberrypi.org/downloads/raspbian/) | ||
* Raspberry Pis should have static IPs (requirement for Kubernetes and Ansible inventory) | ||
* Ability to SSH into all Raspberry Pis and escalate privileges with sudo | ||
* The pi user is fine just change its password | ||
* [Ansible](http://docs.ansible.com/ansible/latest/intro_installation.html) 2.2 or higher | ||
|
||
### Recommendations | ||
|
||
* Since Raspbian Lite is being used it's recommended that the video memory of the Raspberry Pi 3s be set to its lowest setting (16 MB). | ||
|
||
### References & Credits | ||
|
||
These playbooks were assembled using a handful of very helpful guides: | ||
|
||
* [K8s on (vanilla) Raspbian Lite](https://gist.github.com/alexellis/fdbc90de7691a1b9edb545c17da2d975) by [Alex Ellis](https://www.alexellis.io/) | ||
* [Installing kubeadm](https://kubernetes.io/docs/setup/independent/install-kubeadm/) | ||
* [kubernetes/dashboard - Access control - Admin privileges](https://github.com/kubernetes/dashboard/wiki/Access-control#admin-privileges) | ||
* [Install using the convenience script](https://docs.docker.com/engine/installation/linux/docker-ce/debian/#install-using-the-convenience-script) | ||
|
||
A very special thanks to [**Alex Ellis**](https://www.alexellis.io/) and the [OpenFaaS](https://www.openfaas.com/) community for their assitance in answering questions and making sense of some errors. |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# http://docs.ansible.com/intro_configuration.html | ||
|
||
[defaults] | ||
callback_plugins = callback_plugins | ||
fact_caching = jsonfile | ||
fact_caching_connection = .cache/ | ||
fact_caching_timeout = 14400 | ||
force_color = 1 | ||
gathering = smart | ||
host_key_checking = False | ||
http_user_agent = ansible-agent | ||
inventory = inventory | ||
log_path = .log/ansible.log | ||
remote_user = pi | ||
retry_files_enabled = False | ||
|
||
[privilege_escalation] | ||
become = True | ||
|
||
[ssh_connection] | ||
ssh_args = -o ControlMaster=auto -o ControlPersist=60s | ||
control_path = %(directory)s/ansible-ssh-%%h-%%p-%%r | ||
control_path_dir = .cp | ||
pipelining = True |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
- hosts: all | ||
roles: | ||
- common | ||
- kubeadm | ||
|
||
- hosts: master | ||
roles: | ||
- master | ||
- dashboard | ||
|
||
- hosts: all:!master | ||
roles: | ||
- workers |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
token: udy29x.ugyyk3tumg27atmr | ||
podnet: 10.244.0.0/16 |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pik8s000 ansible_host=192.168.86.200 | ||
pik8s001 ansible_host=192.168.86.201 | ||
pik8s002 ansible_host=192.168.86.202 | ||
pik8s003 ansible_host=192.168.86.203 | ||
pik8s004 ansible_host=192.168.86.204 | ||
pik8s005 ansible_host=192.168.86.205 | ||
|
||
[master] | ||
pik8s000 |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait cgroup_enable=cpuset cgroup_enable=memory |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
# tasks file for common | ||
- name: Enabling cgroup options at boot | ||
copy: | ||
src: cmdline.txt | ||
dest: /boot/cmdline.txt | ||
owner: root | ||
group: root | ||
mode: 0755 | ||
register: cmdline | ||
tags: | ||
- boot | ||
|
||
- name: Pass bridged IPv4 traffic to iptables' chains | ||
sysctl: | ||
name: net.bridge.bridge-nf-call-iptables | ||
value: 1 | ||
state: present | ||
|
||
- name: apt-get update | ||
apt: | ||
update_cache=yes | ||
autoclean=yes | ||
autoremove=yes | ||
cache_valid_time=86400 | ||
|
||
- name: apt-get upgrade | ||
apt: | ||
upgrade=full | ||
|
||
- name: Reboot | ||
shell: sleep 2 && shutdown -r now "Ansible Reboot for /boot/cmdline.txt Change" | ||
async: 1 | ||
poll: 0 | ||
ignore_errors: True | ||
when: cmdline|changed | ||
tags: | ||
- boot | ||
- shutdown | ||
|
||
- name: Wait for Reboot | ||
local_action: wait_for | ||
args: | ||
host: "{{ inventory_hostname }}" | ||
port: 22 | ||
delay: 15 | ||
timeout: 90 | ||
become: False | ||
when: cmdline|changed | ||
tags: | ||
- boot | ||
- shutdown |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Doc: https://github.com/kubernetes/dashboard/wiki/Access-control#admin-privileges | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: kubernetes-dashboard | ||
labels: | ||
k8s-app: kubernetes-dashboard | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-admin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: kubernetes-dashboard | ||
namespace: kube-system |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
# tasks file for dashboard | ||
- name: Install k8s Dashboard | ||
shell: kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard-arm.yaml | ||
|
||
- name: Configure Dashboard Access | ||
shell: kubectl apply -f https://raw.githubusercontent.com/chris-short/pik8s/master/roles/dashboard/files/dashboard-admin.yaml | ||
|
||
- name: Fetch kubeconfig file | ||
fetch: | ||
src: /root/.kube/config | ||
dest: ~/.kube/config | ||
flat: yes |
Oops, something went wrong.