Zuul jobs to build and push Docker Image to quay.io
Added zuul jobs to build the hostconfig-operator image and the push the image to quay.io repository Updated the airship-hostconfig-operator-test zuul job to use make script to build the image instead of the operator-sdk command. Change-Id: I05dfd41d0517bc8f491a96b98916f9194e1a9531
This commit is contained in:
parent
46576c9cfe
commit
6934b606be
43
Dockerfile
Normal file
43
Dockerfile
Normal file
@ -0,0 +1,43 @@
|
||||
# Ansible Operator base image
|
||||
FROM quay.io/operator-framework/ansible-operator:v0.17.0
|
||||
|
||||
# Installing dependency libraries
|
||||
COPY airship-host-config/requirements.yml ${HOME}/requirements.yml
|
||||
RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \
|
||||
&& chmod -R ug+rwx ${HOME}/.ansible
|
||||
|
||||
# Configuration for ansible
|
||||
COPY airship-host-config/build/ansible.cfg /etc/ansible/ansible.cfg
|
||||
|
||||
# CRD entrypoint definition YAML file
|
||||
COPY airship-host-config/watches.yaml ${HOME}/watches.yaml
|
||||
|
||||
# Installing ssh clients - used to connect to kubernetes nodes
|
||||
USER root
|
||||
RUN dnf install openssh-clients -y
|
||||
RUN dnf install -y wget && \
|
||||
wget -O /tmp/epel-release-6-8.noarch.rpm \
|
||||
http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm \
|
||||
&& rpm -ivh /tmp/epel-release-6-8.noarch.rpm \
|
||||
&& dnf -y install sshpass
|
||||
USER ansible-operator
|
||||
|
||||
# Copying the configuration roles
|
||||
COPY airship-host-config/roles/ ${HOME}/roles/
|
||||
|
||||
# Copying the entry-point playbook
|
||||
COPY airship-host-config/playbooks/ ${HOME}/playbooks/
|
||||
|
||||
# Copying inventory - used to build the kubernetes nodes dynamically
|
||||
COPY airship-host-config/inventory/ ${HOME}/inventory/
|
||||
|
||||
# Copying filter and callback plugins used for computation
|
||||
COPY airship-host-config/plugins/ ${HOME}/plugins/
|
||||
|
||||
# ansible-runner unable to pick custom callback plugins specified in any other directory other than /usr/local/lib/python3.6/site-packages/ansible/plugins/callback
|
||||
# ansible-runner is overriding the ANSIBLE_CALLBACK_PLUGINS Environment variable
|
||||
# https://github.com/ansible/ansible-runner/blob/stable/1.3.x/ansible_runner/runner_config.py#L178
|
||||
COPY airship-host-config/plugins/callback/hostconfig_k8_cr_status.py /usr/local/lib/python3.6/site-packages/ansible/plugins/callback/
|
||||
|
||||
# Intializing ssh folder
|
||||
RUN mkdir ${HOME}/.ssh
|
44
Makefile
Normal file
44
Makefile
Normal file
@ -0,0 +1,44 @@
|
||||
SHELL := /bin/bash
|
||||
|
||||
GIT_VERSION ?= v0.1.0
|
||||
GIT_MODULE ?= opendev.org/airship/hostconfig-operator/pkg/version
|
||||
|
||||
# docker image options
|
||||
DOCKER_REGISTRY ?= quay.io
|
||||
DOCKER_FORCE_CLEAN ?= true
|
||||
DOCKER_IMAGE_NAME ?= hostconfig-operator
|
||||
DOCKER_IMAGE_PREFIX ?= airshipit
|
||||
DOCKER_IMAGE_TAG ?= dev
|
||||
DOCKER_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
|
||||
|
||||
# proxy options
|
||||
PROXY ?= http://proxy.foo.com:8000
|
||||
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
|
||||
USE_PROXY ?= false
|
||||
|
||||
# Build hostconfig-operator image
|
||||
.PHONY: images
|
||||
images:
|
||||
ifeq ($(USE_PROXY), true)
|
||||
@docker build . --tag $(DOCKER_IMAGE) \
|
||||
--build-arg http_proxy=$(PROXY) \
|
||||
--build-arg https_proxy=$(PROXY) \
|
||||
--build-arg HTTP_PROXY=$(PROXY) \
|
||||
--build-arg HTTPS_PROXY=$(PROXY) \
|
||||
--build-arg no_proxy=$(NO_PROXY) \
|
||||
--build-arg NO_PROXY=$(NO_PROXY) \
|
||||
--force-rm=$(DOCKER_FORCE_CLEAN)
|
||||
else
|
||||
@docker build . --tag $(DOCKER_IMAGE) \
|
||||
--force-rm=$(DOCKER_FORCE_CLEAN)
|
||||
endif
|
||||
# Publishing hostconfig-operator image to quay.io
|
||||
ifeq ($(PUBLISH), true)
|
||||
@echo 'publish hostconfig image to quay.io with image name $(DOCKER_IMAGE)'
|
||||
@docker push $(DOCKER_IMAGE)
|
||||
endif
|
||||
|
||||
# Priniting docker image tag
|
||||
.PHONY: print-docker-image-tag
|
||||
print-docker-image-tag:
|
||||
@echo "$(DOCKER_IMAGE)"
|
@ -31,8 +31,8 @@ spec:
|
||||
effect: NoSchedule
|
||||
containers:
|
||||
- name: airship-host-config
|
||||
image: "airship-hostconfig:local"
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
image: "AIRSHIP_HOSTCONFIG_IMAGE"
|
||||
imagePullPolicy: "PULL_POLICY"
|
||||
volumeMounts:
|
||||
- mountPath: /tmp/ansible-operator/runner
|
||||
name: runner
|
||||
|
17
playbooks/airship-hostconfig-operator-build-images.yaml
Normal file
17
playbooks/airship-hostconfig-operator-build-images.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- hosts: all
|
||||
become: yes
|
||||
roles:
|
||||
- role: ensure-docker
|
||||
- hostconfig-operator-build-images
|
17
playbooks/airship-hostconfig-operator-publish-images.yaml
Normal file
17
playbooks/airship-hostconfig-operator-publish-images.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- hosts: all
|
||||
become: yes
|
||||
roles:
|
||||
- ensure-docker
|
||||
- hostconfig-operator-publish-images
|
@ -15,15 +15,19 @@
|
||||
- name: "set default gate scripts"
|
||||
set_fact:
|
||||
gate_scripts_default:
|
||||
- ./tools/deployment/host_config/01_install_kubectl.sh
|
||||
- ./tools/deployment/host_config/10_test_config.sh
|
||||
- ./tools/deployment/host_config/20_deploy_k8cluster_vagrant.sh
|
||||
- ./tools/deployment/host_config/30_deploy_host_config.sh
|
||||
- ./tools/deployment/host_config/40_test_host_config_cr.sh
|
||||
- ./tools/deployment/00_install_kind.sh
|
||||
- ./tools/deployment/01_install_kubectl.sh
|
||||
- ./tools/deployment/10_create_hostconfig_cluster.sh
|
||||
- ./tools/deployment/20_configure_ssh_on_nodes.sh
|
||||
- ./tools/deployment/30_create_labels.sh
|
||||
- ./tools/deployment/40_deploy_hostconfig_operator.sh
|
||||
- ./tools/deployment/50_test_hostconfig_cr.sh
|
||||
- ./tools/deployment/51_test_hostconfig_cr_reconcile.sh
|
||||
- ./tools/deployment/52_test_hostconfig_cr_failure.sh
|
||||
|
||||
- name: "Run gate scripts"
|
||||
include_role:
|
||||
name: hostconfig-run-script
|
||||
name: hostconfig-operator-run-script
|
||||
vars:
|
||||
gate_script_path: "{{ item }}"
|
||||
with_items: "{{ gate_scripts | default(gate_scripts_default) }}"
|
@ -77,4 +77,3 @@
|
||||
file:
|
||||
path: /var/run/docker.sock
|
||||
group: docker
|
||||
|
||||
|
@ -22,4 +22,3 @@
|
||||
assert:
|
||||
that:
|
||||
- docker_version.rc == 0
|
||||
|
||||
|
18
tools/deployment/02_install_operator_sdk.sh → roles/hostconfig-operator-build-images/tasks/main.yaml
Executable file → Normal file
18
tools/deployment/02_install_operator_sdk.sh → roles/hostconfig-operator-build-images/tasks/main.yaml
Executable file → Normal file
@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@ -12,12 +10,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -xe
|
||||
- name: Build hostconfig-operator Image
|
||||
make:
|
||||
chdir: "{{ zuul.project.src_dir }}"
|
||||
target: images
|
||||
|
||||
RELEASE_VERSION=v0.8.0
|
||||
|
||||
echo "Installing Operator-SDK to build image"
|
||||
|
||||
wget -O operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
|
||||
chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
|
||||
sudo mv operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/operator-sdk
|
||||
- name: Verify Image Exists
|
||||
shell: docker image inspect "$(make print-docker-image-tag)"
|
||||
args:
|
||||
chdir: "{{ zuul.project.src_dir }}"
|
45
roles/hostconfig-operator-publish-images/tasks/main.yaml
Normal file
45
roles/hostconfig-operator-publish-images/tasks/main.yaml
Normal file
@ -0,0 +1,45 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Install python3-docker and python3-requests Modules
|
||||
package:
|
||||
name:
|
||||
- python3-docker
|
||||
- python3-requests
|
||||
state: present
|
||||
|
||||
- name: List Docker Images
|
||||
shell: docker image ls
|
||||
|
||||
- name: Push Images
|
||||
block:
|
||||
- name: Login to Image Registry
|
||||
docker_login:
|
||||
username: "{{ hostconfig_operator_image_repo_credentials.username }}"
|
||||
password: "{{ hostconfig_operator_image_repo_credentials.password }}"
|
||||
registry_url: "{{ image_repo }}"
|
||||
|
||||
- name: Push Image with Latest Tag
|
||||
make:
|
||||
chdir: "{{ zuul.project.src_dir }}"
|
||||
params:
|
||||
DOCKER_IMAGE_TAG: latest
|
||||
PUBLISH: "true"
|
||||
target: images
|
||||
|
||||
- name: Push Image with Commit Tag
|
||||
make:
|
||||
chdir: "{{ zuul.project.src_dir }}"
|
||||
params:
|
||||
DOCKER_IMAGE_TAG: "{{ zuul.newrev }}"
|
||||
PUBLISH: "true"
|
||||
target: images
|
@ -16,19 +16,18 @@ set -xe
|
||||
|
||||
export HOSTCONFIG_WS=${HOSTCONFIG_WS:-$PWD}
|
||||
export HOSTCONFIG=${HOSTCONFIG:-"$HOSTCONFIG_WS/airship-host-config"}
|
||||
export IMAGE_NAME=${IMAGE_NAME:-"airship-hostconfig:local"}
|
||||
|
||||
# Building hostconfig image
|
||||
cd $HOSTCONFIG
|
||||
operator-sdk build $IMAGE_NAME
|
||||
make images
|
||||
|
||||
DOCKER_IMAGE=$(make print-docker-image-tag)
|
||||
|
||||
# Copying hostconfig image to nodes
|
||||
kind load docker-image $IMAGE_NAME --name hostconfig
|
||||
kind load docker-image $DOCKER_IMAGE --name hostconfig
|
||||
|
||||
# Deploying HostConfig Operator Pod
|
||||
cd $HOSTCONFIG_WS
|
||||
sed -i "s/AIRSHIP_HOSTCONFIG_IMAGE/$IMAGE_NAME/g" $HOSTCONFIG/deploy/operator.yaml
|
||||
sed -i "s/PULL_POLICY/IfNotPresent/g" $HOSTCONFIG/deploy/operator.yaml
|
||||
sed -i "s|AIRSHIP_HOSTCONFIG_IMAGE|$DOCKER_IMAGE|g" $HOSTCONFIG/deploy/operator.yaml
|
||||
sed -i "s|PULL_POLICY|IfNotPresent|g" $HOSTCONFIG/deploy/operator.yaml
|
||||
|
||||
kubectl apply -f $HOSTCONFIG/deploy/crds/hostconfig.airshipit.org_hostconfigs_crd.yaml
|
||||
kubectl apply -f $HOSTCONFIG/deploy/role.yaml
|
||||
|
@ -11,18 +11,17 @@
|
||||
# limitations under the License.
|
||||
|
||||
- job:
|
||||
name: airship-host-config
|
||||
name: airship-hostconfig-operator-test
|
||||
nodeset: airship-hostconfig-single-node
|
||||
pre-run: playbooks/airship-hostconfig-deploy-docker.yaml
|
||||
pre-run: playbooks/airship-hostconfig-operator-deploy-docker.yaml
|
||||
timeout: 3600
|
||||
run: playbooks/airship-host-config.yaml
|
||||
run: playbooks/airship-hostconfig-operator.yaml
|
||||
post-run: playbooks/airship-collect-logs.yaml
|
||||
attempts: 1
|
||||
vars:
|
||||
gate_scripts:
|
||||
- ./tools/deployment/00_install_kind.sh
|
||||
- ./tools/deployment/01_install_kubectl.sh
|
||||
- ./tools/deployment/02_install_operator_sdk.sh
|
||||
- ./tools/deployment/10_create_hostconfig_cluster.sh
|
||||
- ./tools/deployment/20_configure_ssh_on_nodes.sh
|
||||
- ./tools/deployment/30_create_labels.sh
|
||||
@ -31,3 +30,23 @@
|
||||
- ./tools/deployment/51_test_hostconfig_cr_reconcile.sh
|
||||
- ./tools/deployment/52_test_hostconfig_cr_failure.sh
|
||||
voting: false
|
||||
|
||||
- job:
|
||||
name: airship-hostconfig-operator-build-image
|
||||
nodeset: airship-hostconfig-single-node
|
||||
run: playbooks/airship-hostconfig-operator-build-images.yaml
|
||||
irrelevant-files:
|
||||
- ^.*\.md$
|
||||
- ^docs/.*$
|
||||
|
||||
- job:
|
||||
name: airship-hostconfig-operator-publish-image
|
||||
parent: airship-hostconfig-operator-build-image
|
||||
post-run: playbooks/airship-hostconfig-operator-publish-images.yaml
|
||||
secrets:
|
||||
- name: hostconfig_operator_image_repo_credentials
|
||||
secret: hostconfig_operator_image_repo_credentials
|
||||
pass-to-parent: true
|
||||
vars:
|
||||
image: quay.io/airshipit/hostconfig-operator
|
||||
image_repo: https://quay.io/api/v1/
|
||||
|
@ -15,13 +15,3 @@
|
||||
nodes:
|
||||
- name: primary
|
||||
label: ubuntu-bionic
|
||||
- nodeset:
|
||||
name: airship-hostconfig-single-16GB-bionic-node
|
||||
nodes:
|
||||
- name: primary
|
||||
label: ubuntu-bionic-expanded
|
||||
- nodeset:
|
||||
name: airship-hostconfig-single-32GB-bionic-node
|
||||
nodes:
|
||||
- name: primary
|
||||
label: ubuntu-bionic-32GB
|
||||
|
@ -13,7 +13,12 @@
|
||||
- project:
|
||||
check:
|
||||
jobs:
|
||||
- airship-host-config
|
||||
- airship-hostconfig-operator-test
|
||||
- airship-hostconfig-operator-build-image
|
||||
gate:
|
||||
jobs:
|
||||
- noop
|
||||
- airship-hostconfig-operator-build-image
|
||||
post:
|
||||
jobs:
|
||||
- airship-hostconfig-operator-publish-image
|
||||
|
37
zuul.d/secrets.yaml
Normal file
37
zuul.d/secrets.yaml
Normal file
@ -0,0 +1,37 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- secret:
|
||||
name: hostconfig_operator_image_repo_credentials
|
||||
data:
|
||||
username: !encrypted/pkcs1-oaep
|
||||
- N52MSnXV26Yz3fFxLEKsw7CTnlr48qZHmwet6jsSveUSkBAv7ukJcxIHOw3A37Qa3oIzN
|
||||
koJXOz2B2iUok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Pksg9vN+1O80aU13jUlyNtyBEa9FSS/5lMJoQrXScPZX84Ov6HXB/vu8
|
||||
Qy3d3W8e42hBHEe5beQQXyj0ORPpMMiMIBVk0mIJekCHdDf0J3bYrR7P0ffyBNWGBUNdc
|
||||
3/xDt8JDas6tiDsDbV7B5yKj1WBQ45MWbBzeXoBi13t1g97QUxOTKPOwoenUax/T9lhbN
|
||||
ctn0mXOAjUtmPjS+DfDSt+BkPVLouT8bbSs+fJHE6Pi4jnuc8OEatbJQvlUMhAszsxmdy
|
||||
+8Gyyi2VKAheswe1aPiZ+FBXh9hDOMgL7toPnpYH7wBvTz6MROwbWqs+7x+2+Y=
|
Loading…
x
Reference in New Issue
Block a user