Skip to content

Commit

Permalink
Add implementation of OVA generation
Browse files Browse the repository at this point in the history
Signed-off-by: Ondra Machacek <[email protected]>
  • Loading branch information
machacekondra committed Sep 5, 2024
1 parent 5bbd41f commit e34d09f
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
examples/AgentVM.ova
examples/AgentVM-1.iso
examples/rhcos-live.x86_64.iso
rhcos-live.x86_64.iso
examples/config.ign
examples/config.yaml
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ tidy:
lint: tools
$(GOBIN)/golangci-lint run -v

build: bin
image:
curl --silent -C - -O https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/latest/rhcos-live.x86_64.iso

build: bin image
go build -buildvcs=false $(GO_BUILD_FLAGS) -o $(GOBIN) ./cmd/...

build-api: bin
Expand Down
File renamed without changes.
55 changes: 55 additions & 0 deletions data/config.ign.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"ignition": { "version": "3.0.0" },
"passwd": {
"users": [
{
"name": "core",
"passwordHash": "$y$j9T$hUUbW8zoB.Qcmpwm4/RuK1$FMtuDAxNLp3sEa2PnGiJdXr8uYbvUNPlVDXpcJim529"
}
]
},
"storage": {
"directories": [{
"path": "/var/home/core/vol",
"overwrite": true,
"user": {
"id": 1001
}
}, {
"path": "/var/home/core/vol/data",
"overwrite": true,
"user": {
"id": 1001
}
}, {
"path": "/var/home/core/vol/config",
"overwrite": true,
"user": {
"id": 1001
}
}],
"files": [{
"path": "/var/home/core/vol/config.yaml",
"mode": 400,
"user": {
"id": 1001
},
"contents": {"source": "data:text/plain;base64,@CONFIG_DATA@"}
}]
},
"systemd": {
"units": [{
"name": "planner-agent-ui.service",
"enabled": true,
"contents": "[Unit]\nDescription=Agent UI\nWants=network-online.target\nAfter=network-online.target\nRequiresMountsFor=%t/containers\n\n[Service]\nEnvironment=PODMAN_SYSTEMD_UNIT=%n\nRestart=on-failure\nTimeoutStopSec=70\nExecStart=/usr/bin/podman run --network host --cidfile=%t/%n.ctr-id --cgroups=no-conmon --rm --sdnotify=conmon -p 8443:8443 -d quay.io/kubev2v/planner-agent-ui\nExecStop=/usr/bin/podman stop --ignore -t 10 --cidfile=%t/%n.ctr-id\nExecStopPost=/usr/bin/podman rm -f --ignore -t 10 --cidfile=%t/%n.ctr-id\nType=notify\nNotifyAccess=all\n\n[Install]\nWantedBy=default.target"
}, {
"name": "planner-agent-collector.service",
"enabled": true,
"contents": "[Unit]\nDescription=Podman container-planner-colector.service\nDocumentation=man:podman-generate-systemd(1)\nWants=network-online.target\nAfter=network-online.target\nRequiresMountsFor=%t/containers\n\n[Service]\nType=oneshot\nRestartSec=2s\nExecStartPre=/usr/bin/podman run --rm -v myvol:/mnt:Z --name test-container alpine sh -c \"/usr/bin/test -f /mnt/data/credentials.json\"\nExecStartPre=/usr/bin/podman run -d -p 8181:8181 --network host --entrypoint /usr/bin/opa quay.io/kubev2v/forklift-validation:release-v2.6.4 run --server /usr/share/opa/policies\nEnvironment=PODMAN_SYSTEMD_UNIT=%n\nRestart=on-failure\nTimeoutStopSec=70\nExecStart=/usr/bin/podman run --network host --cidfile=%t/%n.ctr-id --cgroups=no-conmon --rm --sdnotify=conmon --replace -v myvol:/vol:Z --name planner-collector -d quay.io/machacekondra/collector /vol/data/credentials.json /vol/data/inventory.json\nExecStop=/usr/bin/podman stop --ignore -t 10 --cidfile=%t/%n.ctr-id\nExecStopPost=/usr/bin/podman rm -f --ignore -t 10 --cidfile=%t/%n.ctr-id\nType=notify\nNotifyAccess=all\n\n[Install]\nWantedBy=default.target"
}, {
"name": "planner-agent.service",
"enabled": true,
"contents": "[Unit]\nDescription=Podman container-planner-agent.service\nDocumentation=man:podman-generate-systemd(1)\nWants=network-online.target\nAfter=network-online.target\nRequiresMountsFor=%t/containers\n\n[Service]\nEnvironment=PODMAN_SYSTEMD_UNIT=%n\nRestart=on-failure\nTimeoutStopSec=70\nExecStartPre=/usr/bin/podman volume create myvol\nExecStartPre=/usr/sbin/setenforce 0 \nExecStartPre=/usr/bin/podman run --rm -v /var/home/core/vol:/src:Z -v myvol:/mnt:Z --name temp-container alpine sh -c \"cp -r /src/* /mnt/ && chmod -R a+rw /mnt\"\nExecStart=/usr/bin/podman run -p 3333:3333 --cidfile=%t/%n.ctr-id --cgroups=no-conmon --rm --sdnotify=conmon --replace -d -v myvol:/agent:Z --name planner-agent quay.io/machacekondra/planner-agent -config /agent/config.yaml\nExecStop=/usr/bin/podman stop --ignore -t 10 --cidfile=%t/%n.ctr-id\nExecStopPost=/usr/bin/podman rm -f --ignore -t 10 --cidfile=%t/%n.ctr-id\nType=notify\nNotifyAccess=all\n\n[Install]\nWantedBy=default.target"
}]
}
}
8 changes: 8 additions & 0 deletions data/config.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
config-dir: /agent/config
data-dir: /agent/data
log-level: debug
source-id: @CONFIG_ID@
update-interval: 5s
planner-service:
service:
server: http://@CONFIG_IP@:7443
16 changes: 13 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/net-byte/go-gateway v0.0.2
github.com/oapi-codegen/nethttp-middleware v1.0.2
github.com/oapi-codegen/runtime v1.1.1
github.com/openshift/assisted-image-service v0.0.0-20240827125623-ad5c4b36a817
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
Expand All @@ -31,9 +32,12 @@ require (
github.com/ajg/form v1.5.1 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/bytedance/sonic v1.10.0-rc3 // indirect
github.com/cavaliercoder/go-cpio v0.0.0-20180626203310-925f9528c45e // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/diskfs/go-diskfs v1.4.0 // indirect
github.com/elliotwutingfeng/asciiset v0.0.0-20230602022725-51bbb787efab // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
Expand All @@ -47,9 +51,10 @@ require (
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.1 // indirect
github.com/go-playground/validator/v10 v10.15.5 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
Expand Down Expand Up @@ -80,24 +85,29 @@ require (
github.com/openshift/api v0.0.0-20230613151523-ba04973d3ed1 // indirect
github.com/openshift/custom-resource-status v1.1.2 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pelletier/go-toml/v2 v2.0.9 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/xattr v0.4.9 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/arch v0.4.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/djherbis/times.v1 v1.3.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit e34d09f

Please sign in to comment.