diff --git a/Containerfile.agent b/Containerfile.agent index 822ef50..9399180 100644 --- a/Containerfile.agent +++ b/Containerfile.agent @@ -1,8 +1,8 @@ -FROM docker.io/library/alpine as ui +FROM registry.access.redhat.com/ubi9/ubi as ui WORKDIR /app RUN mkdir /app/www && \ - wget -O /tmp/agent-latest.tgz https://github.com/kubev2v/migration-planner-ui/releases/download/latest/agent-latest.tgz && \ + curl -Lo /tmp/agent-latest.tgz https://github.com/kubev2v/migration-planner-ui/releases/download/latest/agent-latest.tgz && \ tar xf /tmp/agent-latest.tgz -C /app/www # Builder container diff --git a/Containerfile.api b/Containerfile.api index cebd22c..fd0b0b1 100644 --- a/Containerfile.api +++ b/Containerfile.api @@ -1,11 +1,9 @@ # Builder container -FROM registry.access.redhat.com/ubi9/go-toolset as iso -WORKDIR /iso -RUN curl -o /iso/rhcos-live.x86_64.iso https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/latest/rhcos-live.x86_64.iso - FROM registry.access.redhat.com/ubi9/go-toolset as builder WORKDIR /app +RUN curl -o /app/rhcos-live.x86_64.iso https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/latest/rhcos-live.x86_64.iso + COPY go.mod go.sum ./ RUN go mod download @@ -20,7 +18,7 @@ WORKDIR /app COPY /data /app/data/ COPY --from=builder /planner-api /app/ -COPY --from=iso /iso/rhcos-live.x86_64.iso /app/ +COPY --from=builder /app/rhcos-live.x86_64.iso /app/ # Use non-root user RUN chown -R 1001:0 /app diff --git a/Makefile b/Makefile index e9ffa64..cae7621 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ VERBOSE ?= false MIGRATION_PLANNER_AGENT_IMAGE ?= quay.io/kubev2v/migration-planner-agent MIGRATION_PLANNER_COLLECTOR_IMAGE ?= quay.io/kubev2v/migration-planner-collector MIGRATION_PLANNER_API_IMAGE ?= quay.io/kubev2v/migration-planner-api +MIGRATION_PLANNER_UI_IMAGE ?= quay.io/kubev2v/migration-planner-ui SOURCE_GIT_TAG ?=$(shell git describe --always --long --tags --abbrev=7 --match 'v[0-9]*' || echo 'v0.0.0-unknown-$(SOURCE_GIT_COMMIT)') SOURCE_GIT_TREE_STATE ?=$(shell ( ( [ ! -d ".git/" ] || git diff --quiet ) && echo 'clean' ) || echo 'dirty') @@ -85,6 +86,8 @@ push-containers: build-containers podman push $(MIGRATION_PLANNER_AGENT_IMAGE):latest deploy-on-openshift: + sed 's|@MIGRATION_PLANNER_API_IMAGE@|$(MIGRATION_PLANNER_API_IMAGE)|g' deploy/k8s/migration-planner.yaml.template > deploy/k8s/migration-planner.yaml + sed 's|@MIGRATION_PLANNER_UI_IMAGE@|$(MIGRATION_PLANNER_UI_IMAGE)|g' deploy/k8s/migration-planner-ui.yaml.template > deploy/k8s/migration-planner-ui.yaml oc apply -f 'deploy/k8s/*-service.yaml' oc apply -f 'deploy/k8s/*-secret.yaml' oc create route edge planner --service=migration-planner-ui || true diff --git a/data/config.ign.template b/data/config.ign.template index f3d6496..887c327 100644 --- a/data/config.ign.template +++ b/data/config.ign.template @@ -78,7 +78,7 @@ storage: name: core group: name: core - - path: /home/core/.config/systemd/user/planner-setup.service + - path: /home/core/.config/containers/systemd/planner-setup.container mode: 0644 contents: inline: | @@ -86,14 +86,18 @@ storage: Description=Prepare data volume for the container Before=planner-agent.service - [Service] - ExecStart=/usr/bin/podman run --rm -v planner.volume:/agent -v /home/core/vol:/mnt:Z alpine sh -c "cp -r /mnt/* /agent/ && chmod -R a+rwx /agent" + [Container] + Image=registry.access.redhat.com/ubi9/ubi-micro + Exec=sh -c "cp -r /mnt/* /agent/ && chmod -R a+rwx /agent" + Volume=planner.volume:/agent + Volume=/home/core/vol:/mnt:Z + [Service] Type=oneshot RemainAfterExit=yes [Install] - WantedBy=multi-user.target + WantedBy=multi-user.target default.target - path: /home/core/.config/containers/systemd/planner-agent.container mode: 0644 contents: @@ -103,7 +107,7 @@ storage: Wants=planner-setup.service [Container] - Image=quay.io/kubev2v/migration-planner-agent + Image=@MIGRATION_PLANNER_AGENT_IMAGE@ ContainerName=planner-agent AutoUpdate=registry Exec= -config /agent/config.yaml @@ -140,7 +144,7 @@ storage: Wants=planner-agent-opa.service [Container] - Image=quay.io/kubev2v/migration-planner-collector + Image=@MIGRATION_PLANNER_COLLECTOR_IMAGE@ ContainerName=migration-planner-collector AutoUpdate=registry Exec=/vol/data/credentials.json /vol/data/inventory.json diff --git a/deploy/k8s/migration-planner-ui.yaml b/deploy/k8s/migration-planner-ui.yaml index cb64144..7d344ef 100644 --- a/deploy/k8s/migration-planner-ui.yaml +++ b/deploy/k8s/migration-planner-ui.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: migration-planner-ui - image: quay.io/machacekondra/migration-planner-ui + image: quay.io/kubev2v/migration-planner-ui imagePullPolicy: Always ports: - containerPort: 8080 diff --git a/deploy/k8s/migration-planner-ui.yaml.template b/deploy/k8s/migration-planner-ui.yaml.template new file mode 100644 index 0000000..e940cd1 --- /dev/null +++ b/deploy/k8s/migration-planner-ui.yaml.template @@ -0,0 +1,21 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + name: migration-planner-ui +spec: + replicas: 1 + selector: + matchLabels: + app: migration-planner-ui + template: + metadata: + labels: + app: migration-planner-ui + spec: + containers: + - name: migration-planner-ui + image: @MIGRATION_PLANNER_UI_IMAGE@ + imagePullPolicy: Always + ports: + - containerPort: 8080 + restartPolicy: Always diff --git a/deploy/k8s/migration-planner.yaml.template b/deploy/k8s/migration-planner.yaml.template new file mode 100644 index 0000000..2b35dc4 --- /dev/null +++ b/deploy/k8s/migration-planner.yaml.template @@ -0,0 +1,57 @@ +apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 +kind: Deployment +metadata: + name: migration-planner +spec: + selector: + matchLabels: + app: migration-planner + replicas: 1 + template: + metadata: + labels: + app: migration-planner + spec: + containers: + - name: migration-planner + resources: + limits: + cpu: 500m + memory: 2000Mi + requests: + cpu: 300m + memory: 400Mi + image: @MIGRATION_PLANNER_API_IMAGE@ + imagePullPolicy: Always + ports: + - containerPort: 3443 + livenessProbe: + httpGet: + path: /health + port: 3443 + initialDelaySeconds: 30 + env: + - name: CONFIG_SERVER + valueFrom: + secretKeyRef: + name: migration-planner-secret + key: config_server + volumeMounts: + - name: migration-planner-config + mountPath: "/.migration-planner/config.yaml" + subPath: config.yaml + readOnly: true + serviceAccountName: migration-planner + volumes: + - name: migration-planner-config + secret: + secretName: migration-planner-rds + optional: true + items: + - key: config.yaml + path: config.yaml +--- +kind: ServiceAccount +apiVersion: v1 +metadata: + name: migration-planner diff --git a/internal/image/ova.go b/internal/image/ova.go index ed53cff..4cf6c61 100644 --- a/internal/image/ova.go +++ b/internal/image/ova.go @@ -118,6 +118,8 @@ func (o *Ova) generateIgnition() (string, error) { butaneContent := strings.Replace(string(butaneTemplate), "@CONFIG_ID@", o.Id.String(), -1) butaneContent = strings.Replace(butaneContent, "@CONFIG_SERVER@", util.GetEnv("CONFIG_SERVER", "http://127.0.0.1:7443"), -1) + butaneContent = strings.Replace(butaneContent, "@MIGRATION_PLANNER_COLLECTOR_IMAGE@", util.GetEnv("MIGRATION_PLANNER_COLLECTOR_IMAGE", "quay.io/kubev2v/migration-planner-collector"), -1) + butaneContent = strings.Replace(butaneContent, "@MIGRATION_PLANNER_AGENT_IMAGE@", util.GetEnv("MIGRATION_PLANNER_AGENT_IMAGE", "quay.io/kubev2v/migration-planner-agent"), -1) dataOut, _, err := config.TranslateBytes([]byte(butaneContent), common.TranslateBytesOptions{}) if err != nil {