Skip to content

Commit

Permalink
Merge "Revert "Build iso image in a single phase""
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Nov 19, 2021
2 parents 0dc7073 + 6ac83b3 commit 6d79781
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 31 deletions.
4 changes: 2 additions & 2 deletions krm-functions/cloud-init/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
ARG GO_IMAGE=quay.io/airshipit/golang:1.16.8-buster
ARG RELEASE_IMAGE=quay.io/airshipit/image-builder:k8s-1.21-latest-ubuntu_focal

ARG RELEASE_IMAGE=quay.io/airshipit/alpine:3.13.5
FROM ${GO_IMAGE} as builder
ARG GOPROXY=""

Expand Down Expand Up @@ -29,4 +28,5 @@ RUN make ${MAKE_TARGET}
FROM ${RELEASE_IMAGE} as release
ARG MAKE_TARGET=bin/cloud-init
COPY --from=builder /usr/src/airshipctl/${MAKE_TARGET} /usr/local/bin/config-function
USER 65534
CMD ["/usr/local/bin/config-function"]
13 changes: 1 addition & 12 deletions krm-functions/cloud-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ package main
import (
"errors"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"

"sigs.k8s.io/kustomize/api/provider"
Expand Down Expand Up @@ -69,15 +67,6 @@ func docFromRNode(rnode *yaml.RNode) (document.Document, error) {
return collection[0], nil
}

func runCmd(cmd string, opts ...string) error {
c := exec.Command(cmd, opts...)
// allows to observe realtime output from script
w := io.Writer(os.Stderr)
c.Stdout = w
c.Stderr = w
return c.Run()
}

func main() {
fn := func(rl *framework.ResourceList) error {
functionConfigDocument, err := docFromRNode(rl.FunctionConfig)
Expand Down Expand Up @@ -124,7 +113,7 @@ func main() {
}

rl.Items = []*yaml.RNode{}
return runCmd("/usr/bin/local/entrypoint.sh")
return nil
}
cmd := command.Build(framework.ResourceListProcessorFunc(fn), command.StandaloneEnabled, false)
if err := cmd.Execute(); err != nil {
Expand Down
56 changes: 42 additions & 14 deletions manifests/phases/executors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ spec:
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
metadata:
name: iso-build-image
name: iso-cloud-init-data
labels:
airshipit.org/deploy-k8s: "false"
spec:
Expand All @@ -263,19 +263,6 @@ spec:
src: /srv/images
dst: /config
rw: true
envVars:
- IMAGE_TYPE=iso
- BUILDER_CONFIG=/config/builder-conf.yaml
- USER_DATA_FILE=user-data
- NET_CONFIG_FILE=network-data
- OUTPUT_FILE_NAME=ephemeral.iso
- OUTPUT_METADATA_FILE_NAME=output1-metadata.yaml
- http_proxy
- https_proxy
- HTTP_PROXY
- HTTPS_PROXY
- no_proxy
- NO_PROXY
config: |
apiVersion: airshipit.org/v1alpha1
kind: IsoConfiguration
Expand All @@ -294,6 +281,47 @@ config: |
outputFileName: ephemeral.iso
container:
volume: /srv/images:/config # for compatibility with image-builder
---
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
metadata:
name: iso-build-image
labels:
airshipit.org/deploy-k8s: "false"
spec:
type: airship
airship:
privileged: true
containerRuntime: docker
cmd:
- /bin/bash
- -c
- /usr/bin/local/entrypoint.sh 1>&2
image: quay.io/airshipit/image-builder:k8s-1.19-latest-ubuntu_focal
mounts:
- type: bind
src: /srv/images
dst: /config
rw: true
envVars:
- IMAGE_TYPE=iso
- BUILDER_CONFIG=/config/builder-conf.yaml
- USER_DATA_FILE=user-data
- NET_CONFIG_FILE=network-data
- OUTPUT_FILE_NAME=ephemerial.iso
- OUTPUT_METADATA_FILE_NAME=output-metadata.yaml
- http_proxy
- https_proxy
- HTTP_PROXY
- HTTPS_PROXY
- no_proxy
- NO_PROXY
config: |
apiVersion: airshipit.org/v1alpha1
kind: DoesNotMatter
metadata:
name: isogen
---
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
Expand Down
12 changes: 11 additions & 1 deletion manifests/phases/phases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,24 @@ config:
---
apiVersion: airshipit.org/v1alpha1
kind: Phase
metadata:
name: iso-cloud-init-data
config:
executorRef:
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
name: iso-cloud-init-data
documentEntryPoint: ephemeral/bootstrap
---
apiVersion: airshipit.org/v1alpha1
kind: Phase
metadata:
name: iso-build-image
config:
executorRef:
apiVersion: airshipit.org/v1alpha1
kind: GenericContainer
name: iso-build-image
documentEntryPoint: ephemeral/bootstrap
---
apiVersion: airshipit.org/v1alpha1
kind: Phase
Expand Down
13 changes: 12 additions & 1 deletion manifests/phases/replacements/versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ metadata:
config.kubernetes.io/function: |-
container:
image: localhost/replacement-transformer
replacements: []
replacements:
- source:
objref:
kind: VersionsCatalogue
name: versions-airshipctl
fieldref: spec.images.image_builder.image_builder.image_builder.image
target:
objref:
kind: GenericContainer
name: iso-build-image
fieldrefs: ["spec.image"]

1 change: 1 addition & 0 deletions manifests/type/gating/phases/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ metadata:
name: iso
description: "Runs phases to build iso image"
phases:
- name: iso-cloud-init-data
- name: iso-build-image
validation:
kindsToSkip:
Expand Down
2 changes: 1 addition & 1 deletion tools/deployment/24_build_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sudo chown -R ${USER_NAME} ${IMAGE_DIR}
unset IFS
for plan in $IMAGE_PHASE_PLANS; do
echo "Build phase plan: $plan"
sudo --preserve-env=SOPS_IMPORT_PGP airshipctl plan run $plan --debug
airshipctl plan run $plan --debug
done

echo "List generated images"
Expand Down

0 comments on commit 6d79781

Please sign in to comment.