diff --git a/playbooks/airship-aiap-build-images.yaml b/playbooks/airship-aiap-build-images.yaml new file mode 100644 index 000000000..a99625e32 --- /dev/null +++ b/playbooks/airship-aiap-build-images.yaml @@ -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: + - docker-install + - aiap-build-images diff --git a/playbooks/airship-aiap-publish-images.yaml b/playbooks/airship-aiap-publish-images.yaml new file mode 100644 index 000000000..293d81d06 --- /dev/null +++ b/playbooks/airship-aiap-publish-images.yaml @@ -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: + - docker-install + - aiap-publish-images diff --git a/roles/aiap-build-images/tasks/main.yaml b/roles/aiap-build-images/tasks/main.yaml new file mode 100644 index 000000000..07bee0b14 --- /dev/null +++ b/roles/aiap-build-images/tasks/main.yaml @@ -0,0 +1,19 @@ +# 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: Build airship-in-a-pod Images + make: + chdir: "{{ zuul.project.src_dir }}/tools/airship-in-a-pod" + target: images + params: + DOCKER_REGISTRY: "{{ image_repo }}" + DOCKER_IMAGE_TAG: "{{ zuul.change }}" diff --git a/roles/aiap-publish-images/tasks/main.yaml b/roles/aiap-publish-images/tasks/main.yaml new file mode 100644 index 000000000..fff7168f2 --- /dev/null +++ b/roles/aiap-publish-images/tasks/main.yaml @@ -0,0 +1,41 @@ +# 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: "{{ airshipctl_image_repo_credentials.username }}" + password: "{{ airshipctl_image_repo_credentials.password }}" + registry_url: "{{ image_repo }}" + + - name: Push Image with Tags + make: + chdir: "{{ zuul.project.src_dir }}/tools/airship-in-a-pod" + target: images + params: + DOCKER_REGISTRY: "{{ image_repo }}" + DOCKER_IMAGE_TAG: "{{ item }}" + PUBLISH: "true" + loop: + - "latest" + - "{{ zuul.newrev }}" diff --git a/tools/airship-in-a-pod/Makefile b/tools/airship-in-a-pod/Makefile index d71f0b1f1..5a30e1fb0 100644 --- a/tools/airship-in-a-pod/Makefile +++ b/tools/airship-in-a-pod/Makefile @@ -1,10 +1,10 @@ -IMAGE_REGISTRY ?= quay.io/airshipit -IMAGES := infra-builder artifact-setup runner -IMAGE_TAG ?= latest +DOCKER_REGISTRY ?= quay.io +DOCKER_IMAGE_PREFIX ?= airshipit +DOCKER_IMAGE_TAG ?= latest +IMAGES ?= infra-builder artifact-setup runner +PUBLISH ?= false -PUSH_IMAGES ?= false - -.PHONY: help base libvirt $(IMAGES) build test +.PHONY: help base libvirt $(IMAGES) images test SHELL:=/bin/bash .ONESHELL: @@ -12,34 +12,34 @@ SHELL:=/bin/bash help: ## This help. @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) -build: base -build: libvirt -build: $(IMAGES) ## Build the containers. +images: base +images: libvirt +images: $(IMAGES) ## Build the containers. base: - docker build --tag $(IMAGE_REGISTRY)/aiap-base:$(IMAGE_TAG) --build-arg BASE_IMAGE=ubuntu:20.04 ./base -ifeq (true, $(PUSH_IMAGES)) - docker push $(IMAGE_REGISTRY)/aiap-base:$(IMAGE_TAG) + docker build --tag $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/aiap-base:$(DOCKER_IMAGE_TAG) --build-arg BASE_IMAGE=ubuntu:20.04 ./base +ifeq (true, $(PUBLISH)) + docker push $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/aiap-base:$(DOCKER_IMAGE_TAG) endif libvirt: - docker build --tag $(IMAGE_REGISTRY)/libvirt:$(IMAGE_TAG) ./libvirt -ifeq (true, $(PUSH_IMAGES)) - docker push $(IMAGE_REGISTRY)/libvirt:$(IMAGE_TAG) + docker build --tag $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/libvirt:$(DOCKER_IMAGE_TAG) ./libvirt +ifeq (true, $(PUBLISH)) + docker push $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/libvirt:$(DOCKER_IMAGE_TAG) endif $(IMAGES): - docker build --tag $(IMAGE_REGISTRY)/aiap-$@:$(IMAGE_TAG) ./$@ -ifeq (true, $(PUSH_IMAGES)) - docker push $(IMAGE_REGISTRY)/aiap-$@:$(IMAGE_TAG) + docker build --tag $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/aiap-$@:$(DOCKER_IMAGE_TAG) ./$@ +ifeq (true, $(PUBLISH)) + docker push $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/aiap-$@:$(DOCKER_IMAGE_TAG) endif test: test-airshipctl test-treasuremap -test-airshipctl: build - kubectl delete pod airship-in-a-pod || true +test-airshipctl: images + kubectl delete pod airship-in-a-pod || true kustomize build ./examples/airshipctl | kubectl apply -f - -test-treasuremap: build - kubectl delete pod airship-in-a-pod || true +test-treasuremap: images + kubectl delete pod airship-in-a-pod || true kustomize build ./examples/airshipctl | kubectl apply -f - diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 0095015a3..53cb41dfb 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -59,6 +59,13 @@ - ^.*\.md$ - ^\.github/.*$ +- job: + name: airship-aiap-build-image + nodeset: airship-airshipctl-single-node + run: playbooks/airship-aiap-build-images.yaml + files: + - ^tools/airship-in-a-pod/.*$ + - job: name: airship-airshipctl-validate-site-docs timeout: 6600 @@ -239,3 +246,15 @@ pass-to-parent: true vars: image: quay.io/airshipit/airshipctl +- job: + name: airship-aiap-publish-image + nodeset: airship-airshipctl-single-node + run: playbooks/airship-aiap-publish-images.yaml + files: + - ^tools/airship-in-a-pod/.*$ + secrets: + - name: airshipctl_image_repo_credentials + secret: airshipctl_image_repo_credentials + pass-to-parent: true + vars: + image: quay.io/airshipit/airshipctl diff --git a/zuul.d/projects.yaml b/zuul.d/projects.yaml index f2fa20063..93a936a7c 100644 --- a/zuul.d/projects.yaml +++ b/zuul.d/projects.yaml @@ -40,6 +40,7 @@ - airship-airshipctl-validate-site-docs # - airship-airshipctl-functional-existing-k8s TODO: Enable this when functional tests exist, and a cluster is up - airship-airshipctl-gate-script-runner-docker + - airship-aiap-build-image experimental: jobs: - airship-airshipctl-docker-kubebench-conformance @@ -53,11 +54,13 @@ - airship-airshipctl-build-image - airship-airshipctl-validate-site-docs - airship-airshipctl-gate-script-runner + - airship-aiap-build-image # - airship-airshipctl-functional-existing-k8s TODO: Enable this when functional tests exist, and a cluster is up post: jobs: - airship-airshipctl-publish-image + - airship-aiap-publish-image - airship-airshipctl-upload-git-mirror promote: jobs: