Merge pull request #2317 from kubernetes-incubator/add_digitalocean_ci
Additional CI platform (digital-ocean)
This commit is contained in:
commit
e2f083f885
23 changed files with 374 additions and 135 deletions
285
.gitlab-ci.yml
285
.gitlab-ci.yml
|
@ -1,14 +1,29 @@
|
|||
stages:
|
||||
- moderator
|
||||
- unit-tests
|
||||
- deploy-gce-part1
|
||||
- deploy-gce-part2
|
||||
- deploy-gce-special
|
||||
- moderator
|
||||
- deploy-part1
|
||||
- deploy-part2
|
||||
- deploy-special
|
||||
|
||||
variables:
|
||||
FAILFASTCI_NAMESPACE: 'kargo-ci'
|
||||
# DOCKER_HOST: tcp://localhost:2375
|
||||
ANSIBLE_FORCE_COLOR: "true"
|
||||
MAGIC: "ci check this"
|
||||
TEST_ID: "$CI_PIPELINE_ID-$CI_BUILD_ID"
|
||||
CI_TEST_VARS: "./tests/files/${CI_JOB_NAME}.yml"
|
||||
GS_ACCESS_KEY_ID: $GS_KEY
|
||||
GS_SECRET_ACCESS_KEY: $GS_SECRET
|
||||
CONTAINER_ENGINE: docker
|
||||
SSH_USER: root
|
||||
GCE_PREEMPTIBLE: "false"
|
||||
ANSIBLE_KEEP_REMOTE_FILES: "1"
|
||||
ANSIBLE_CONFIG: ./tests/ansible.cfg
|
||||
IDEMPOT_CHECK: "false"
|
||||
RESET_CHECK: "false"
|
||||
UPGRADE_TEST: "false"
|
||||
KUBEADM_ENABLED: "false"
|
||||
LOG_LEVEL: "-vv"
|
||||
|
||||
# asia-east1-a
|
||||
# asia-northeast1-a
|
||||
|
@ -18,14 +33,14 @@ variables:
|
|||
# us-west1-a
|
||||
|
||||
before_script:
|
||||
- pip install -r tests/requirements.txt
|
||||
- /usr/bin/python -m pip install -r tests/requirements.txt
|
||||
- mkdir -p /.ssh
|
||||
|
||||
.job: &job
|
||||
tags:
|
||||
- kubernetes
|
||||
- docker
|
||||
image: quay.io/ant31/kargo:master
|
||||
image: quay.io/kubespray/kubespray:latest
|
||||
|
||||
.docker_service: &docker_service
|
||||
services:
|
||||
|
@ -38,24 +53,17 @@ before_script:
|
|||
.gce_variables: &gce_variables
|
||||
GCE_USER: travis
|
||||
SSH_USER: $GCE_USER
|
||||
TEST_ID: "$CI_PIPELINE_ID-$CI_BUILD_ID"
|
||||
CI_TEST_VARS: "./tests/files/${CI_JOB_NAME}.yml"
|
||||
CONTAINER_ENGINE: docker
|
||||
PRIVATE_KEY: $GCE_PRIVATE_KEY
|
||||
GS_ACCESS_KEY_ID: $GS_KEY
|
||||
GS_SECRET_ACCESS_KEY: $GS_SECRET
|
||||
CLOUD_MACHINE_TYPE: "g1-small"
|
||||
GCE_PREEMPTIBLE: "false"
|
||||
ANSIBLE_KEEP_REMOTE_FILES: "1"
|
||||
ANSIBLE_CONFIG: ./tests/ansible.cfg
|
||||
IDEMPOT_CHECK: "false"
|
||||
RESET_CHECK: "false"
|
||||
UPGRADE_TEST: "false"
|
||||
KUBEADM_ENABLED: "false"
|
||||
LOG_LEVEL: "-vv"
|
||||
MAGIC: "ci check this"
|
||||
CI_PLATFORM: "gce"
|
||||
PRIVATE_KEY: $GCE_PRIVATE_KEY
|
||||
|
||||
.gce: &gce
|
||||
.do_variables: &do_variables
|
||||
PRIVATE_KEY: $DO_PRIVATE_KEY
|
||||
CI_PLATFORM: "do"
|
||||
SSH_USER: root
|
||||
|
||||
|
||||
.testcases: &testcases
|
||||
<<: *job
|
||||
<<: *docker_service
|
||||
cache:
|
||||
|
@ -65,13 +73,10 @@ before_script:
|
|||
- $HOME/.cache
|
||||
before_script:
|
||||
- docker info
|
||||
- pip install -r tests/requirements.txt
|
||||
- /usr/bin/python -m pip install -r requirements.txt
|
||||
- /usr/bin/python -m pip install -r tests/requirements.txt
|
||||
- mkdir -p /.ssh
|
||||
- mkdir -p $HOME/.ssh
|
||||
- echo $PRIVATE_KEY | base64 -d > $HOME/.ssh/id_rsa
|
||||
- echo $GCE_PEM_FILE | base64 -d > $HOME/.ssh/gce
|
||||
- echo $GCE_CREDENTIALS > $HOME/.ssh/gce.json
|
||||
- chmod 400 $HOME/.ssh/id_rsa
|
||||
- ansible-playbook --version
|
||||
- export PYPATH=$([[ ! "$CI_JOB_NAME" =~ "coreos" ]] && echo /usr/bin/python || echo /opt/bin/python)
|
||||
- echo "CI_JOB_NAME is $CI_JOB_NAME"
|
||||
|
@ -81,15 +86,7 @@ before_script:
|
|||
- ls
|
||||
- echo ${PWD}
|
||||
- echo "${STARTUP_SCRIPT}"
|
||||
- >
|
||||
ansible-playbook tests/cloud_playbooks/create-gce.yml -i tests/local_inventory/hosts.cfg -c local
|
||||
${LOG_LEVEL}
|
||||
-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=${PWD}/inventory/sample/hosts.ini
|
||||
-e test_id=${TEST_ID}
|
||||
-e preemptible=$GCE_PREEMPTIBLE
|
||||
- cd tests && make create-${CI_PLATFORM} -s ; cd -
|
||||
|
||||
# Check out latest tag if testing upgrade
|
||||
# Uncomment when gitlab kargo repo has tags
|
||||
|
@ -226,104 +223,109 @@ before_script:
|
|||
fi
|
||||
|
||||
after_script:
|
||||
- >
|
||||
ansible-playbook -i inventory/sample/hosts.ini tests/cloud_playbooks/delete-gce.yml -c local $LOG_LEVEL
|
||||
-e @${CI_TEST_VARS}
|
||||
-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=${PWD}/inventory/sample/hosts.ini
|
||||
- cd tests && make delete-${CI_PLATFORM} -s ; cd -
|
||||
|
||||
.gce: &gce
|
||||
<<: *testcases
|
||||
variables:
|
||||
<<: *gce_variables
|
||||
|
||||
.do: &do
|
||||
variables:
|
||||
<<: *do_variables
|
||||
<<: *testcases
|
||||
|
||||
# Test matrix. Leave the comments for markup scripts.
|
||||
.coreos_calico_aio_variables: &coreos_calico_aio_variables
|
||||
# stage: deploy-gce-part1
|
||||
# stage: deploy-part1
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.ubuntu_canal_ha_variables: &ubuntu_canal_ha_variables
|
||||
# stage: deploy-gce-part1
|
||||
# stage: deploy-part1
|
||||
UPGRADE_TEST: "graceful"
|
||||
|
||||
.centos_weave_kubeadm_variables: ¢os_weave_kubeadm_variables
|
||||
# stage: deploy-gce-part1
|
||||
# stage: deploy-part1
|
||||
UPGRADE_TEST: "graceful"
|
||||
|
||||
.ubuntu_canal_kubeadm_variables: &ubuntu_canal_kubeadm_variables
|
||||
# stage: deploy-gce-part1
|
||||
# stage: deploy-part1
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.ubuntu_contiv_sep_variables: &ubuntu_contiv_sep_variables
|
||||
# stage: deploy-gce-special
|
||||
# stage: deploy-special
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.rhel7_weave_variables: &rhel7_weave_variables
|
||||
# stage: deploy-gce-part1
|
||||
# stage: deploy-part1
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.centos7_flannel_addons_variables: ¢os7_flannel_addons_variables
|
||||
# stage: deploy-gce-part2
|
||||
# stage: deploy-part2
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.debian8_calico_variables: &debian8_calico_variables
|
||||
# stage: deploy-gce-part2
|
||||
# stage: deploy-part2
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.coreos_canal_variables: &coreos_canal_variables
|
||||
# stage: deploy-gce-part2
|
||||
# stage: deploy-part2
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.rhel7_canal_sep_variables: &rhel7_canal_sep_variables
|
||||
# stage: deploy-gce-special
|
||||
# stage: deploy-special
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.ubuntu_weave_sep_variables: &ubuntu_weave_sep_variables
|
||||
# stage: deploy-gce-special
|
||||
# stage: deploy-special
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.centos7_calico_ha_variables: ¢os7_calico_ha_variables
|
||||
# stage: deploy-gce-special
|
||||
# stage: deploy-special
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.coreos_alpha_weave_ha_variables: &coreos_alpha_weave_ha_variables
|
||||
# stage: deploy-gce-special
|
||||
# stage: deploy-special
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.ubuntu_rkt_sep_variables: &ubuntu_rkt_sep_variables
|
||||
# stage: deploy-gce-part1
|
||||
# stage: deploy-part1
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.ubuntu_vault_sep_variables: &ubuntu_vault_sep_variables
|
||||
# stage: deploy-gce-part1
|
||||
# stage: deploy-part1
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
.ubuntu_flannel_variables: &ubuntu_flannel_variables
|
||||
# stage: deploy-gce-special
|
||||
# stage: deploy-special
|
||||
MOVED_TO_GROUP_VARS: "true"
|
||||
|
||||
|
||||
# Builds for PRs only (premoderated by unit-tests step) and triggers (auto)
|
||||
coreos-calico-aio:
|
||||
stage: deploy-gce-part1
|
||||
### PR JOBS
|
||||
gce_coreos-calico-aio:
|
||||
stage: deploy-part1
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
<<: *gce_variables
|
||||
<<: *coreos_calico_aio_variables
|
||||
<<: *gce_variables
|
||||
when: on_success
|
||||
except: ['triggers']
|
||||
only: [/^pr-.*$/]
|
||||
|
||||
coreos-calico-sep-triggers:
|
||||
stage: deploy-gce-part1
|
||||
do_ubuntu-canal-ha:
|
||||
stage: deploy-part1
|
||||
<<: *job
|
||||
<<: *gce
|
||||
<<: *do
|
||||
variables:
|
||||
<<: *gce_variables
|
||||
<<: *coreos_calico_aio_variables
|
||||
<<: *do_variables
|
||||
when: on_success
|
||||
only: ['triggers']
|
||||
except: ['triggers']
|
||||
only: [/^pr-.*$/]
|
||||
|
||||
centos7-flannel-addons:
|
||||
stage: deploy-gce-part2
|
||||
gce_centos7-flannel-addons:
|
||||
stage: deploy-part1
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -333,18 +335,8 @@ centos7-flannel-addons:
|
|||
except: ['triggers']
|
||||
only: [/^pr-.*$/]
|
||||
|
||||
centos7-flannel-addons-triggers:
|
||||
stage: deploy-gce-part1
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
<<: *gce_variables
|
||||
<<: *centos7_flannel_addons_variables
|
||||
when: on_success
|
||||
only: ['triggers']
|
||||
|
||||
ubuntu-weave-sep:
|
||||
stage: deploy-gce-special
|
||||
gce_ubuntu-weave-sep:
|
||||
stage: deploy-part1
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -354,8 +346,41 @@ ubuntu-weave-sep:
|
|||
except: ['triggers']
|
||||
only: [/^pr-.*$/]
|
||||
|
||||
ubuntu-weave-sep-triggers:
|
||||
stage: deploy-gce-part1
|
||||
### MANUAL JOBS
|
||||
gce_coreos-calico-sep-triggers:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
<<: *gce_variables
|
||||
<<: *coreos_calico_aio_variables
|
||||
when: on_success
|
||||
only: ['triggers']
|
||||
|
||||
|
||||
gce_ubuntu-canal-ha-triggers:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
<<: *gce_variables
|
||||
<<: *ubuntu_canal_ha_variables
|
||||
when: on_success
|
||||
only: ['triggers']
|
||||
|
||||
gce_centos7-flannel-addons-triggers:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
<<: *gce_variables
|
||||
<<: *centos7_flannel_addons_variables
|
||||
when: on_success
|
||||
only: ['triggers']
|
||||
|
||||
|
||||
gce_ubuntu-weave-sep-triggers:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -365,8 +390,8 @@ ubuntu-weave-sep-triggers:
|
|||
only: ['triggers']
|
||||
|
||||
# More builds for PRs/merges (manual) and triggers (auto)
|
||||
ubuntu-canal-ha:
|
||||
stage: deploy-gce-part1
|
||||
gce_ubuntu-canal-ha:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -376,18 +401,8 @@ ubuntu-canal-ha:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/]
|
||||
|
||||
ubuntu-canal-ha-triggers:
|
||||
stage: deploy-gce-part1
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
<<: *gce_variables
|
||||
<<: *ubuntu_canal_ha_variables
|
||||
when: on_success
|
||||
only: ['triggers']
|
||||
|
||||
ubuntu-canal-kubeadm:
|
||||
stage: deploy-gce-part1
|
||||
gce_ubuntu-canal-kubeadm:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -397,8 +412,8 @@ ubuntu-canal-kubeadm:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/]
|
||||
|
||||
ubuntu-canal-kubeadm-triggers:
|
||||
stage: deploy-gce-part1
|
||||
gce_ubuntu-canal-kubeadm-triggers:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -407,8 +422,8 @@ ubuntu-canal-kubeadm-triggers:
|
|||
when: on_success
|
||||
only: ['triggers']
|
||||
|
||||
centos-weave-kubeadm:
|
||||
stage: deploy-gce-part1
|
||||
gce_centos-weave-kubeadm:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -418,8 +433,8 @@ centos-weave-kubeadm:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/]
|
||||
|
||||
centos-weave-kubeadm-triggers:
|
||||
stage: deploy-gce-part1
|
||||
gce_centos-weave-kubeadm-triggers:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -428,8 +443,8 @@ centos-weave-kubeadm-triggers:
|
|||
when: on_success
|
||||
only: ['triggers']
|
||||
|
||||
ubuntu-contiv-sep:
|
||||
stage: deploy-gce-special
|
||||
gce_ubuntu-contiv-sep:
|
||||
stage: deploy-special
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -439,8 +454,8 @@ ubuntu-contiv-sep:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/]
|
||||
|
||||
rhel7-weave:
|
||||
stage: deploy-gce-part1
|
||||
gce_rhel7-weave:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -450,8 +465,8 @@ rhel7-weave:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/]
|
||||
|
||||
rhel7-weave-triggers:
|
||||
stage: deploy-gce-part1
|
||||
gce_rhel7-weave-triggers:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -460,8 +475,8 @@ rhel7-weave-triggers:
|
|||
when: on_success
|
||||
only: ['triggers']
|
||||
|
||||
debian8-calico-upgrade:
|
||||
stage: deploy-gce-part2
|
||||
gce_debian8-calico-upgrade:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -471,8 +486,8 @@ debian8-calico-upgrade:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/]
|
||||
|
||||
debian8-calico-triggers:
|
||||
stage: deploy-gce-part1
|
||||
gce_debian8-calico-triggers:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -481,8 +496,8 @@ debian8-calico-triggers:
|
|||
when: on_success
|
||||
only: ['triggers']
|
||||
|
||||
coreos-canal:
|
||||
stage: deploy-gce-part2
|
||||
gce_coreos-canal:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -492,8 +507,8 @@ coreos-canal:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/]
|
||||
|
||||
coreos-canal-triggers:
|
||||
stage: deploy-gce-part1
|
||||
gce_coreos-canal-triggers:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -502,8 +517,8 @@ coreos-canal-triggers:
|
|||
when: on_success
|
||||
only: ['triggers']
|
||||
|
||||
rhel7-canal-sep:
|
||||
stage: deploy-gce-special
|
||||
gce_rhel7-canal-sep:
|
||||
stage: deploy-special
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -513,8 +528,8 @@ rhel7-canal-sep:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/,]
|
||||
|
||||
rhel7-canal-sep-triggers:
|
||||
stage: deploy-gce-part1
|
||||
gce_rhel7-canal-sep-triggers:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -523,8 +538,8 @@ rhel7-canal-sep-triggers:
|
|||
when: on_success
|
||||
only: ['triggers']
|
||||
|
||||
centos7-calico-ha:
|
||||
stage: deploy-gce-special
|
||||
gce_centos7-calico-ha:
|
||||
stage: deploy-special
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -534,8 +549,8 @@ centos7-calico-ha:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/]
|
||||
|
||||
centos7-calico-ha-triggers:
|
||||
stage: deploy-gce-part1
|
||||
gce_centos7-calico-ha-triggers:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -545,8 +560,8 @@ centos7-calico-ha-triggers:
|
|||
only: ['triggers']
|
||||
|
||||
# no triggers yet https://github.com/kubernetes-incubator/kargo/issues/613
|
||||
coreos-alpha-weave-ha:
|
||||
stage: deploy-gce-special
|
||||
gce_coreos-alpha-weave-ha:
|
||||
stage: deploy-special
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -556,8 +571,8 @@ coreos-alpha-weave-ha:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/]
|
||||
|
||||
ubuntu-rkt-sep:
|
||||
stage: deploy-gce-part1
|
||||
gce_ubuntu-rkt-sep:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -567,8 +582,8 @@ ubuntu-rkt-sep:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/]
|
||||
|
||||
ubuntu-vault-sep:
|
||||
stage: deploy-gce-part1
|
||||
gce_ubuntu-vault-sep:
|
||||
stage: deploy-part2
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
@ -578,8 +593,8 @@ ubuntu-vault-sep:
|
|||
except: ['triggers']
|
||||
only: ['master', /^pr-.*$/]
|
||||
|
||||
ubuntu-flannel-sep:
|
||||
stage: deploy-gce-special
|
||||
gce_ubuntu-flannel-sep:
|
||||
stage: deploy-special
|
||||
<<: *job
|
||||
<<: *gce
|
||||
variables:
|
||||
|
|
16
Dockerfile
Normal file
16
Dockerfile
Normal file
|
@ -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
|
51
tests/Makefile
Normal file
51
tests/Makefile
Normal file
|
@ -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)
|
97
tests/cloud_playbooks/create-do.yml
Normal file
97
tests/cloud_playbooks/create-do.yml
Normal file
|
@ -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' }}"
|
10
tests/files/do_ubuntu-canal-ha.yml
Normal file
10
tests/files/do_ubuntu-canal-ha.yml
Normal file
|
@ -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'
|
|
@ -3,3 +3,5 @@ yamllint
|
|||
apache-libcloud==2.2.1
|
||||
boto==2.9.0
|
||||
tox
|
||||
dopy
|
||||
PyCrypto
|
||||
|
|
48
tests/templates/inventory-do.j2
Normal file
48
tests/templates/inventory-do.j2
Normal file
|
@ -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
|
Loading…
Reference in a new issue