Bootstrap kubernetes
This commit is contained in:
parent
0a003c39b1
commit
96f213a535
2
k8s-test/.gitignore
vendored
Normal file
2
k8s-test/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
venv/
|
||||
ansible_roles/*/
|
29
k8s-test/Makefile
Normal file
29
k8s-test/Makefile
Normal file
@ -0,0 +1,29 @@
|
||||
KUBE_CONTEXT ?= kubernetes-admin@kubernetes
|
||||
|
||||
.PHONY: all
|
||||
all: cluster core
|
||||
|
||||
venv/bin/ansible:
|
||||
python3 -m venv venv
|
||||
./venv/bin/pip install ansible
|
||||
# ./venv/bin/pip install python-consul
|
||||
|
||||
.PHONY: cluster
|
||||
cluster: venv/bin/ansible
|
||||
./venv/bin/ansible-galaxy install -p ansible_roles -r ansible_roles/requirements.yml
|
||||
env ANSIBLE_ROLES_PATH=./ansible_roles ./venv/bin/ansible-playbook -K -vv \
|
||||
-i ansible_hosts.yml ./cluster-bootstrap.yml
|
||||
|
||||
.PHONY: core
|
||||
core:
|
||||
cd core && terraform init
|
||||
cd core && terraform apply -var "kube_config_context=$(KUBE_CONTEXT)"
|
||||
|
||||
.PHONY: destroy-core
|
||||
destroy-core:
|
||||
cd core && terraform destroy -var "kube_config_context=$(KUBE_CONTEXT)"
|
||||
|
||||
# Install CNI on hosts?
|
||||
# curl -L -o cni-plugins.tgz "https://github.com/containernetworking/plugins/releases/download/v1.0.0/cni-plugins-linux-$( [ $(uname -m) = aarch64 ] && echo arm64 || echo amd64)"-v1.0.0.tgz
|
||||
# sudo mkdir -p /opt/cni/bin
|
||||
# sudo tar -C /opt/cni/bin -xzf cni-plugins.tgz
|
9
k8s-test/ansible_hosts.yml
Normal file
9
k8s-test/ansible_hosts.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
all:
|
||||
children:
|
||||
servers:
|
||||
hosts:
|
||||
k0.thefij:
|
||||
kubernetes_role: "master"
|
||||
k1.thefij:
|
||||
kubernetes_role: "node"
|
7
k8s-test/ansible_roles/requirements.yml
Normal file
7
k8s-test/ansible_roles/requirements.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
- src: geerlingguy.kubernetes
|
||||
version: 7.1.1
|
||||
- src: geerlingguy.docker
|
||||
version: 4.2.2
|
||||
# - src: geerlingguy.docker_arm
|
||||
# version: 5.0.0
|
20
k8s-test/cluster-bootstrap.yml
Normal file
20
k8s-test/cluster-bootstrap.yml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Install Docker and k8s
|
||||
hosts: servers
|
||||
become: true
|
||||
|
||||
vars:
|
||||
kubernetes_allow_pods_on_master: true
|
||||
deb_arch: "{% if ansible_architecture == 'x86_64' %}amd64{% elif ansible_architecture == 'armv7l' %}armhf{% endif %}"
|
||||
docker_apt_arch: "{{ deb_arch }}"
|
||||
docker_compose_arch: "{{ (ansible_architecture == 'armv7l') | ternary('armv7', ansible_architecture) }}"
|
||||
|
||||
pre_tasks:
|
||||
- name: Verify we have an arch detected
|
||||
fail:
|
||||
msg: Could not determine architecture
|
||||
when: deb_arch|length == 0
|
||||
|
||||
roles:
|
||||
- geerlingguy.docker
|
||||
- geerlingguy.kubernetes
|
Loading…
Reference in New Issue
Block a user