Skip to content
Snippets Groups Projects
Verified Commit d36d47e5 authored by Varac's avatar Varac
Browse files

Merge branch 'master' into 137-bootstrap-cli-script

parents 708a23be 4d589e5b
No related branches found
No related tags found
No related merge requests found
Showing
with 98 additions and 64 deletions
...@@ -17,17 +17,14 @@ variables: ...@@ -17,17 +17,14 @@ variables:
ci_test_image: ci_test_image:
stage: build stage: build
variables: image:
DOCKER_DRIVER: overlay2 # We need a shell to provide the registry credentials, so we need to use the
image: docker:stable # kaniko debug image (https://github.com/GoogleContainerTools/kaniko#debug-image)
services: name: gcr.io/kaniko-project/executor:debug
- docker:18-dind # FIXME This is an older version of DIND. Update when gitlab-runner fixes https://gitlab.com/gitlab-org/gitlab-runner/issues/4501 entrypoint: [""]
before_script:
- docker info
script: script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- docker build -t ${CI_REGISTRY_IMAGE}/openappstack-ci:${CI_COMMIT_REF_NAME} . - /kaniko/executor --context ${CI_PROJECT_DIR} --dockerfile ${CI_PROJECT_DIR}/Dockerfile --destination $CI_REGISTRY_IMAGE/openappstack-ci:${CI_COMMIT_REF_NAME}
- docker push ${CI_REGISTRY_IMAGE}/openappstack-ci:${CI_COMMIT_REF_NAME}
only: only:
changes: changes:
- Dockerfile - Dockerfile
...@@ -55,6 +52,7 @@ bootstrap: ...@@ -55,6 +52,7 @@ bootstrap:
when: always when: always
only: only:
changes: changes:
- .gitlab-ci.yml
- ansible/**/* - ansible/**/*
- helmfiles/**/* - helmfiles/**/*
- test/**/* - test/**/*
...@@ -81,6 +79,7 @@ install: ...@@ -81,6 +79,7 @@ install:
expire_in: 1 month expire_in: 1 month
only: only:
changes: changes:
- .gitlab-ci.yml
- ansible/**/* - ansible/**/*
- helmfiles/**/* - helmfiles/**/*
- test/**/* - test/**/*
...@@ -97,6 +96,7 @@ testinfra: ...@@ -97,6 +96,7 @@ testinfra:
- pytest -v -m 'testinfra' --connection=ansible --ansible-inventory=../clusters/$HOSTNAME/inventory.yml --hosts='ansible://*' - pytest -v -m 'testinfra' --connection=ansible --ansible-inventory=../clusters/$HOSTNAME/inventory.yml --hosts='ansible://*'
only: only:
changes: changes:
- .gitlab-ci.yml
- ansible/**/* - ansible/**/*
- helmfiles/**/* - helmfiles/**/*
- test/**/* - test/**/*
...@@ -116,6 +116,7 @@ certs: ...@@ -116,6 +116,7 @@ certs:
- pytest -s -m 'certs' --connection=ansible --ansible-inventory=../clusters/$HOSTNAME/inventory.yml --hosts='ansible://*' - pytest -s -m 'certs' --connection=ansible --ansible-inventory=../clusters/$HOSTNAME/inventory.yml --hosts='ansible://*'
only: only:
changes: changes:
- .gitlab-ci.yml
- ansible/**/* - ansible/**/*
- helmfiles/**/* - helmfiles/**/*
- test/**/* - test/**/*
...@@ -134,6 +135,7 @@ behave-nextcloud: ...@@ -134,6 +135,7 @@ behave-nextcloud:
retry: 2 retry: 2
only: only:
changes: changes:
- .gitlab-ci.yml
- ansible/**/* - ansible/**/*
- helmfiles/**/* - helmfiles/**/*
- test/**/* - test/**/*
...@@ -151,6 +153,7 @@ behave-grafana: ...@@ -151,6 +153,7 @@ behave-grafana:
when: on_failure when: on_failure
only: only:
changes: changes:
- .gitlab-ci.yml
- ansible/**/* - ansible/**/*
- helmfiles/**/* - helmfiles/**/*
- test/**/* - test/**/*
...@@ -163,9 +166,10 @@ terminate: ...@@ -163,9 +166,10 @@ terminate:
# Remove droplet after successful tests # Remove droplet after successful tests
- echo "$CI_COMMIT_MESSAGE" | grep '!ci_dont_terminate' && echo 'Termination of droplet disabled in commit message.' || python3 -m openappstack $HOSTNAME --terminate - echo "$CI_COMMIT_MESSAGE" | grep '!ci_dont_terminate' && echo 'Termination of droplet disabled in commit message.' || python3 -m openappstack $HOSTNAME --terminate
# Remove droplet older than 2 days # Remove droplet older than 2 days
- python3 -c "import openappstack.cosmos; openappstack.cosmos.terminate_droplets_by_name(\"^ci-\", 2)" - python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^ci-\", 2)"
only: only:
changes: changes:
- .gitlab-ci.yml
- ansible/**/* - ansible/**/*
- helmfiles/**/* - helmfiles/**/*
- test/**/* - test/**/*
......
...@@ -45,3 +45,7 @@ ...@@ -45,3 +45,7 @@
tags: ['rke_configuration'] tags: ['rke_configuration']
- role: setup - role: setup
tags: ['setup'] tags: ['setup']
- role: apps
tags: ['apps']
- role: finalize
tags: ['finalize']
...@@ -16,10 +16,13 @@ nextcloud_mariadb_password: "{{ lookup('password', '{{ cluster_dir }}/secrets/ne ...@@ -16,10 +16,13 @@ nextcloud_mariadb_password: "{{ lookup('password', '{{ cluster_dir }}/secrets/ne
nextcloud_mariadb_root_password: "{{ lookup('password', '{{ cluster_dir }}/secrets/nextcloud_mariadb_root_password chars=ascii_letters') }}" nextcloud_mariadb_root_password: "{{ lookup('password', '{{ cluster_dir }}/secrets/nextcloud_mariadb_root_password chars=ascii_letters') }}"
grafana_admin_password: "{{ lookup('password', '{{ cluster_dir }}/secrets/grafana_admin_password chars=ascii_letters') }}" grafana_admin_password: "{{ lookup('password', '{{ cluster_dir }}/secrets/grafana_admin_password chars=ascii_letters') }}"
# Kubernetes version
kubernetes_version: "v1.14.3-rancher1-1"
# git repo versions # git repo versions
git_charts_version: 'HEAD' git_charts_version: 'HEAD'
git_local_storage_version: 'HEAD' git_local_storage_version: 'HEAD'
git_nextcloud_version: '897c800f7a1d632784d8dc721f34362d4e789743' git_nextcloud_version: '21aac1909edf5dc84eae067a536a16e16ca897fb'
# Application versions # Application versions
# https://github.com/kubernetes-sigs/krew/releases # https://github.com/kubernetes-sigs/krew/releases
...@@ -39,3 +42,10 @@ rke: ...@@ -39,3 +42,10 @@ rke:
# Also possible: # Also possible:
# checksum: 'sha256:https://github.com/rancher/rke/releases/download/v0.2.4/sha256sum.txt' # checksum: 'sha256:https://github.com/rancher/rke/releases/download/v0.2.4/sha256sum.txt'
checksum: 'sha256:7c05727aa3d6f8c4b5f60b057f1fe7883af48d5a778e3b1668f178dda84883ee' checksum: 'sha256:7c05727aa3d6f8c4b5f60b057f1fe7883af48d5a778e3b1668f178dda84883ee'
cert_manager:
version: '0.9.1'
# cert-manager requires custom resource definitions applied before installing
# the helm chart. See https://hub.helm.sh/charts/jetstack/cert-manager for
# details
crd_version: '0.9'
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- name: Install CRDs for cert-manager - name: Install CRDs for cert-manager
tags: tags:
- cert-manager - cert-manager
command: /snap/bin/kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.8/deploy/manifests/00-crds.yaml command: '/snap/bin/kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-{{ cert_manager.crd_version }}/deploy/manifests/00-crds.yaml'
- name: Prevent validation deadlock for cert-manager - name: Prevent validation deadlock for cert-manager
tags: tags:
......
---
- name: Clone nextcloud repo
tags:
- git
git:
repo: 'https://open.greenhost.net/openappstack/nextcloud'
dest: '{{ data_directory }}/source/repos/nextcloud'
version: '{{ git_nextcloud_version }}'
- name: Clone local-storage repo
tags:
- git
git:
repo: 'https://open.greenhost.net/openappstack/local-storage'
dest: '{{ data_directory }}/source/repos/local-storage'
version: '{{ git_local_storage_version }}'
- name: Apply helmfiles
tags:
- helmfile
environment:
- NEXTCLOUD_PASSWORD: "{{ nextcloud_password }}"
- NEXTCLOUD_MARIADB_PASSWORD: "{{ nextcloud_mariadb_password }}"
- NEXTCLOUD_MARIADB_ROOT_PASSWORD: "{{ nextcloud_mariadb_root_password }}"
- GRAFANA_ADMIN_PASSWORD: "{{ grafana_admin_password }}"
shell: /usr/local/bin/helmfile -b /snap/bin/helm -e oas -f {{ data_directory }}/source/helmfiles/helmfile.d/{{ item }}.yaml apply --suppress-secrets | sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> {{ log_directory }}/helmfile.log
with_items: "{{ helmfiles }}"
when: item is not search("cert-manager")
...@@ -20,22 +20,6 @@ ...@@ -20,22 +20,6 @@
version: '{{ git_charts_version }}' version: '{{ git_charts_version }}'
become: true become: true
- name: Clone nextcloud repo
tags:
- git
git:
repo: 'https://open.greenhost.net/openappstack/nextcloud'
dest: '{{ data_directory }}/source/repos/nextcloud'
version: '{{ git_nextcloud_version }}'
- name: Clone local-storage repo
tags:
- git
git:
repo: 'https://open.greenhost.net/openappstack/local-storage'
dest: '{{ data_directory }}/source/repos/local-storage'
version: '{{ git_local_storage_version }}'
- name: Create OAS namespaces - name: Create OAS namespaces
tags: tags:
- kubernetes - kubernetes
...@@ -85,15 +69,3 @@ ...@@ -85,15 +69,3 @@
- helmfile - helmfile
shell: 'helm ls --failed --short | xargs -L1 helm delete --purge' shell: 'helm ls --failed --short | xargs -L1 helm delete --purge'
when: helm_failed_deployments.stdout != "" when: helm_failed_deployments.stdout != ""
- name: Apply helmfiles
tags:
- helmfile
- tmp
environment:
- NEXTCLOUD_PASSWORD: "{{ nextcloud_password }}"
- NEXTCLOUD_MARIADB_PASSWORD: "{{ nextcloud_mariadb_password }}"
- NEXTCLOUD_MARIADB_ROOT_PASSWORD: "{{ nextcloud_mariadb_root_password }}"
- GRAFANA_ADMIN_PASSWORD: "{{ grafana_admin_password }}"
command: "/usr/local/bin/helmfile -b /snap/bin/helm -e oas -f {{ data_directory }}/source/helmfiles/helmfile.d/{{ item }}.yaml apply --suppress-secrets"
with_items: "{{ helmfiles }}"
---
- import_tasks: init.yml
- import_tasks: cert-manager.yml
- import_tasks: helmfiles.yml
---
- import_tasks: sync_cluster_data.yml
---
- name: Copy cluster information to local folder
tags:
- fetch
- rke
- kubectl
- helmfile
fetch:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
flat: yes
loop:
- src: "{{ data_directory }}/rke/kube_config_cluster.yml"
dest: "{{ secret_directory }}/kube_config_cluster.yml"
- src: "{{ log_directory }}/rke.log"
dest: cluster_data/rke.log
- src: "{{ data_directory }}/rke/cluster.yml"
dest: cluster_data/rke_cluster.yml
- src: "{{ log_directory }}/helmfile.log"
dest: cluster_data/helmfile.log
...@@ -72,7 +72,7 @@ authorization: ...@@ -72,7 +72,7 @@ authorization:
mode: rbac mode: rbac
options: {} options: {}
ignore_docker_version: false ignore_docker_version: false
kubernetes_version: "v1.13.5-rancher1-3" kubernetes_version: {{ kubernetes_version }}
private_registries: [] private_registries: []
ingress: ingress:
# Set this to none, so we can install nginx ourselves. # Set this to none, so we can install nginx ourselves.
......
...@@ -2,6 +2,4 @@ ...@@ -2,6 +2,4 @@
- import_tasks: ssh.yml - import_tasks: ssh.yml
- import_tasks: rke.yml - import_tasks: rke.yml
- import_tasks: tiller.yml - import_tasks: tiller.yml
- import_tasks: cert-manager.yml
- import_tasks: helmfiles.yml
- import_tasks: krew.yml - import_tasks: krew.yml
--- ---
- name: Check if there is an cluster.rkestate at the old location (/oas/control/local/rke/)
stat: path=/oas/control/local/rke/cluster.rkestate
register: old_cluster_rkestate
- name: Move rke cluster state file from old to new location
command: mv /oas/control/local/rke/cluster.rkestate /var/lib/OpenAppStack/rke/cluster.rkestate
when: old_cluster_rkestate.stat.exists
- name: Build Cluster - name: Build Cluster
tags: tags:
- rke - rke
...@@ -20,20 +29,3 @@ ...@@ -20,20 +29,3 @@
state: link state: link
src: "{{ data_directory }}/rke/kube_config_cluster.yml" src: "{{ data_directory }}/rke/kube_config_cluster.yml"
dest: /root/.kube/config dest: /root/.kube/config
- name: Copy cluster information to local folder
tags:
- fetch
- rke
- kubectl
fetch:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
flat: yes
loop:
- src: "{{ data_directory }}/rke/kube_config_cluster.yml"
dest: "{{ cluster_dir }}/secrets/kube_config_cluster.yml"
- src: "{{ log_directory }}/rke.log"
dest: "{{ cluster_dir }}/rke.log"
- src: "{{ data_directory }}/rke/cluster.yml"
dest: "{{ cluster_dir }}/rke_cluster.yml"
...@@ -11,7 +11,7 @@ releases: ...@@ -11,7 +11,7 @@ releases:
- name: "oas-{{ .Environment.Values.releaseName }}-cert-manager" - name: "oas-{{ .Environment.Values.releaseName }}-cert-manager"
namespace: "cert-manager" namespace: "cert-manager"
chart: "jetstack/cert-manager" chart: "jetstack/cert-manager"
version: "0.9.1" version: '{{ cert_manager.version }}'
values: values:
- "../values/cert-manager.yaml.gotmpl" - "../values/cert-manager.yaml.gotmpl"
wait: false wait: false
...@@ -7,6 +7,7 @@ releases: ...@@ -7,6 +7,7 @@ releases:
- name: "oas-{{ .Environment.Values.releaseName }}-prometheus" - name: "oas-{{ .Environment.Values.releaseName }}-prometheus"
namespace: "oas" namespace: "oas"
chart: "stable/prometheus-operator" chart: "stable/prometheus-operator"
version: 5.15.0
values: values:
- "../values/prometheus.yaml.gotmpl" - "../values/prometheus.yaml.gotmpl"
- "/etc/OpenAppStack/values/apps/prometheus.yaml.gotmpl" - "/etc/OpenAppStack/values/apps/prometheus.yaml.gotmpl"
......
...@@ -7,7 +7,6 @@ openshift>=0.8.6 ...@@ -7,7 +7,6 @@ openshift>=0.8.6
# Needed for testinfra using the ansible module # Needed for testinfra using the ansible module
paramiko paramiko
psutil>=5.5.0 psutil>=5.5.0
pycurl>=7.43.0.2
pyopenssl>=19.0.0 pyopenssl>=19.0.0
pytest>=4.3.0 pytest>=4.3.0
requests>=2.19.1 requests>=2.19.1
...@@ -16,4 +15,4 @@ testinfra>=3.0.0 ...@@ -16,4 +15,4 @@ testinfra>=3.0.0
setuptools>=40.6.2 setuptools>=40.6.2
wheel>=0.33.1 wheel>=0.33.1
pytz>=2019.1 pytz>=2019.1
-e git+https://open.greenhost.net/greenhost/cloud-api#egg=greenhost_cloud
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment