-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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 #2317 from kubernetes-incubator/add_digitalocean_ci
Additional CI platform (digital-ocean)
- Loading branch information
Showing
23 changed files
with
369 additions
and
130 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM ubuntu:16.04 | ||
|
||
RUN mkdir /kubespray | ||
WORKDIR /kubespray | ||
RUN apt update -y && \ | ||
apt install -y \ | ||
libssl-dev python-dev sshpass apt-transport-https \ | ||
ca-certificates curl gnupg2 software-properties-common python-pip | ||
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \ | ||
add-apt-repository \ | ||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | ||
$(lsb_release -cs) \ | ||
stable" \ | ||
&& apt update -y && apt-get install docker-ce -y | ||
COPY . . | ||
RUN /usr/bin/python -m pip install pip -U && /usr/bin/python -m pip install -r tests/requirements.txt && python -m pip install -r requirements.txt |
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,51 @@ | ||
INVENTORY=$(PWD)/../inventory/sample/hosts.ini | ||
|
||
$(HOME)/.ssh/id_rsa: | ||
mkdir -p $(HOME)/.ssh | ||
echo $(PRIVATE_KEY) | base64 -d > $(HOME)/.ssh/id_rsa | ||
chmod 400 $(HOME)/.ssh/id_rsa | ||
|
||
init-gce: $(HOME)/.ssh/id_rsa | ||
# echo $(GCE_PEM_FILE) | base64 -d > $(HOME)/.ssh/gce | ||
echo "$(GCE_CREDENTIALS_B64)" | base64 -d > $(HOME)/.ssh/gce.json | ||
|
||
init-do: $(HOME)/.ssh/id_rsa | ||
echo $(DO_PRIVATE_KEY) | base64 -d > $(HOME)/.ssh/id_rsa | ||
|
||
create-gce: init-gce | ||
ansible-playbook cloud_playbooks/create-gce.yml -i local_inventory/hosts.cfg -c local \ | ||
$(LOG_LEVEL) \ | ||
-e @"files/${CI_JOB_NAME}.yml" \ | ||
-e gce_credentials_file=$(HOME)/.ssh/gce.json \ | ||
-e gce_project_id=$(GCE_PROJECT_ID) \ | ||
-e gce_service_account_email=$(GCE_ACCOUNT) \ | ||
-e inventory_path=$(INVENTORY) \ | ||
-e test_id=$(TEST_ID) \ | ||
-e preemptible=$(GCE_PREEMPTIBLE) | ||
|
||
|
||
delete-gce: | ||
ansible-playbook -i $(INVENTORY) cloud_playbooks/delete-gce.yml -c local \ | ||
$(LOG_LEVEL) \ | ||
-e @"files/${CI_JOB_NAME}.yml" \ | ||
-e test_id=$(TEST_ID) \ | ||
-e gce_project_id=$(GCE_PROJECT_ID) \ | ||
-e gce_service_account_email=$(GCE_ACCOUNT) \ | ||
-e gce_credentials_file=$(HOME)/.ssh/gce.json \ | ||
-e inventory_path=$(INVENTORY) | ||
|
||
create-do: init-do | ||
ansible-playbook cloud_playbooks/create-do.yml -i local_inventory/hosts.cfg -c local \ | ||
${LOG_LEVEL} \ | ||
-e @"files/${CI_JOB_NAME}.yml" \ | ||
-e inventory_path=$(INVENTORY) \ | ||
-e test_id=${TEST_ID} | ||
|
||
|
||
delete-do: | ||
ansible-playbook -i $(INVENTORY) cloud_playbooks/create-do.yml -c local \ | ||
$(LOG_LEVEL) \ | ||
-e @"files/${CI_JOB_NAME}.yml" \ | ||
-e state=absent \ | ||
-e test_id=${TEST_ID} \ | ||
-e inventory_path=$(INVENTORY) |
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,97 @@ | ||
--- | ||
- hosts: localhost | ||
become: false | ||
gather_facts: no | ||
vars: | ||
state: "present" | ||
ssh_key_id: "6536865" | ||
cloud_machine_type: 2gb | ||
regions: | ||
- nyc1 | ||
- sfo1 | ||
- nyc2 | ||
- ams2 | ||
- sgp1 | ||
- lon1 | ||
- nyc3 | ||
- ams3 | ||
- fra1 | ||
- tor1 | ||
- sfo2 | ||
- blr1 | ||
cloud_images: | ||
- coreos-beta | ||
- fedora-24-x64 | ||
- centos-5-x64 | ||
- centos-5-x32 | ||
- fedora-25-x64 | ||
- debian-7-x64 | ||
- debian-7-x32 | ||
- debian-8-x64 | ||
- debian-8-x32 | ||
- centos-6-x32 | ||
- centos-6-x64 | ||
- coreos-stable | ||
- ubuntu-16-10-x32 | ||
- ubuntu-16-10-x64 | ||
- freebsd-11-0-x64-zfs | ||
- freebsd-10-3-x64-zfs | ||
- coreos-alpha | ||
- ubuntu-12-04-x32 | ||
- ubuntu-12-04-x64 | ||
- ubuntu-16-04-x64 | ||
- ubuntu-16-04-x32 | ||
- ubuntu-14-04-x64 | ||
- ubuntu-14-04-x32 | ||
- centos-7-x64 | ||
- freebsd-11-0-x64 | ||
- freebsd-10-3-x64 | ||
- centos-7-3-1611-x64 | ||
mode: default | ||
|
||
tasks: | ||
- name: replace_test_id | ||
set_fact: | ||
test_name: "{{test_id |regex_replace('\\.', '-')}}" | ||
|
||
- name: show vars | ||
debug: msg="{{cloud_region}}, {{cloud_image}}" | ||
|
||
- set_fact: | ||
instance_names: >- | ||
{%- if mode in ['separate', 'ha'] -%} | ||
["k8s-{{test_name}}-1", "k8s-{{test_name}}-2", "k8s-{{test_name}}-3"] | ||
{%- else -%} | ||
["k8s-{{test_name}}-1", "k8s-{{test_name}}-2"] | ||
{%- endif -%} | ||
- name: Manage DO instances | {{state}} | ||
digital_ocean: | ||
unique_name: yes | ||
api_token: "{{ lookup('env','DO_API_TOKEN') }}" | ||
command: "droplet" | ||
image_id: "{{ cloud_image }}" | ||
name: "{{ item }}" | ||
private_networking: no | ||
region_id: "{{cloud_region}}" | ||
size_id: "{{cloud_machine_type}}" | ||
ssh_key_ids: "{{ssh_key_id}}" | ||
state: "{{state}}" | ||
wait: yes | ||
register: droplets | ||
with_items: "{{instance_names}}" | ||
|
||
- debug: | ||
msg: "{{droplets}}, {{inventory_path}}" | ||
when: "{{ state == 'present' }}" | ||
|
||
- name: Template the inventory | ||
template: | ||
src: ../templates/inventory-do.j2 | ||
dest: "{{ inventory_path }}" | ||
when: "{{ state == 'present' }}" | ||
|
||
- name: Wait for SSH to come up | ||
wait_for: host={{item.droplet.ip_address}} port=22 delay=10 timeout=180 state=started | ||
with_items: "{{droplets.results}}" | ||
when: "{{ state == 'present' }}" |
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,10 @@ | ||
cloud_image: ubuntu-16-04-x64 | ||
cloud_region: nyc3 | ||
mode: ha | ||
|
||
# Deployment settings | ||
bootstrap_os: ubuntu | ||
kube_network_plugin: canal | ||
deploy_netchecker: true | ||
kubedns_min_replicas: 1 | ||
# cloud_provider: 'do' |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
|
@@ -3,3 +3,5 @@ yamllint | |
apache-libcloud==2.2.1 | ||
boto==2.9.0 | ||
tox | ||
dopy | ||
PyCrypto |
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,48 @@ | ||
{% for instance in droplets.results %} | ||
{{instance.droplet.name}} ansible_ssh_host={{instance.droplet.ip_address}} | ||
{% endfor %} | ||
|
||
{% if mode is defined and mode == "separate" %} | ||
[kube-master] | ||
{{droplets.results[0].droplet.name}} | ||
|
||
[kube-node] | ||
{{droplets.results[1].droplet.name}} | ||
|
||
[etcd] | ||
{{droplets.results[2].droplet.name}} | ||
|
||
[vault] | ||
{{droplets.results[2].droplet.name}} | ||
{% elif mode is defined and mode == "ha" %} | ||
[kube-master] | ||
{{droplets.results[0].droplet.name}} | ||
{{droplets.results[1].droplet.name}} | ||
|
||
[kube-node] | ||
{{droplets.results[2].droplet.name}} | ||
|
||
[etcd] | ||
{{droplets.results[1].droplet.name}} | ||
{{droplets.results[2].droplet.name}} | ||
|
||
[vault] | ||
{{droplets.results[1].droplet.name}} | ||
{{droplets.results[2].droplet.name}} | ||
{% else %} | ||
[kube-master] | ||
{{droplets.results[0].droplet.name}} | ||
|
||
[kube-node] | ||
{{droplets.results[1].droplet.name}} | ||
|
||
[etcd] | ||
{{droplets.results[0].droplet.name}} | ||
|
||
[vault] | ||
{{droplets.results[0].droplet.name}} | ||
{% endif %} | ||
|
||
[k8s-cluster:children] | ||
kube-node | ||
kube-master |