Skip to content

Commit

Permalink
WIP: use stream metadata
Browse files Browse the repository at this point in the history
See openshift/os#477

TODO:

 - Azure
 - Multiple architectures
  • Loading branch information
cgwalters committed Jan 21, 2021
1 parent 3a733a5 commit a36299c
Show file tree
Hide file tree
Showing 18 changed files with 761 additions and 301 deletions.
242 changes: 242 additions & 0 deletions data/data/rhcos-4.7-stream.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
{
"stream": "rhcos-4.7",
"metadata": {
"last-modified": "2021-01-21T16:24:12Z"
},
"architectures": {
"x86_64": {
"artifacts": {
"aws": {
"release": "47.83.202012030221-0",
"formats": {
"vmdk.gz": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-aws.x86_64.vmdk.gz",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-aws.x86_64.vmdk.gz.sig",
"sha256": "c8b741671cf4f2c13a1de4068ed2bb2d3f09479c89d205789c1cc58e76bd7eda",
"uncompressed-sha256": "732e2d6b4745fae4dd9385bee75f199af2121e4d3a8eae92600c8c826119388c"
}
}
}
},
"azure": {
"release": "47.83.202012030221-0",
"formats": {
"vhd.gz": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-azure.x86_64.vhd.gz",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-azure.x86_64.vhd.gz.sig",
"sha256": "f1da54a42b2178e8ab0eda2a3d8aa613b3cf1809c0a92e0b94124a27370dea9c",
"uncompressed-sha256": "6201d201935e9e1cc144ae77d151ea736dd601ecbad246edc9cc1d75a1d93e41"
}
}
}
},
"gcp": {
"release": "47.83.202012030221-0",
"formats": {
"tar.gz": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-gcp.x86_64.tar.gz",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-gcp.x86_64.tar.gz.sig",
"sha256": "5837067659ad7055f0614bd0feb867322b1832f901dd513520beada7f5ba6b09",
"uncompressed-sha256": ""
}
}
}
},
"ibmcloud": {
"release": "47.83.202012030221-0",
"formats": {
"qcow2.gz": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-ibmcloud.x86_64.qcow2.gz",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-ibmcloud.x86_64.qcow2.gz.sig",
"sha256": "515f13f6d78d6b1e0f52656d49754345ec6fc8a5c64f53c18d8577c907929118",
"uncompressed-sha256": "b12038dfc63f0816b1dc459278eda266eed3eca228bf771ec005b8a7407fc469"
}
}
}
},
"metal": {
"release": "47.83.202012030221-0",
"formats": {
"4k.raw.gz": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-metal4k.x86_64.raw.gz",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-metal4k.x86_64.raw.gz.sig",
"sha256": "81b63723a643530f2a50f656baa097894d8a064c89c7468ed570cec1dbb6157f",
"uncompressed-sha256": "e94fbd8615d1790ab39ac6ad29eaf0ddd5f726d65fab4a31b71b2c66cf507d47"
}
},
"iso": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-live.x86_64.iso",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-live.x86_64.iso.sig",
"sha256": "21a05f87fc7e4609d635481dc4d09d061cc32acd09657b050fd62a9b4f42677b",
"uncompressed-sha256": ""
}
},
"pxe": {
"kernel": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-live-kernel-x86_64",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-live-kernel-x86_64.sig",
"sha256": "7c297b7daee6a01c7a09b68f9fe4a655580168113e8730917f061fecbe8ceb32",
"uncompressed-sha256": ""
},
"initramfs": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-live-initramfs.x86_64.img",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-live-initramfs.x86_64.img.sig",
"sha256": "36eb33777fa768fa8de0a862265e553d952bb7636b800cbdd1fc4ac3d4cb03db",
"uncompressed-sha256": ""
},
"rootfs": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-live-rootfs.x86_64.img",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-live-rootfs.x86_64.img.sig",
"sha256": "b52a5197c5db12971ce7e52f217f3fa6da30ffe04150a3eaa4c8319db7072ca5",
"uncompressed-sha256": ""
}
},
"raw.gz": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-metal.x86_64.raw.gz",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-metal.x86_64.raw.gz.sig",
"sha256": "77702ef31e3a15042df51f36a83f8b5afcb15576858482c32a15fb9cfa0424b6",
"uncompressed-sha256": "983293a570e30ed50fe07b51bb5ed5ef798810a022e24e65ae5f3290b38d7ceb"
}
}
}
},
"openstack": {
"release": "47.83.202012030221-0",
"formats": {
"qcow2.gz": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-openstack.x86_64.qcow2.gz",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-openstack.x86_64.qcow2.gz.sig",
"sha256": "cde9caedbe67d921ab9ff76a71f62b0172f863f1a984d2ce5aa0fccac090b3f8",
"uncompressed-sha256": "b487344e1e104f9f34985ec5015ffd8b532df4c357137c38c7cbbd7289fb881a"
}
}
}
},
"qemu": {
"release": "47.83.202012030221-0",
"formats": {
"qcow2.gz": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-qemu.x86_64.qcow2.gz",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-qemu.x86_64.qcow2.gz.sig",
"sha256": "4104496474292789b7ef5414a5678cd886d9e22895e3227b14f2c93408a0af26",
"uncompressed-sha256": "f0a028820a263ed4156104a5ae57ae96ca4a8ec93c5b879843ef378a43e6a993"
}
}
}
},
"vmware": {
"release": "47.83.202012030221-0",
"formats": {
"ova": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-vmware.x86_64.ova",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/rhcos-4.7/builds/47.83.202012030221-0/x86_64/rhcos-47.83.202012030221-0-vmware.x86_64.ova.sig",
"sha256": "d9c480df7d5545b86e32cfd711de3c1a682bed255b7fd9b8075f58c38bd41c1d",
"uncompressed-sha256": ""
}
}
}
}
},
"images": {
"aws": {
"regions": {
"af-south-1": {
"release": "47.83.202012030221-0",
"image": "ami-03dc8417bfb54885e"
},
"ap-east-1": {
"release": "47.83.202012030221-0",
"image": "ami-055665dc9e9799296"
},
"ap-northeast-1": {
"release": "47.83.202012030221-0",
"image": "ami-0f67d9a2324e93380"
},
"ap-northeast-2": {
"release": "47.83.202012030221-0",
"image": "ami-0af7d134b7362c59c"
},
"ap-south-1": {
"release": "47.83.202012030221-0",
"image": "ami-0bfb5d254a69b7419"
},
"ap-southeast-1": {
"release": "47.83.202012030221-0",
"image": "ami-08e130fb7b06c0d5d"
},
"ap-southeast-2": {
"release": "47.83.202012030221-0",
"image": "ami-0bec9aae9292db769"
},
"ca-central-1": {
"release": "47.83.202012030221-0",
"image": "ami-0f0d4fd027aafa9ec"
},
"eu-central-1": {
"release": "47.83.202012030221-0",
"image": "ami-0b299978f75c6fab7"
},
"eu-north-1": {
"release": "47.83.202012030221-0",
"image": "ami-0a9cf69e21ee6efa7"
},
"eu-south-1": {
"release": "47.83.202012030221-0",
"image": "ami-00813d96eb14a5a94"
},
"eu-west-1": {
"release": "47.83.202012030221-0",
"image": "ami-01e09e74477d926f3"
},
"eu-west-2": {
"release": "47.83.202012030221-0",
"image": "ami-09009bcbfb3ffc566"
},
"eu-west-3": {
"release": "47.83.202012030221-0",
"image": "ami-052ce7993e1a51903"
},
"me-south-1": {
"release": "47.83.202012030221-0",
"image": "ami-08d9bf8527beecee4"
},
"sa-east-1": {
"release": "47.83.202012030221-0",
"image": "ami-07eec7d9a8e420ea1"
},
"us-east-1": {
"release": "47.83.202012030221-0",
"image": "ami-0996bc3576195a2f0"
},
"us-east-2": {
"release": "47.83.202012030221-0",
"image": "ami-0c0b5ea0a4ebe87d5"
},
"us-west-1": {
"release": "47.83.202012030221-0",
"image": "ami-067abd73d16691225"
},
"us-west-2": {
"release": "47.83.202012030221-0",
"image": "ami-055cdcaf3b4d54a91"
}
}
},
"gcp": {
"project": "rhcos-cloud",
"name": "rhcos-47-83-202012030221-0-gcp-x86-64"
}
}
}
}
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ require (
github.com/clarketm/json v1.14.1
github.com/containers/image v3.0.2+incompatible
github.com/coreos/ignition/v2 v2.3.0
github.com/coreos/stream-metadata-go v0.0.0-20210121193119-2fbf8747cee7
github.com/dmacvicar/terraform-provider-libvirt v0.6.2
github.com/fatih/color v1.10.0 // indirect
github.com/frankban/quicktest v1.7.2 // indirect
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,14 @@ github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea/go.mod h1:E3G3o1h8I7cfc
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/prometheus-operator v0.35.0/go.mod h1:XHYZUStZWcwd1yk/1DjZv/fywqKIyAJ6pSwvIr+v9BQ=
github.com/coreos/prometheus-operator v0.38.0/go.mod h1:xZC7/TgeC0/mBaJk+1H9dbHaiEvLYHgX6Mi1h40UPh8=
github.com/coreos/stream-metadata-go v0.0.0-20210115160721-ba77d4e64952 h1:t7IgMcyflINfXWPISnHTXwa/F+NxLgWGRGejoyfHUII=
github.com/coreos/stream-metadata-go v0.0.0-20210115160721-ba77d4e64952/go.mod h1:RTjQyHgO/G37oJ3qnqYK6Z4TPZ5EsaabOtfMjVXmgko=
github.com/coreos/stream-metadata-go v0.0.0-20210119202048-fb3ac10789fb h1:a1FamXpn1idyCsvXOAEdlmAWDZi6baC6sP2mJ/iHiHs=
github.com/coreos/stream-metadata-go v0.0.0-20210119202048-fb3ac10789fb/go.mod h1:RTjQyHgO/G37oJ3qnqYK6Z4TPZ5EsaabOtfMjVXmgko=
github.com/coreos/stream-metadata-go v0.0.0-20210120211222-7575c72c6f05 h1:GXgmcV54WyU3LDXRwf3vXtgkmajMHoYfQ/qCuPblr4A=
github.com/coreos/stream-metadata-go v0.0.0-20210120211222-7575c72c6f05/go.mod h1:RTjQyHgO/G37oJ3qnqYK6Z4TPZ5EsaabOtfMjVXmgko=
github.com/coreos/stream-metadata-go v0.0.0-20210121193119-2fbf8747cee7 h1:6LNM7FalzC7155uc5ecuUmD1x70QsOexZYGVHnLc4OE=
github.com/coreos/stream-metadata-go v0.0.0-20210121193119-2fbf8747cee7/go.mod h1:RTjQyHgO/G37oJ3qnqYK6Z4TPZ5EsaabOtfMjVXmgko=
github.com/coreos/vcontext v0.0.0-20190529201340-22b159166068/go.mod h1:E+6hug9bFSe0KZ2ZAzr8M9F5JlArJjv5D1JS7KSkPKE=
github.com/coreos/vcontext v0.0.0-20191017033345-260217907eb5/go.mod h1:E+6hug9bFSe0KZ2ZAzr8M9F5JlArJjv5D1JS7KSkPKE=
github.com/coreos/vcontext v0.0.0-20200225161404-ee043618d38d h1:Nu473BdYOxcnhFfPrl1ihpCtxI/VZr2IfhVIHDGP43Y=
Expand Down
22 changes: 18 additions & 4 deletions pkg/asset/cluster/tfvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
azureprovider "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1beta1"
openstackprovider "sigs.k8s.io/cluster-api-provider-openstack/pkg/apis/openstackproviderconfig/v1alpha1"

coreosarch "github.com/coreos/stream-metadata-go/arch"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/ignition"
"github.com/openshift/installer/pkg/asset/ignition/bootstrap"
Expand Down Expand Up @@ -170,6 +171,16 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
return errors.Errorf("master slice cannot be empty")
}

