From 7322ba669d181022db5b75061b9e5f560974fd08 Mon Sep 17 00:00:00 2001 From: Evan Cordell Date: Tue, 29 May 2018 15:17:55 -0400 Subject: [PATCH 1/4] chore(deploy): add ansible playbook for deploying OLM --- Documentation/install/install.md | 11 ++++++++ Makefile | 25 +++++++++++++++--- deploy/aos-olm/playbook/config.yaml | 4 +++ deploy/aos-olm/playbook/private/config.yaml | 6 +++++ deploy/aos-olm/playbook/private/roles/olm | 1 + deploy/aos-olm/values.yaml | 22 ++++++++++++++++ deploy/namespace.yaml | 4 --- deploy/role/defaults/main.yaml | 3 +++ deploy/role/files/.gitkeep | 0 deploy/role/meta/main.yaml | 16 ++++++++++++ deploy/role/tasks/install.yaml | 19 ++++++++++++++ deploy/role/tasks/main.yaml | 8 ++++++ deploy/role/tasks/remove.yaml | 8 ++++++ deploy/role/tasks/remove_components.yaml | 1 + scripts/k8s_yaml_to_ansible_install.sh | 29 +++++++++++++++++++++ scripts/k8s_yaml_to_ansible_remove.sh | 27 +++++++++++++++++++ scripts/package-release.sh | 2 +- 17 files changed, 178 insertions(+), 8 deletions(-) create mode 100644 deploy/aos-olm/playbook/config.yaml create mode 100644 deploy/aos-olm/playbook/private/config.yaml create mode 120000 deploy/aos-olm/playbook/private/roles/olm create mode 100644 deploy/aos-olm/values.yaml delete mode 100644 deploy/namespace.yaml create mode 100644 deploy/role/defaults/main.yaml create mode 100644 deploy/role/files/.gitkeep create mode 100644 deploy/role/meta/main.yaml create mode 100644 deploy/role/tasks/install.yaml create mode 100644 deploy/role/tasks/main.yaml create mode 100644 deploy/role/tasks/remove.yaml create mode 100644 deploy/role/tasks/remove_components.yaml create mode 100755 scripts/k8s_yaml_to_ansible_install.sh create mode 100755 scripts/k8s_yaml_to_ansible_remove.sh diff --git a/Documentation/install/install.md b/Documentation/install/install.md index 1ee2c8e171..d1a56de5e6 100644 --- a/Documentation/install/install.md +++ b/Documentation/install/install.md @@ -19,6 +19,17 @@ kubectl create namespace tectonic-system kubectl apply -f deploy/tectonic-alm-operator/manifests/0.4.0 ``` +## Install with Ansible for openshift + +OLM should be installed via [openshift-ansible](https://github.com/openshift/openshift-ansible). The playbook in this +repo is periodically synced with openshift-ansible and should only be used for testing releases. + +The playbook assumes that the hosts file has the same format as [openshift-ansible](https://github.com/openshift/openshift-ansible) + +```sh +ansible-playbook -i path/to/hosts deploy/aos-olm/playbook/config.yaml +``` + ## Run locally with minikube This command starts minikube, builds the OLM containers locally with the minikube-provided docker, and uses the local configuration in [local-values.yaml](local-values.yaml) to build localized deployment resources for OLM. diff --git a/Makefile b/Makefile index 4eb85a349d..4a35578078 100644 --- a/Makefile +++ b/Makefile @@ -152,13 +152,32 @@ $(counterfeiter): generate-mock-client: $(counterfeiter) go generate ./$(PKG_DIR)/... -make gen-all: gen-ci codegen generate-mock-client +gen-all: gen-ci codegen generate-mock-client # make ver=0.3.0 tectonic-release tectonic-release: ./scripts/package-release.sh $(ver) deploy/tectonic-alm-operator/manifests/$(ver) deploy/tectonic-alm-operator/values.yaml -# make ver=0.3.0 release -release: +# make ver=0.3.0 upstream-release +upstream-release: ./scripts/package-release.sh $(ver) deploy/upstream/manifests/$(ver) deploy/upstream/values.yaml + +YQ := $(GOPATH)/bin/yq +$(YQ): + go get -u github.com/mikefarah/yq + +# make ver=0.3.0 ansible-release +ansible-release: $(YQ) + # copy base role to versioned release + mkdir -p deploy/aos-olm/$(ver) + cp -R deploy/role/ deploy/aos-olm/$(ver)/ + # copy manifest files into release + ./scripts/package-release.sh $(ver) deploy/aos-olm/$(ver)/files deploy/aos-olm/values.yaml + # generate install/remove tasks based on manifest files + ./scripts/k8s_yaml_to_ansible_install.sh deploy/aos-olm/$(ver)/files deploy/aos-olm/$(ver)/tasks/install.yaml + ./scripts/k8s_yaml_to_ansible_remove.sh deploy/aos-olm/$(ver)/files deploy/aos-olm/$(ver)/tasks/remove_components.yaml + # link newest release into playbook + ln -sF ../../../../deploy/aos-olm/$(ver) deploy/aos-olm/playbook/private/roles/olm + +release: tectonic-release upstream-release ansible-release \ No newline at end of file diff --git a/deploy/aos-olm/playbook/config.yaml b/deploy/aos-olm/playbook/config.yaml new file mode 100644 index 0000000000..79e7897d4e --- /dev/null +++ b/deploy/aos-olm/playbook/config.yaml @@ -0,0 +1,4 @@ +--- +- import_playbook: private/config.yaml + vars: + operator_lifecycle_manager_install: true \ No newline at end of file diff --git a/deploy/aos-olm/playbook/private/config.yaml b/deploy/aos-olm/playbook/private/config.yaml new file mode 100644 index 0000000000..ff43508760 --- /dev/null +++ b/deploy/aos-olm/playbook/private/config.yaml @@ -0,0 +1,6 @@ +--- +- name: Operator Lifecycle Manager + hosts: masters[0] + tasks: + - import_role: + name: olm \ No newline at end of file diff --git a/deploy/aos-olm/playbook/private/roles/olm b/deploy/aos-olm/playbook/private/roles/olm new file mode 120000 index 0000000000..e870af5a6a --- /dev/null +++ b/deploy/aos-olm/playbook/private/roles/olm @@ -0,0 +1 @@ +../../../../deploy/aos-olm/0.4.1 \ No newline at end of file diff --git a/deploy/aos-olm/values.yaml b/deploy/aos-olm/values.yaml new file mode 100644 index 0000000000..feaf8c8960 --- /dev/null +++ b/deploy/aos-olm/values.yaml @@ -0,0 +1,22 @@ +rbacApiVersion: rbac.authorization.k8s.io +namespace: operator-lifecycle-manager +catalog_namespace: operator-lifecycle-manager +alm: + replicaCount: 1 + image: + ref: quay.io/coreos/olm@sha256:351f0c4973a88a4ea606721555829776429b0ecb53d5a2bfee6bce459d109e5b + pullPolicy: IfNotPresent + service: + internalPort: 8080 + +catalog: + replicaCount: 1 + image: + ref: quay.io/coreos/catalog@sha256:54571e25474a9a063a144922e7321203e5aa5e63d03f748682d559341359a916 + pullPolicy: IfNotPresent + service: + internalPort: 8080 + +catalog_sources: + - tectonic-ocs + - upstream-components diff --git a/deploy/namespace.yaml b/deploy/namespace.yaml deleted file mode 100644 index 110a1efc33..0000000000 --- a/deploy/namespace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: alm \ No newline at end of file diff --git a/deploy/role/defaults/main.yaml b/deploy/role/defaults/main.yaml new file mode 100644 index 0000000000..a3c1815244 --- /dev/null +++ b/deploy/role/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +operator_lifecycle_manager_remove: false +operator_lifecycle_manager_install: true diff --git a/deploy/role/files/.gitkeep b/deploy/role/files/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/deploy/role/meta/main.yaml b/deploy/role/meta/main.yaml new file mode 100644 index 0000000000..9a3c4783f5 --- /dev/null +++ b/deploy/role/meta/main.yaml @@ -0,0 +1,16 @@ +--- +galaxy_info: + author: Evan Cordell + description: Operator Lifecycle Manager + company: Red Hat, Inc. + license: Apache License, Version 2.0 + min_ansible_version: 2.1 + platforms: + - name: EL + versions: + - 7 + categories: + - cloud +dependencies: +- role: lib_utils +- role: lib_openshift diff --git a/deploy/role/tasks/install.yaml b/deploy/role/tasks/install.yaml new file mode 100644 index 0000000000..472a1499a0 --- /dev/null +++ b/deploy/role/tasks/install.yaml @@ -0,0 +1,19 @@ +--- + +- name: create operator-lifecycle-manager project + oc_project: + name: operator-lifecycle-manager + state: present + node_selector: + - "" + +- name: Make temp directory for manifests + command: mktemp -d /tmp/olm-ansible-XXXXXX + register: mktemp + changed_when: False + +- name: Copy manifests to temp directory + copy: + src: "{{ item }}" + dest: "{{ mktemp.stdout }}" + with_fileglob: files/*.yaml \ No newline at end of file diff --git a/deploy/role/tasks/main.yaml b/deploy/role/tasks/main.yaml new file mode 100644 index 0000000000..92e094fe46 --- /dev/null +++ b/deploy/role/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +# do any asserts here + +- include_tasks: install.yaml + when: operator_lifecycle_manager_install | bool + +- include_tasks: remove.yaml + when: operator_lifecycle_manager_remove | bool diff --git a/deploy/role/tasks/remove.yaml b/deploy/role/tasks/remove.yaml new file mode 100644 index 0000000000..c62698929e --- /dev/null +++ b/deploy/role/tasks/remove.yaml @@ -0,0 +1,8 @@ +--- + +- import_tasks: remove_components.yaml + +- name: remove openshift-ansible-service-broker project + oc_project: + name: openshift-ansible-service-broker + state: absent diff --git a/deploy/role/tasks/remove_components.yaml b/deploy/role/tasks/remove_components.yaml new file mode 100644 index 0000000000..73b314ff7c --- /dev/null +++ b/deploy/role/tasks/remove_components.yaml @@ -0,0 +1 @@ +--- \ No newline at end of file diff --git a/scripts/k8s_yaml_to_ansible_install.sh b/scripts/k8s_yaml_to_ansible_install.sh new file mode 100755 index 0000000000..f1b1669977 --- /dev/null +++ b/scripts/k8s_yaml_to_ansible_install.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# requires yq to be installed https://github.com/mikefarah/yq + +if [[ ${#@} < 2 ]]; then + echo "Usage: $0 manifests outfile" + echo "* manifests: directory of k8s manifests" + echo "* outfile: the ansible file to append" + exit 1 +fi + +manifests=$1 +outfile=$2 + +for filename in $manifests/*.yaml; do + kind=$(yq r "$filename" kind) + name=$(yq r "$filename" metadata.name) + cat <> $outfile + +- name: Apply $name $kind manifest + oc_obj: + state: present + kind: $kind + name: $name + namespace: operator-lifecycle-manager + files: + - "{{ mktemp.stdout }}/$(basename $filename)" +EOF +done diff --git a/scripts/k8s_yaml_to_ansible_remove.sh b/scripts/k8s_yaml_to_ansible_remove.sh new file mode 100755 index 0000000000..7e92789720 --- /dev/null +++ b/scripts/k8s_yaml_to_ansible_remove.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# requires yq to be installed https://github.com/mikefarah/yq + +if [[ ${#@} < 2 ]]; then + echo "Usage: $0 manifests outfile" + echo "* manifests: directory of k8s manifests" + echo "* outfile: the ansible file to append" + exit 1 +fi + +manifests=$1 +outfile=$2 + +for filename in $manifests/*.yaml; do + kind=$(yq r "$filename" kind) + name=$(yq r "$filename" metadata.name) + cat <> $outfile + +- name: Remove $name $kind manifest + oc_obj: + state: absent + kind: $kind + name: $name + namespace: operator-lifecycle-manager +EOF +done diff --git a/scripts/package-release.sh b/scripts/package-release.sh index 14c41c9a71..13e3db12db 100755 --- a/scripts/package-release.sh +++ b/scripts/package-release.sh @@ -3,7 +3,7 @@ # requires helm to be installed if [[ ${#@} < 3 ]]; then - echo "Usage: $0 version alm-sha catalog-sha" + echo "Usage: $0 semver chart values" echo "* semver: semver-formatted version for this package" echo "* chart: the directory to output the chart" echo "* values: the values file" From d0626c3e918b09bd4e599c22a3e8b7bd945344d5 Mon Sep 17 00:00:00 2001 From: Evan Cordell Date: Tue, 22 May 2018 08:46:42 -0400 Subject: [PATCH 2/4] chore(deploy): add openshift_ansible as a submodule in order to symlink lib_openshift and lib_utils --- .gitmodules | 3 +++ deploy/aos-olm/openshift-ansible | 1 + deploy/aos-olm/playbook/private/roles/lib_openshift | 1 + deploy/aos-olm/playbook/private/roles/lib_utils | 1 + 4 files changed, 6 insertions(+) create mode 100644 .gitmodules create mode 160000 deploy/aos-olm/openshift-ansible create mode 120000 deploy/aos-olm/playbook/private/roles/lib_openshift create mode 120000 deploy/aos-olm/playbook/private/roles/lib_utils diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..08fe7b203e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "deploy/aos-olm/openshift-ansible"] + path = deploy/aos-olm/openshift-ansible + url = https://github.com/openshift/openshift-ansible diff --git a/deploy/aos-olm/openshift-ansible b/deploy/aos-olm/openshift-ansible new file mode 160000 index 0000000000..ed37b6d3b5 --- /dev/null +++ b/deploy/aos-olm/openshift-ansible @@ -0,0 +1 @@ +Subproject commit ed37b6d3b524ba26509821d6e9bfa60c5ef18530 diff --git a/deploy/aos-olm/playbook/private/roles/lib_openshift b/deploy/aos-olm/playbook/private/roles/lib_openshift new file mode 120000 index 0000000000..c903361249 --- /dev/null +++ b/deploy/aos-olm/playbook/private/roles/lib_openshift @@ -0,0 +1 @@ +../../../openshift-ansible/roles/lib_openshift \ No newline at end of file diff --git a/deploy/aos-olm/playbook/private/roles/lib_utils b/deploy/aos-olm/playbook/private/roles/lib_utils new file mode 120000 index 0000000000..d384e2a676 --- /dev/null +++ b/deploy/aos-olm/playbook/private/roles/lib_utils @@ -0,0 +1 @@ +../../../openshift-ansible/roles/lib_utils \ No newline at end of file From 96be8a36c5c78040c0b3a035470acd1cf8f5e374 Mon Sep 17 00:00:00 2001 From: Evan Cordell Date: Thu, 24 May 2018 14:29:17 -0400 Subject: [PATCH 3/4] feat(build): add rhel build for eventual inclusion into openshift. didn't add to our CI now since we know we won't need this just yet --- Dockerfile.rhel7 | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Dockerfile.rhel7 diff --git a/Dockerfile.rhel7 b/Dockerfile.rhel7 new file mode 100644 index 0000000000..c58b05e39c --- /dev/null +++ b/Dockerfile.rhel7 @@ -0,0 +1,12 @@ +FROM registry.centos.org/centos/centos:7 + +RUN yum update -y +RUN yum install -y golang make + +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH + +WORKDIR /go/src/github.com/operator-framework/operator-lifecycle-manager +COPY . . + +RUN make build From b33ae2e20a2aab895140ba6582d45d26f8841a45 Mon Sep 17 00:00:00 2001 From: Evan Cordell Date: Tue, 29 May 2018 15:15:37 -0400 Subject: [PATCH 4/4] fix(ansible): make sure git submodules are checked out before ansible build --- Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4a35578078..ca48ccb33c 100644 --- a/Makefile +++ b/Makefile @@ -169,15 +169,18 @@ $(YQ): # make ver=0.3.0 ansible-release ansible-release: $(YQ) + # ansible release uses openshift-ansible submodule + git submodule init + git submodule update # copy base role to versioned release mkdir -p deploy/aos-olm/$(ver) - cp -R deploy/role/ deploy/aos-olm/$(ver)/ + cp -R deploy/role/. deploy/aos-olm/$(ver)/ # copy manifest files into release ./scripts/package-release.sh $(ver) deploy/aos-olm/$(ver)/files deploy/aos-olm/values.yaml # generate install/remove tasks based on manifest files ./scripts/k8s_yaml_to_ansible_install.sh deploy/aos-olm/$(ver)/files deploy/aos-olm/$(ver)/tasks/install.yaml ./scripts/k8s_yaml_to_ansible_remove.sh deploy/aos-olm/$(ver)/files deploy/aos-olm/$(ver)/tasks/remove_components.yaml # link newest release into playbook - ln -sF ../../../../deploy/aos-olm/$(ver) deploy/aos-olm/playbook/private/roles/olm + ln -sfF ../../../../deploy/aos-olm/$(ver) deploy/aos-olm/playbook/private/roles/olm -release: tectonic-release upstream-release ansible-release \ No newline at end of file +release: tectonic-release upstream-release ansible-release