Automatically infer bootstrap_os (#3498)

* Automatically infer bootstrap_os

* Rename bootstrap os to os_family
This commit is contained in:
Giacomo Longo 2018-10-11 08:32:10 +02:00 committed by k8s-ci-robot
parent e813b26963
commit 3f786542d3
22 changed files with 31 additions and 43 deletions

19
Vagrantfile vendored
View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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"

View file

@ -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 %}"

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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