archName := coreosarch.RpmArch(fmt.Sprintf("%s", installConfig.Config.ControlPlane.Architecture))
st, err := rhcospkg.FetchCoreOSBuild(ctx)
if err != nil {
return err
}
starch, err := st.GetArchitecture(archName)
if err != nil {
return err
}

switch platform {
case aws.Name:
var vpc string
Expand Down Expand Up @@ -338,16 +349,19 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
}
preexistingnetwork := installConfig.Config.GCP.Network != ""

imageRaw, err := rhcospkg.GCPRaw(ctx, installConfig.Config.ControlPlane.Architecture)
if err != nil {
return errors.Wrap(err, "failed to find Raw GCP image URL")
var gcpimage string
if starch.Images.Gcp != nil {
img := starch.Images.Gcp
gcpimage = fmt.Sprintf("projects/%s/global/images/%s", img.Project, img.Name)
} else {
return fmt.Errorf("%s: No GCP build found", st.FormatPrefix(archName))
}
data, err := gcptfvars.TFVars(
gcptfvars.TFVarsSources{
Auth: auth,
MasterConfigs: masterConfigs,
WorkerConfigs: workerConfigs,
ImageURI: imageRaw,
ImageURI: gcpimage,
ImageLicenses: installConfig.Config.GCP.Licenses,
PublicZoneName: publicZoneName,
PublishStrategy: installConfig.Config.Publish,
Expand Down
45 changes: 32 additions & 13 deletions pkg/asset/rhcos/bootstrap_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package rhcos

import (
"context"
"fmt"
"time"

"github.com/coreos/stream-metadata-go/arch"

"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
"github.com/openshift/installer/pkg/rhcos"
Expand Down Expand Up @@ -37,28 +40,44 @@ func (i *BootstrapImage) Generate(p asset.Parents) error {
p.Get(ic)
config := ic.Config

var osimage string
var err error
ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
defer cancel()

archName := arch.RpmArch(fmt.Sprintf("%s", config.ControlPlane.Architecture))
st, err := rhcos.FetchCoreOSBuild(ctx)
if err != nil {
return err
}
starch, err := st.GetArchitecture(archName)
if err != nil {
return err
}

switch config.Platform.Name() {
case baremetal.Name:
// Check for RHCOS image URL override
// Check for CoreOS image URL override
if boi := config.Platform.BareMetal.BootstrapOSImage; boi != "" {
osimage = boi
break
*i = BootstrapImage(boi)
return nil
}

// Baremetal IPI launches a local VM for the bootstrap node
// Hence requires the QEMU image to use the libvirt backend
osimage, err = rhcos.QEMU(ctx, config.ControlPlane.Architecture)
if a, ok := starch.Artifacts["qemu"]; ok {
u, err := rhcos.FindArtifactURL(a)
if err != nil {
return err
}
*i = BootstrapImage(u)
return nil
}
return fmt.Errorf("%s: No qemu build found", st.FormatPrefix(archName))
default:
// other platforms use the same image for all nodes
osimage, err = osImage(config)
}
if err != nil {
return err
u, err := osImage(config)
if err != nil {
return err
}
*i = BootstrapImage(u)
return nil
}
*i = BootstrapImage(osimage)
return nil
}
Loading

0 comments on commit a36299c

Please sign in to comment.