-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix insecure registries length check and add docs * Add the following roles: - helm - metallb - healthcheck Add task to download admin.conf from master to ansible controller * Revert hosts.ini to upstream
- Loading branch information
Showing
14 changed files
with
325 additions
and
5 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
[kube-cluster:children] | ||
master | ||
node | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
--- | ||
|
||
- name: Install Docker container engine | ||
include_tasks: pkg.yml | ||
|
||
|
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 @@ | ||
--- | ||
- name: "Create tmp directory" | ||
file: | ||
path: "{{ tmp_dir }}" | ||
state: directory | ||
mode: 0755 | ||
tags: healthcheck | ||
|
||
- name: "Create checkout directory" | ||
file: | ||
path: "{{ tmp_dir }}/healthcheck" | ||
state: directory | ||
mode: 0755 | ||
tags: healthcheck | ||
|
||
- name: "Clone git repo" | ||
git: | ||
repo: "{{ healthcheck_git_url }}" | ||
dest: "{{ tmp_dir }}/healthcheck" | ||
tags: healthcheck | ||
|
||
- name: "Install Healthcheck" | ||
shell: "kubectl apply -f {{ tmp_dir }}/healthcheck/kubernetes/" | ||
tags: healthcheck | ||
|
||
- name: "Clean-up" | ||
file: | ||
path: "{{ tmp_dir }}" | ||
state: absent | ||
ignore_errors: yes | ||
tags: healthcheck |
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 @@ | ||
--- | ||
healthcheck_git_url: https://github.com/emrekenci/k8s-healthcheck.git |
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,18 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: tiller | ||
namespace: kube-system | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: tiller | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-admin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: tiller | ||
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,53 @@ | ||
--- | ||
- name: "Create tmp directory" | ||
file: | ||
path: "{{ tmp_dir }}" | ||
state: directory | ||
mode: 0755 | ||
tags: helm | ||
|
||
- name: "Check if Helm is installed" | ||
shell: command -v helm >/dev/null 2>&1 | ||
register: helm_exists | ||
ignore_errors: yes | ||
tags: helm | ||
|
||
- name: "Install Helm" | ||
block: | ||
- name: "Get Helm installer" | ||
get_url: | ||
url: https://raw.githubusercontent.com/helm/helm/master/scripts/get | ||
dest: "{{ tmp_dir }}/get_helm.sh" | ||
mode: 0755 | ||
|
||
- name: "Run the installer" | ||
shell: "{{ tmp_dir }}/get_helm.sh" | ||
|
||
when: helm_exists.rc > 0 | ||
tags: helm | ||
|
||
- name: "Copy yaml file" | ||
copy: | ||
src: "rbac-config.yml" | ||
dest: "{{ tmp_dir }}/rbac-config.yml" | ||
mode: 0644 | ||
tags: helm | ||
|
||
- name: "RBAC configuration" | ||
shell: "kubectl apply -f {{ tmp_dir }}/rbac-config.yml" | ||
tags: helm | ||
|
||
- name: "Init Helm" | ||
shell: "helm init --service-account tiller" | ||
tags: helm | ||
|
||
- name: "Update Helm repo" | ||
shell: "helm repo update" | ||
tags: helm | ||
|
||
- name: "Clean-up" | ||
file: | ||
path: "{{ tmp_dir }}" | ||
state: absent | ||
ignore_errors: yes | ||
tags: helm |
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
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,28 @@ | ||
--- | ||
- name: "Create tmp directory" | ||
file: | ||
path: "{{ tmp_dir }}" | ||
state: directory | ||
mode: 0755 | ||
tags: metallb | ||
|
||
- name: "Install MetalLB" | ||
shell: "kubectl apply -f {{ metallb_yaml_url }}" | ||
tags: metallb | ||
|
||
- name: "Create configmap file" | ||
template: | ||
src: metallb-layer-2-config.yml.j2 | ||
dest: "{{ tmp_dir }}/metallb-layer-2-config.yml" | ||
tags: metallb | ||
|
||
- name: "Create MetalLB configmap in kubernetes" | ||
shell: "kubectl apply -f {{ tmp_dir }}/metallb-layer-2-config.yml" | ||
tags: metallb | ||
|
||
- name: "Clean-up" | ||
file: | ||
path: "{{ tmp_dir }}" | ||
state: absent | ||
ignore_errors: yes | ||
tags: metallb |
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,12 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
namespace: metallb-system | ||
name: config | ||
data: | ||
config: | | ||
address-pools: | ||
- name: metallb-ip-space | ||
protocol: layer2 | ||
addresses: | ||
- {{ metallb_address_space }} |
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,4 @@ | ||
--- | ||
metallb_version: v0.7.3 | ||
metallb_yaml_url: "https://raw.githubusercontent.com/google/metallb/{{ metallb_version }}/manifests/metallb.yaml" | ||
metallb_address_space: 192.168.205.200-192.168.205.210 |
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
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,89 @@ | ||
servers = [ | ||
{ | ||
:name => "k8s-nxt-head-1", | ||
:type => "master", | ||
:box => "ubuntu/xenial64", | ||
:box_version => "20180831.0.0", | ||
:eth1 => "192.168.205.16", | ||
:mem => "4096", | ||
:cpu => "2" | ||
}, | ||
{ | ||
:name => "k8s-nxt-node-1", | ||
:type => "node", | ||
:box => "ubuntu/xenial64", | ||
:box_version => "20180831.0.0", | ||
:eth1 => "192.168.205.17", | ||
:mem => "4096", | ||
:cpu => "2" | ||
}, | ||
{ | ||
:name => "k8s-nxt-node-2", | ||
:type => "node", | ||
:box => "ubuntu/xenial64", | ||
:box_version => "20180831.0.0", | ||
:eth1 => "192.168.205.18", | ||
:mem => "4096", | ||
:cpu => "2" | ||
} | ||
] | ||
|
||
# This script to install k8s using kubeadm will get executed after a box is provisioned | ||
$configureBox = <<-SCRIPT | ||
# install docker v17.03 | ||
# reason for not using docker provision is that it always installs latest version of the docker, but kubeadm requires 17.03 or older | ||
apt-get update | ||
apt-get install -y apt-transport-https ca-certificates curl software-properties-common | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | ||
add-apt-repository "deb https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" | ||
apt-get update && apt-get install -y docker-ce=$(apt-cache madison docker-ce | grep 17.03 | head -1 | awk '{print $3}') | ||
# run docker commands as vagrant user (sudo not required) | ||
usermod -aG docker vagrant | ||
# install kubeadm | ||
apt-get install -y apt-transport-https curl | ||
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | ||
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list | ||
deb http://apt.kubernetes.io/ kubernetes-xenial main | ||
EOF | ||
apt-get update | ||
apt-get install -y kubelet kubeadm kubectl | ||
apt-mark hold kubelet kubeadm kubectl | ||
# kubelet requires swap off | ||
swapoff -a | ||
# keep swap off after reboot | ||
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab | ||
# ip of this box | ||
IP_ADDR=`ifconfig enp0s8 | grep Mask | awk '{print $2}'| cut -f2 -d:` | ||
# set node-ip | ||
sudo sed -i "/^[^#]*KUBELET_EXTRA_ARGS=/c\KUBELET_EXTRA_ARGS=--node-ip=$IP_ADDR" /etc/default/kubelet | ||
sudo systemctl restart kubelet | ||
sudo cp /tmp/authorized_keys_root /root/.ssh/authorized_keys | ||
SCRIPT | ||
|
||
Vagrant.configure("2") do |config| | ||
|
||
servers.each do |opts| | ||
config.vm.define opts[:name] do |config| | ||
|
||
config.vm.box = opts[:box] | ||
config.vm.box_version = opts[:box_version] | ||
config.vm.hostname = opts[:name] | ||
config.vm.network :private_network, ip: opts[:eth1] | ||
config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "/tmp/authorized_keys_root" | ||
|
||
config.vm.provider "virtualbox" do |v| | ||
|
||
v.name = opts[:name] | ||
v.customize ["modifyvm", :id, "--groups", "/k8s_nxt"] | ||
v.customize ["modifyvm", :id, "--memory", opts[:mem]] | ||
v.customize ["modifyvm", :id, "--cpus", opts[:cpu]] | ||
|
||
end | ||
|
||
config.vm.provision "shell", inline: $configureBox | ||
|
||
end | ||
|
||
end | ||
|
||
end |