This repository has been archived by the owner on Apr 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1444 from ingvagabund/refactor-kubernetes-roles
Automatic merge from submit-queue Refactor kubernetes roles Continuing effort [1] of cleaning roles for kubernetes, master and node roles. TODO: - [x] clean ``kubernetes`` role - [x] move ``download_bins.yml`` under ``node`` and ``master`` and enable installation of downloaded binaries for Fedora, CentOS and other OSes. - [x] extend the installation options with installation of distribution rpm (not just the latest) - [x] clean and refactor ``node`` role - [x] clean and refactor ``master`` role - [x] introduce ``deploy-master.yml`` and ``deploy-node.yml`` playbooks, include them in the top level playbook - [x] tag relevant tasks and introduce new scripts - [x] move CPU and Memory accounting under node role (inside ``kubelet-configuration.yml``) Some items of the TODO (new playbooks, new scripts) can be resolved only once the #967 is merged. [1] #1298
- Loading branch information
Showing
61 changed files
with
859 additions
and
282 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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
--- | ||
|
||
- name: Setup etcd | ||
- name: Deploy etcd | ||
hosts: etcd | ||
sudo: yes | ||
roles: | ||
|
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 @@ | ||
--- | ||
- name: Deploy master | ||
hosts: masters | ||
become: yes | ||
roles: | ||
- master | ||
tags: | ||
- masters | ||
|
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 @@ | ||
--- | ||
- name: Deploy node | ||
hosts: nodes | ||
become: yes | ||
roles: | ||
- node | ||
tags: | ||
- nodes | ||
|
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 was deleted.
Oops, something went wrong.
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,9 @@ | ||
--- | ||
- name: Create kubernetes config directory | ||
file: path={{ kube_config_dir }} state=directory | ||
|
||
- name: Write the global config file | ||
template: src=config.j2 dest={{ kube_config_dir }}/config | ||
notify: | ||
- restart daemons | ||
|
This file was deleted.
Oops, something went wrong.
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,40 +1,17 @@ | ||
--- | ||
- include: fedora.yml | ||
when: ansible_distribution == "Fedora" | ||
- name: Fedora | Remove docker window manager on F20 | ||
yum: pkg=docker state=absent | ||
when: ansible_distribution == "Fedora" and ansible_distribution_major_version == "20" | ||
tags: install | ||
|
||
- name: Update {{ kube_script_dir }} if this is atomic | ||
set_fact: | ||
kube_script_dir: "/usr/local/libexec/kubernetes" | ||
when: is_atomic and kube_script_dir == "/usr/libexec/kubernetes" | ||
- name: Override kubernetes facts | ||
include: override_facts.yml | ||
|
||
- name: Initialize the python_bin fact | ||
set_fact: | ||
python_bin: "python" | ||
|
||
- name: Update facts if this is CoreOS or Ubuntu 14.04 | ||
set_fact: | ||
bin_dir: "/opt/bin" | ||
kube_script_dir: "/opt/bin/kubernetes" | ||
python_bin: "/opt/bin/python" | ||
when: is_coreos or ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int < 15 | ||
|
||
- name: Create kubernetes config directory | ||
file: path={{ kube_config_dir }} state=directory | ||
|
||
- name: Create kubernetes script directory | ||
file: path={{ kube_script_dir }} state=directory | ||
|
||
- name: Create bin dir | ||
file: path={{ bin_dir }} state=directory | ||
|
||
- name: write the global config file | ||
template: src=config.j2 dest={{ kube_config_dir }}/config | ||
notify: | ||
- restart daemons | ||
|
||
- include: download_bins.yml | ||
when: is_coreos or ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int < 15 | ||
- name: Configure kubernetes | ||
include: configure.yml | ||
tags: configure | ||
|
||
- include: secrets.yml | ||
tags: | ||
secrets | ||
tags: configure |
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,17 @@ | ||
--- | ||
- name: Update {{ kube_script_dir }} if this is atomic | ||
set_fact: | ||
kube_script_dir: "/usr/local/libexec/kubernetes" | ||
when: is_atomic and kube_script_dir == "/usr/libexec/kubernetes" | ||
|
||
- name: Initialize the python_bin fact | ||
set_fact: | ||
python_bin: "python" | ||
|
||
- name: Update facts if this is CoreOS or Ubuntu 14.04 | ||
set_fact: | ||
bin_dir: "/opt/bin" | ||
kube_script_dir: "/opt/bin/kubernetes" | ||
python_bin: "/opt/bin/python" | ||
when: is_coreos or ansible_distribution == 'Ubuntu' and ansible_distribution_major_version|int < 15 | ||
|
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
- name: Write the config file for the api server | ||
template: src=apiserver.j2 dest={{ kube_config_dir }}/apiserver | ||
|
||
- name: Ensure that a token auth file exists (addons may populate it) | ||
file: path={{ kube_token_dir }}/known_tokens.csv state=touch | ||
changed_when: false | ||
|
||
- name: Add cap_net_bind_service to kube-apiserver | ||
capabilities: path=/usr/bin/kube-apiserver capability=cap_net_bind_service=ep state=present | ||
when: kube_source_type != "github-release" and not is_atomic and not is_coreos and not ansible_distribution == 'Ubuntu' and not ansible_distribution_major_version|int < 15 | ||
|
||
- name: Setting the apiserver_modified fact to true | ||
set_fact: | ||
apiserver_modified: 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,4 @@ | ||
--- | ||
- name: Restart apiserver | ||
service: name=kube-apiserver state=restarted | ||
|
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,8 @@ | ||
--- | ||
- name: Enable apiserver | ||
service: name=kube-apiserver enabled=yes | ||
when: services_enabled == true | ||
|
||
- name: Start apiserver | ||
service: name=kube-apiserver state=started | ||
register: apiserver_started |
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,17 @@ | ||
--- | ||
- name: Get the master token values | ||
slurp: | ||
src: "{{ kube_token_dir }}/{{ item }}-{{ inventory_hostname }}.token" | ||
with_items: | ||
- "system:controller_manager" | ||
- "system:scheduler" | ||
- "system:kubectl" | ||
register: tokens | ||
delegate_to: "{{ groups['masters'][0] }}" | ||
|
||
- name: Set token facts | ||
set_fact: | ||
controller_manager_token: "{{ tokens.results[0].content|b64decode }}" | ||
scheduler_token: "{{ tokens.results[1].content|b64decode }}" | ||
kubectl_token: "{{ tokens.results[2].content|b64decode }}" | ||
|
11 changes: 11 additions & 0 deletions
11
ansible/roles/master/tasks/controller-manager-configure.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,11 @@ | ||
--- | ||
- name: Write the config file for the controller-manager | ||
template: src=controller-manager.j2 dest={{ kube_config_dir }}/controller-manager | ||
|
||
- name: Write the kubecfg (auth) file for controller-manager | ||
template: src=controller-manager.kubeconfig.j2 dest={{ kube_config_dir }}/controller-manager.kubeconfig | ||
|
||
- name: Setting the controller_manager_modified fact to true | ||
set_fact: | ||
controller_manager_modified: 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,4 @@ | ||
--- | ||
- name: Restart controller-manager | ||
service: name=kube-controller-manager state=restarted | ||
|
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,8 @@ | ||
--- | ||
- name: Enable controller-manager | ||
service: name=kube-controller-manager enabled=yes | ||
when: services_enabled == true | ||
|
||
- name: Start controller-manager | ||
service: name=kube-controller-manager state=started | ||
register: controller_manager_started |
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
Oops, something went wrong.