Merge pull request #1045 from bradbeam/vsphere
Adding vsphere cloud provider support
This commit is contained in:
commit
85596c2610
8 changed files with 72 additions and 28 deletions
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
## There are some changes specific to the cloud providers
|
## There are some changes specific to the cloud providers
|
||||||
## for instance we need to encapsulate packets with some network plugins
|
## for instance we need to encapsulate packets with some network plugins
|
||||||
## If set the possible values are either 'gce', 'aws', 'azure' or 'openstack'
|
## If set the possible values are either 'gce', 'aws', 'azure', 'openstack', or 'vsphere'
|
||||||
## When openstack is used make sure to source in the openstack credentials
|
## When openstack is used make sure to source in the openstack credentials
|
||||||
## like you would do when using nova-client before starting the playbook.
|
## like you would do when using nova-client before starting the playbook.
|
||||||
#cloud_provider:
|
#cloud_provider:
|
||||||
|
|
|
@ -52,7 +52,7 @@ spec:
|
||||||
{% endif %}
|
{% endif %}
|
||||||
- --v={{ kube_log_level }}
|
- --v={{ kube_log_level }}
|
||||||
- --allow-privileged=true
|
- --allow-privileged=true
|
||||||
{% if cloud_provider is defined and cloud_provider in ["openstack", "azure"] %}
|
{% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere"] %}
|
||||||
- --cloud-provider={{ cloud_provider }}
|
- --cloud-provider={{ cloud_provider }}
|
||||||
- --cloud-config={{ kube_config_dir }}/cloud_config
|
- --cloud-config={{ kube_config_dir }}/cloud_config
|
||||||
{% elif cloud_provider is defined and cloud_provider == "aws" %}
|
{% elif cloud_provider is defined and cloud_provider == "aws" %}
|
||||||
|
|
|
@ -32,7 +32,7 @@ spec:
|
||||||
- --node-monitor-period={{ kube_controller_node_monitor_period }}
|
- --node-monitor-period={{ kube_controller_node_monitor_period }}
|
||||||
- --pod-eviction-timeout={{ kube_controller_pod_eviction_timeout }}
|
- --pod-eviction-timeout={{ kube_controller_pod_eviction_timeout }}
|
||||||
- --v={{ kube_log_level }}
|
- --v={{ kube_log_level }}
|
||||||
{% if cloud_provider is defined and cloud_provider in ["openstack", "azure"] %}
|
{% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere"] %}
|
||||||
- --cloud-provider={{cloud_provider}}
|
- --cloud-provider={{cloud_provider}}
|
||||||
- --cloud-config={{ kube_config_dir }}/cloud_config
|
- --cloud-config={{ kube_config_dir }}/cloud_config
|
||||||
{% elif cloud_provider is defined and cloud_provider == "aws" %}
|
{% elif cloud_provider is defined and cloud_provider == "aws" %}
|
||||||
|
@ -54,7 +54,7 @@ spec:
|
||||||
- mountPath: {{ kube_cert_dir }}
|
- mountPath: {{ kube_cert_dir }}
|
||||||
name: ssl-certs-kubernetes
|
name: ssl-certs-kubernetes
|
||||||
readOnly: true
|
readOnly: true
|
||||||
{% if cloud_provider is defined and cloud_provider in ["openstack", "azure"] %}
|
{% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere" ] %}
|
||||||
- mountPath: {{ kube_config_dir }}/cloud_config
|
- mountPath: {{ kube_config_dir }}/cloud_config
|
||||||
name: cloudconfig
|
name: cloudconfig
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
@ -63,7 +63,7 @@ spec:
|
||||||
- hostPath:
|
- hostPath:
|
||||||
path: {{ kube_cert_dir }}
|
path: {{ kube_cert_dir }}
|
||||||
name: ssl-certs-kubernetes
|
name: ssl-certs-kubernetes
|
||||||
{% if cloud_provider is defined and cloud_provider in ["openstack", "azure"] %}
|
{% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere"] %}
|
||||||
- hostPath:
|
- hostPath:
|
||||||
path: {{ kube_config_dir }}/cloud_config
|
path: {{ kube_config_dir }}/cloud_config
|
||||||
name: cloudconfig
|
name: cloudconfig
|
||||||
|
|
|
@ -42,7 +42,7 @@ KUBELET_NETWORK_PLUGIN="--hairpin-mode=promiscuous-bridge --network-plugin=kuben
|
||||||
{% endif %}
|
{% endif %}
|
||||||
# Should this cluster be allowed to run privileged docker containers
|
# Should this cluster be allowed to run privileged docker containers
|
||||||
KUBE_ALLOW_PRIV="--allow-privileged=true"
|
KUBE_ALLOW_PRIV="--allow-privileged=true"
|
||||||
{% if cloud_provider is defined and cloud_provider in ["openstack", "azure"] %}
|
{% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere"] %}
|
||||||
KUBELET_CLOUDPROVIDER="--cloud-provider={{ cloud_provider }} --cloud-config={{ kube_config_dir }}/cloud_config"
|
KUBELET_CLOUDPROVIDER="--cloud-provider={{ cloud_provider }} --cloud-config={{ kube_config_dir }}/cloud_config"
|
||||||
{% elif cloud_provider is defined and cloud_provider == "aws" %}
|
{% elif cloud_provider is defined and cloud_provider == "aws" %}
|
||||||
KUBELET_CLOUDPROVIDER="--cloud-provider={{ cloud_provider }}"
|
KUBELET_CLOUDPROVIDER="--cloud-provider={{ cloud_provider }}"
|
||||||
|
|
|
@ -29,6 +29,22 @@ openstack_password: "{{ lookup('env','OS_PASSWORD') }}"
|
||||||
openstack_region: "{{ lookup('env','OS_REGION_NAME') }}"
|
openstack_region: "{{ lookup('env','OS_REGION_NAME') }}"
|
||||||
openstack_tenant_id: "{{ lookup('env','OS_TENANT_ID')|default(lookup('env','OS_PROJECT_ID'),true) }}"
|
openstack_tenant_id: "{{ lookup('env','OS_TENANT_ID')|default(lookup('env','OS_PROJECT_ID'),true) }}"
|
||||||
|
|
||||||
|
# For the vsphere integration, kubelet will need credentials to access
|
||||||
|
# vsphere apis
|
||||||
|
# Documentation regarting these values can be found
|
||||||
|
# https://github.com/kubernetes/kubernetes/blob/master/pkg/cloudprovider/providers/vsphere/vsphere.go#L105
|
||||||
|
vsphere_vcenter_ip: "{{ lookup('env', 'VSPHERE_VCENTER') }}"
|
||||||
|
vsphere_vcenter_port: "{{ lookup('env', 'VSPHERE_VCENTER_PORT') }}"
|
||||||
|
vsphere_user: "{{ lookup('env', 'VSPHERE_USER') }}"
|
||||||
|
vsphere_password: "{{ lookup('env', 'VSPHERE_PASSWORD') }}"
|
||||||
|
vsphere_datacenter: "{{ lookup('env', 'VSPHERE_DATACENTER') }}"
|
||||||
|
vsphere_datastore: "{{ lookup('env', 'VSPHERE_DATASTORE') }}"
|
||||||
|
vsphere_working_dir: "{{ lookup('env', 'VSPHERE_WORKING_DIR') }}"
|
||||||
|
vsphere_insecure: "{{ lookup('env', 'VSPHERE_INSECURE') }}"
|
||||||
|
vsphere_scsi_controller_type: pvscsi
|
||||||
|
# vsphere_public_network is name of the network the VMs are joined to
|
||||||
|
vsphere_public_network: "{{ lookup('env', 'VSPHERE_PUBLIC_NETWORK')|default('') }}"
|
||||||
|
|
||||||
# Container Linux by CoreOS cloud init config file to define /etc/resolv.conf content
|
# Container Linux by CoreOS cloud init config file to define /etc/resolv.conf content
|
||||||
# for hostnet pods and infra needs
|
# for hostnet pods and infra needs
|
||||||
resolveconf_cloud_init_conf: /etc/resolveconf_cloud_init.conf
|
resolveconf_cloud_init_conf: /etc/resolveconf_cloud_init.conf
|
||||||
|
|
|
@ -64,17 +64,13 @@
|
||||||
|
|
||||||
- name: check cloud_provider value
|
- name: check cloud_provider value
|
||||||
fail:
|
fail:
|
||||||
msg: "If set the 'cloud_provider' var must be set either to 'generic', 'gce', 'aws', 'azure' or 'openstack'"
|
msg: "If set the 'cloud_provider' var must be set either to 'generic', 'gce', 'aws', 'azure', 'openstack' or 'vsphere'"
|
||||||
when: cloud_provider is defined and cloud_provider not in ['generic', 'gce', 'aws', 'openstack', 'azure']
|
when: cloud_provider is defined and cloud_provider not in ['generic', 'gce', 'aws', 'azure', 'openstack', 'vsphere']
|
||||||
tags: [cloud-provider, facts]
|
tags: [cloud-provider, facts]
|
||||||
|
|
||||||
- include: openstack-credential-check.yml
|
- include: "{{ cloud_provider }}-credential-check.yml"
|
||||||
when: cloud_provider is defined and cloud_provider == 'openstack'
|
when: cloud_provider is defined and cloud_provider in [ 'openstack', 'azure', 'vsphere' ]
|
||||||
tags: [cloud-provider, openstack, facts]
|
tags: [cloud-provider, "{{ cloud_provider }}", facts]
|
||||||
|
|
||||||
- include: azure-credential-check.yml
|
|
||||||
when: cloud_provider is defined and cloud_provider == 'azure'
|
|
||||||
tags: [cloud-provider, azure, facts]
|
|
||||||
|
|
||||||
- name: Create cni directories
|
- name: Create cni directories
|
||||||
file:
|
file:
|
||||||
|
@ -179,23 +175,14 @@
|
||||||
state: present
|
state: present
|
||||||
tags: bootstrap-os
|
tags: bootstrap-os
|
||||||
|
|
||||||
- name: Write openstack cloud-config
|
- name: Write cloud-config
|
||||||
template:
|
template:
|
||||||
src: openstack-cloud-config.j2
|
src: "{{ cloud_provider }}-cloud-config.j2"
|
||||||
dest: "{{ kube_config_dir }}/cloud_config"
|
dest: "{{ kube_config_dir }}/cloud_config"
|
||||||
group: "{{ kube_cert_group }}"
|
group: "{{ kube_cert_group }}"
|
||||||
mode: 0640
|
mode: 0640
|
||||||
when: inventory_hostname in groups['k8s-cluster'] and cloud_provider is defined and cloud_provider == "openstack"
|
when: inventory_hostname in groups['k8s-cluster'] and cloud_provider is defined and cloud_provider in [ 'openstack', 'azure', 'vsphere' ]
|
||||||
tags: [cloud-provider, openstack]
|
tags: [cloud-provider, "{{ cloud_provider }}"]
|
||||||
|
|
||||||
- name: Write azure cloud-config
|
|
||||||
template:
|
|
||||||
src: azure-cloud-config.j2
|
|
||||||
dest: "{{ kube_config_dir }}/cloud_config"
|
|
||||||
group: "{{ kube_cert_group }}"
|
|
||||||
mode: 0640
|
|
||||||
when: inventory_hostname in groups['k8s-cluster'] and cloud_provider is defined and cloud_provider == "azure"
|
|
||||||
tags: [cloud-provider, azure]
|
|
||||||
|
|
||||||
- include: etchosts.yml
|
- include: etchosts.yml
|
||||||
tags: [bootstrap-os, etchosts]
|
tags: [bootstrap-os, etchosts]
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
- name: check vsphere environment variables
|
||||||
|
fail:
|
||||||
|
msg: "{{ item.name }} is missing"
|
||||||
|
when: item.value is not defined or item.value == ''
|
||||||
|
with_items:
|
||||||
|
- name: vsphere_vcenter_ip
|
||||||
|
value: "{{ vsphere_vcenter_ip }}"
|
||||||
|
- name: vsphere_vcenter_port
|
||||||
|
value: "{{ vsphere_vcenter_port }}"
|
||||||
|
- name: vsphere_user
|
||||||
|
value: "{{ vsphere_user }}"
|
||||||
|
- name: vsphere_password
|
||||||
|
value: "{{ vsphere_password }}"
|
||||||
|
- name: vsphere_datacenter
|
||||||
|
value: "{{ vsphere_datacenter }}"
|
||||||
|
- name: vsphere_datastore
|
||||||
|
value: "{{ vsphere_datastore }}"
|
||||||
|
- name: vsphere_working_dir
|
||||||
|
value: "{{ vsphere_working_dir }}"
|
||||||
|
- name: vsphere_insecure
|
||||||
|
value: "{{ vsphere_insecure }}"
|
|
@ -0,0 +1,20 @@
|
||||||
|
[Global]
|
||||||
|
datacenter = {{ vsphere_datacenter }}
|
||||||
|
datastore = {{ vsphere_datastore }}
|
||||||
|
insecure-flag = {{ vsphere_insecure }}
|
||||||
|
password = {{ vsphere_password }}
|
||||||
|
port = {{ vsphere_vcenter_port }}
|
||||||
|
server = {{ vsphere_vcenter_ip }}
|
||||||
|
user = {{ vsphere_user }}
|
||||||
|
working-dir = {{ vsphere_working_dir }}
|
||||||
|
{% if vsphere_vm_uuid is defined %}
|
||||||
|
vm-uuid = {{ vsphere_vm_uuid }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[Disk]
|
||||||
|
scsicontrollertype = {{ vsphere_scsi_controller_type }}
|
||||||
|
|
||||||
|
{% if vsphere_public_network is defined and vsphere_public_network != "" %}
|
||||||
|
[Network]
|
||||||
|
public-network = {{ vsphere_public_network }}
|
||||||
|
{% endif %}
|
Loading…
Reference in a new issue