Browse Source

Automatically infer bootstrap_os (#3498)

* Automatically infer bootstrap_os

* Rename bootstrap os to os_family
pull/3505/head
Giacomo Longo 6 years ago
committed by k8s-ci-robot
parent
commit
3f786542d3
22 changed files with 31 additions and 43 deletions
  1. 19
      Vagrantfile
  2. 2
      contrib/terraform/aws/README.md
  3. 5
      contrib/terraform/openstack/README.md
  4. 1
      docs/coreos.md
  5. 6
      inventory/sample/group_vars/all/all.yml
  6. 21
      roles/bootstrap-os/tasks/main.yml
  7. 4
      roles/kubespray-defaults/defaults/main.yaml
  8. 1
      tests/files/do_ubuntu-canal-ha.yml
  9. 1
      tests/files/gce_coreos-alpha-weave-ha.yml
  10. 1
      tests/files/gce_coreos-calico-aio.yml
  11. 1
      tests/files/gce_coreos-canal.yml
  12. 1
      tests/files/gce_coreos-cilium.yml
  13. 1
      tests/files/gce_coreos-vault-upgrade.yml
  14. 1
      tests/files/gce_debian8-calico-upgrade.yml
  15. 1
      tests/files/gce_opensuse-canal.yml
  16. 1
      tests/files/gce_ubuntu-canal-ha.yml
  17. 1
      tests/files/gce_ubuntu-canal-kubeadm.yml
  18. 1
      tests/files/gce_ubuntu-flannel-sep.yml
  19. 1
      tests/files/gce_ubuntu-rkt-sep.yml
  20. 1
      tests/files/gce_ubuntu-vault-sep.yml
  21. 1
      tests/files/gce_ubuntu-weave-sep.yml
  22. 2
      tests/files/gce_ubuntu18-flannel-aio.yml

19
Vagrantfile

@ -13,15 +13,15 @@ COREOS_URL_TEMPLATE = "https://storage.googleapis.com/%s.release.core-os.net/amd
DISK_UUID = Time.now.utc.to_i
SUPPORTED_OS = {
"coreos-stable" => {box: "coreos-stable", bootstrap_os: "coreos", user: "core", box_url: COREOS_URL_TEMPLATE % ["stable"]},
"coreos-alpha" => {box: "coreos-alpha", bootstrap_os: "coreos", user: "core", box_url: COREOS_URL_TEMPLATE % ["alpha"]},
"coreos-beta" => {box: "coreos-beta", bootstrap_os: "coreos", user: "core", box_url: COREOS_URL_TEMPLATE % ["beta"]},
"ubuntu1604" => {box: "generic/ubuntu1604", bootstrap_os: "ubuntu", user: "vagrant"},
"ubuntu1804" => {box: "generic/ubuntu1804", bootstrap_os: "ubuntu", user: "vagrant"},
"centos" => {box: "centos/7", bootstrap_os: "centos", user: "vagrant"},
"fedora" => {box: "fedora/28-cloud-base", bootstrap_os: "fedora", user: "vagrant"},
"opensuse" => {box: "opensuse/openSUSE-42.3-x86_64", bootstrap_os: "opensuse", use: "vagrant"},
"opensuse-tumbleweed" => {box: "opensuse/openSUSE-Tumbleweed-x86_64", bootstrap_os: "opensuse", use: "vagrant"},
"coreos-stable" => {box: "coreos-stable", user: "core", box_url: COREOS_URL_TEMPLATE % ["stable"]},
"coreos-alpha" => {box: "coreos-alpha", user: "core", box_url: COREOS_URL_TEMPLATE % ["alpha"]},
"coreos-beta" => {box: "coreos-beta", user: "core", box_url: COREOS_URL_TEMPLATE % ["beta"]},
"ubuntu1604" => {box: "generic/ubuntu1604", user: "vagrant"},
"ubuntu1804" => {box: "generic/ubuntu1804", user: "vagrant"},
"centos" => {box: "centos/7", user: "vagrant"},
"fedora" => {box: "fedora/28-cloud-base", user: "vagrant"},
"opensuse" => {box: "opensuse/openSUSE-42.3-x86_64", use: "vagrant"},
"opensuse-tumbleweed" => {box: "opensuse/openSUSE-Tumbleweed-x86_64", use: "vagrant"},
}
# Defaults for config options defined in CONFIG
@ -138,7 +138,6 @@ Vagrant.configure("2") do |config|
ip = "#{$subnet}.#{i+100}"
host_vars[vm_name] = {
"ip": ip,
"bootstrap_os": SUPPORTED_OS[$os][:bootstrap_os],
"local_release_dir" => $local_release_dir,
"download_run_once": "False",
"kube_network_plugin": $network_plugin

2
contrib/terraform/aws/README.md

@ -43,7 +43,7 @@ ssh -F ./ssh-bastion.conf user@$ip
Example (this one assumes you are using CoreOS)
```commandline
ansible-playbook -i ./inventory/hosts ./cluster.yml -e ansible_user=core -e bootstrap_os=coreos -b --become-user=root --flush-cache
ansible-playbook -i ./inventory/hosts ./cluster.yml -e ansible_user=core -b --become-user=root --flush-cache
```
***Using other distrib than CoreOs***
If you want to use another distribution than CoreOS, you can modify the search filters of the 'data "aws_ami" "distro"' in variables.tf.

5
contrib/terraform/openstack/README.md

@ -341,11 +341,6 @@ If it fails try to connect manually via SSH. It could be something as simple as
### Configure cluster variables
Edit `inventory/$CLUSTER/group_vars/all.yml`:
- Set variable **bootstrap_os** appropriately for your desired image:
```
# Valid bootstrap options (required): ubuntu, coreos, centos, none
bootstrap_os: coreos
```
- **bin_dir**:
```
# Directory where the binaries will be installed

1
docs/coreos.md

@ -6,7 +6,6 @@ Example with Ansible:
Before running the cluster playbook you must satisfy the following requirements:
General CoreOS Pre-Installation Notes:
- You should set the bootstrap_os variable to `coreos`
- Ensure that the bin_dir is set to `/opt/bin`
- ansible_python_interpreter should be `/opt/bin/python`. This will be laid down by the bootstrap task.
- The default resolvconf_mode setting of `docker_dns` **does not** work for CoreOS. This is because we do not edit the systemd service file for docker on CoreOS nodes. Instead, just use the `host_resolvconf` mode. It should work out of the box.

6
inventory/sample/group_vars/all/all.yml

@ -1,9 +1,3 @@
## Valid bootstrap options (required): ubuntu, coreos, centos, none
## If the OS is not listed here, it means it doesn't require extra/bootstrap steps.
## In example, python is not available on 'coreos' so it must be installed before
## anything else. In the opposite, Debian has already all its dependencies fullfiled, then bootstrap_os should be set to `none`.
bootstrap_os: none
## Directory where etcd data stored
etcd_data_dir: /var/lib/etcd

21
roles/bootstrap-os/tasks/main.yml

@ -1,4 +1,25 @@
---
- name: Fetch /etc/os-release
raw: cat /etc/os-release
register: os_release
changed_when: false
- name: Set bootstrap_os
set_fact:
os_family: >-
{%- if 'Ubuntu' in os_release.stdout -%}
ubuntu
{%- elif 'Debian' in os_release.stdout -%}
debian
{%- elif 'CoreOS' in os_release.stdout -%}
coreos
{%- elif 'Fedora' in os_release.stdout -%}
fedora
{%- elif 'CentOS' in os_release.stdout -%}
centos
{%- elif 'OpenSUSE' in os_release.stdout -%}
opensuse
{% endif %}
- include_tasks: bootstrap-ubuntu.yml
when: os_family == "ubuntu"

4
roles/kubespray-defaults/defaults/main.yaml

@ -1,8 +1,4 @@
---
## Required for bootstrap-os/preinstall/download roles and setting facts
# Valid bootstrap options (required): ubuntu, coreos, centos, none
bootstrap_os: none
# Use proxycommand if bastion host is in group all
# This change obseletes editing ansible.cfg file depending on bastion existance
ansible_ssh_common_args: "{% if 'bastion' in groups['all'] %} -o ProxyCommand='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -W %h:%p {{ hostvars['bastion']['ansible_user'] }}@{{ hostvars['bastion']['ansible_host'] }} {% if ansible_ssh_private_key_file is defined %}-i {{ ansible_ssh_private_key_file }}{% endif %} ' {% endif %}"

1
tests/files/do_ubuntu-canal-ha.yml

@ -3,7 +3,6 @@ cloud_region: nyc3
mode: ha
# Deployment settings
bootstrap_os: ubuntu
kube_network_plugin: canal
deploy_netchecker: true
kubedns_min_replicas: 1

1
tests/files/gce_coreos-alpha-weave-ha.yml

@ -7,7 +7,6 @@ startup_script: 'systemctl disable locksmithd && systemctl stop locksmithd'
# Deployment settings
kube_network_plugin: weave
bootstrap_os: coreos
resolvconf_mode: host_resolvconf # this is required as long as the coreos stable channel uses docker < 1.12
deploy_netchecker: true
kubedns_min_replicas: 1

1
tests/files/gce_coreos-calico-aio.yml

@ -8,7 +8,6 @@ startup_script: 'systemctl disable locksmithd && systemctl stop locksmithd'
# Deployment settings
no_group_vars: true
bootstrap_os: coreos
kube_network_plugin: calico
resolvconf_mode: host_resolvconf # this is required as long as the coreos stable channel uses docker < 1.12
deploy_netchecker: true

1
tests/files/gce_coreos-canal.yml

@ -6,7 +6,6 @@ startup_script: 'systemctl disable locksmithd && systemctl stop locksmithd'
# Deployment settings
kube_network_plugin: canal
bootstrap_os: coreos
resolvconf_mode: host_resolvconf # this is required as long as the coreos stable channel uses docker < 1.12
deploy_netchecker: true
kubedns_min_replicas: 1

1
tests/files/gce_coreos-cilium.yml

@ -6,7 +6,6 @@ startup_script: 'systemctl disable locksmithd && systemctl stop locksmithd'
# Deployment settings
kube_network_plugin: cilium
bootstrap_os: coreos
resolvconf_mode: host_resolvconf # this is required as long as the coreos stable channel uses docker < 1.12
deploy_netchecker: true
enable_network_policy: true

1
tests/files/gce_coreos-vault-upgrade.yml

@ -5,7 +5,6 @@ cloud_region: us-central1-b
mode: aio
# Instance settings
bootstrap_os: coreos
cert_management: vault
kube_network_plugin: flannel
deploy_netchecker: true

1
tests/files/gce_debian8-calico-upgrade.yml

@ -5,7 +5,6 @@ mode: default
# Deployment settings
kube_network_plugin: calico
bootstrap_os: debian
deploy_netchecker: true
kubedns_min_replicas: 1
cloud_provider: gce

1
tests/files/gce_opensuse-canal.yml

@ -4,7 +4,6 @@ cloud_region: us-central1-c
mode: default
# Deployment settings
bootstrap_os: opensuse
kube_network_plugin: canal
deploy_netchecker: true
kubedns_min_replicas: 1

1
tests/files/gce_ubuntu-canal-ha.yml

@ -4,7 +4,6 @@ cloud_region: us-central1-c
mode: ha
# Deployment settings
bootstrap_os: ubuntu
kube_network_plugin: canal
deploy_netchecker: true
kubedns_min_replicas: 1

1
tests/files/gce_ubuntu-canal-kubeadm.yml

@ -5,7 +5,6 @@ cloud_region: us-central1-c
mode: ha
# Deployment settings
bootstrap_os: ubuntu
kube_network_plugin: canal
kubeadm_enabled: true
dynamic_kubelet_configuration: true

1
tests/files/gce_ubuntu-flannel-sep.yml

@ -4,7 +4,6 @@ cloud_region: us-central1-a
mode: separate
# Deployment settings
bootstrap_os: ubuntu
kube_network_plugin: flannel
deploy_netchecker: true
kubedns_min_replicas: 1

1
tests/files/gce_ubuntu-rkt-sep.yml

@ -4,7 +4,6 @@ cloud_region: us-central1-c
mode: separate
# Deployment settings
bootstrap_os: ubuntu
kube_network_plugin: flannel
etcd_deployment: rkt
kubelet_deployment: rkt

1
tests/files/gce_ubuntu-vault-sep.yml

@ -5,7 +5,6 @@ cloud_region: us-central1-b
mode: separate
# Instance settings
bootstrap_os: ubuntu
cert_management: vault
kube_network_plugin: canal
deploy_netchecker: true

1
tests/files/gce_ubuntu-weave-sep.yml

@ -4,7 +4,6 @@ cloud_region: us-central1-c
mode: separate
# Deployment settings
bootstrap_os: ubuntu
kube_network_plugin: weave
deploy_netchecker: true
kubedns_min_replicas: 1

2
tests/files/gce_ubuntu18-flannel-aio.yml

@ -5,8 +5,6 @@ cloud_machine_type: "n1-standard-1"
mode: aio
# Deployment settings
kubeadm_enabled: false
bootstrap_os: ubuntu
kube_network_plugin: flannel
dynamic_kubelet_configuration: true
deploy_netchecker: true

Loading…
Cancel
Save